how to take path location from textbox and put it in batch - batch-file

Hello guys im trying to make an extension that open any exe on user computer by simply textbox.user will write the path of exe he wants to open and i need to take that path to batch file and run it is that possible if that so how?
my current batch file only open one path but i want it to take paths from user and open that exe on path location

Well, Native Messaging does not allow you to pass command line parameters. It will only allow communication using the Native Messaging protocol (length + JSON-enconded message).
So you need to make a single native host that is able to read an incoming message, decode it and execute the command you want, i.e.:
// Extension side
chrome.runtime.sendNativeMessage('native.app.id.here', { command: "calc.exe" });
and then the app will receive, through STDIN, the length of the message + {"command":"calc.exe"}
Actually writing code that will decode that message using batch scripting is a terrible idea, but doable in principe. You should probably write an actual program in a language with support for JSON manipulation to handle this. See also this question.

Related

How can I make a file hard to read like the bellow attached file ( image )

I have some .sh files, this file contains my ssh and scp details.
I would like to encrypt the ssh files, upon encryption It should be able to execute/run.
like the background.js ( attachment ) file is encrypted but still executing in the browser
Background:
There is a difference between obfuscation and encryption.
Obfuscation hides the data or makes it hard to read, but it is still theoretically possible to reverse this and get back the original source data.
Encryption actually uses cryptography to make it near-impossible to decrypt without a key.
I believe the image I'm looking at above is "obfuscated" and not "encrypted" based on the details that you've provided.
Answer:
If you're running this file on a machine and not in a browser, I'd recommend looking at compiling it into an executable which will compile it into bytecode. This will likely accomplish your original intent of hiding the source. Nexe is one tool for NodeJS that can do this.
If you're running this in the browser, then you can only really obfuscate it. Terser is a library for this in NodeJS
And lastly, a common pattern for hiding ssh details is to put them into environment variables and have a script reference the environment variables rather than actually putting the credentials in the code.
In JS, that would be process.env.PASSWORD

Can reactJS write into file?

As my title says, is it possible? I am begginer at front-end and trying to teach myself reactJS right now. I learned some javascript before and I know it is impossible to read or write files with it. Mainly what I want to do is to get string from input and lets say write it into file.
Well the question is, where does that file live?
Node is able to write to files because the files exist on the server that node is running on.
React runs in browser so there is no shared file system to write to. You can read from a file because the contents of that file get bundled into the Javascript that gets served to the browser.
If you want to write to a file, you would need to send an API request from your browser / React to a server and have that server write to the file system.
Additionally, as pointed out by Huy Nguyen, it's possible to write to the clients file system from the browser but that is going to be private to that user.
Your question is a bit vague. In addition to what #Stretch0 said, it's possible to read/write files on a user's computer using the browser's native APIs. Here is a good tutorial.

Run a .exe file when a file is opened in a folder

I am mounting a folder as a virtual drive and i want to run a .exe file everytime user opens any file present in that folder. To be precise the folder would contain dummy files present on some other machine. By dummy files i mean the file would be listed but it would be a empty file. Whenever user opens a file i want the .exe program to download that file from another machine and display it to user.
That functionality (remote access on demand) can be implemented using reparse points and file system filters.
You could
use hooks to rewrite the jump address of OpenFile and in the
detour function check for the handle type, retrieve it's info by
using GetFileInformationByHandleEx, parse the data, download
what you need, open the downloaded file and then return
STATUS_SUCCESS or any appropriate error status in case one occurs.
Note
this is a bit more complicated as you also need a auto-inject
mechanism to inject function/library into each process according to
it's architecture.
this is not a safe procedure as most AV's will most likely consider your code malware.

Reading a web address in a batch file

I can open a web browser using an address saved in a batch file. However, I am looking for a way to save the address when I close the window, without having to manually re-edit the file by hand.
I can read/write to a text file; the only part I am not figuring out is how to access the address of the open web tab. Is this do-able through a batch? Or do I need to take a different approach?
The web browsers save address information either in a file or in Windows registry from where it can be read by a batch script.

How to upload image file using cgi program written in c language?

I wanted to upload a jpeg image file on the server.I have a GoAhead web server which supports only cgi c program as a serverside handeling.
Can any one know how to handle http posted image file in program witten in cgi in c language?
The GoAhead web server has a file upload filter for this purpose. The upload filter receives the uploaded file and saves it to disk. It then sets some request variables describing the upload. Those variables are accessible via CGI or via action functions or JST templates.
There is an example in test.c. Search for uploadTest().
See: https://github.com/embedthis/goahead/blob/master/test/test.c
To get POST data just read stdin. Environment variable CONTENT_LENGTH tells you how much to expect but of course you need to make your code robust against whatever a potentially malicious user can throw at you.

Resources