R
R
Root Wood2020-10-12 18:53:48
Automation
Root Wood, 2020-10-12 18:53:48

How to write a script on a flash drive that will run itself when it is connected on any platform (win, mac, lin)?

I have a bunch of sd and usb flash drives, and sometimes my friends like to borrow them for a short (very long time), and without my knowledge. And in a week I can’t find all my flash drives.

I want to write a script, put it on a flash drive, and have it run itself when the flash drive is connected to the PC. The script is simple, like a normal GET request to some of my example.com/flash_id=1. Thus, I will know that my flash drive is "walking" somewhere.

Writing a script that makes a GET request is easy, but how can I make it run itself when connected to a PC?

Answer the question

In order to leave comments, you need to log in

6 answer(s)
S
Sergey Karbivnichy, 2020-10-12
@hottabxp

In Linux, this most likely will not work (most likely in MacOS). On Windows, autorun must be enabled.
Actually, this is a dumb question. Hide your flash drives, or keep thieves out of your house.
If you want to find out who took your flash drive, there has long been a proven solution - USB Killer. 100% find out who took your flash drive.
5f847d783bb5a301892264.jpeg

L
lonelymyp, 2020-10-12
@lonelymyp

Google about badusb.
You can make a flash drive with an additional load, that is, the flash drive will be presented in the system both as a flash drive and as a keyboard, and for example by sending a combination of buttons to launch a command line in which to execute a given command.
Of course, things are considered malicious and antiviruses react to this.

A
Alexey Kharchenko, 2020-10-12
@AVX

This is actually an interesting topic!
Although they tell you that you need to do it differently (I kind of agree), but the method with the script has the right to life.
And here we have to divide it into 2 parts: 1. Social and 2. Technical.
1. Social engineering. You need to make sure that the target audience (it will have to figure out who will mainly use the USB flash drive) wants to run this file. Name it something.... to be interesting to a potential audience, for example "iq test" (yes, funny, you can display a picture with "F*** you sucker!"). In short, just to run it.
2. Technical. It is necessary to ensure that this file starts on both Windows and Linux. On a flash drive, most often exFAT, and the "x" (executable) flag cannot be put on the file there, but if you simply specify to execute the file in the console or other script, it will be executed (it also depends on the method of mounting in a particular system, you can disable launching executables from there). Actually, it is far from trivial to make a script so that the same file is executed both in Windows and in Linux, but it is POSSIBLE (I did it, don't ask why). Much easier to do separately for Windows and separately for Linux.
Register in autoload - for Windows, autorun.inf is at the root, well, specify what and how to run there (yes, autorun can be disabled on your computer, so option 1 needs to be worked out).
In Linux, there is (or was there?) a hole in KDE and other shells, more precisely, even this didn’t really belong to the shell, something else was there, but the point is that some file managers (Dolphin, for example, which is the default file manager in KDE) use .directory files (hidden by default), in which you can prescribe (and they themselves prescribe) the view mode, and other data. So you can specify the path to the icon there, and instead of showing the picture on the script, when you open the folder (flash drive, if you put it in the root), this script will be executed. But it seems that this has already been fixed with updates, but there are still different ways both in Linux and in Windows, too, to make the desired file work.
And how to call curl with the necessary parameters and how to count hits on the server - think for yourself, it's not difficult.
In short, there is a large field for flight :)
PS Antiviruses can swear at this...

A
Adamos, 2020-10-12
@Adamos

Has anyone already done this? Tell me please.

Bill Gates did this. It was called Windows'95, Windows'98, Windows XP.
Finally, the whole world was so overwhelmed with viruses that even he removed the autorun by default.
And no one else did it.
I could advise you to simply format the flash drive in Ext2Fs, but if they take it from you without demand and flirt, then it will be reformatted with the same ease. They also brag to you that they "fixed the problem" ...

W
wisgest, 2020-10-12
@wisgest

For Windows, look for information about the autorun.inf file , but if this feature was previously enabled by default, now it is usually the other way around. For Linux, probably autorun.sh , at least I have such a file, along with autorun.inf, on my 3G modem.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question