ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel
  • »
  • Technology»
  • Computers & Software»
  • Computer Science & Programming

How To Make a 'File Stealing' App on a Mac

Updated on December 1, 2014

What we'll be doing:

In this tutorial, you will learn to create an executable application that searches for files and copies them to a USB. What this means, is you will write a program that will then compile into an executable application. You will put this application on to a USB. Once that is done, you will be able to plug your USB into another computer and have it search for files, then copy them back on to the USB.

Please do not use this knowledge for illicit activities as this tutorial is meant only for educational purposes.

What you need:

TextEdit is the basic text editor that comes installed on Apple computers.

Platypus is an open source software that allows you to compile text files in to executable apps. For this tutorial, we will write our program in a text editor (TextEdit), save that file as a plain text file, and then use Platypus to compile that text file in to an executable app.

What the finished code will look like

mkdir /Volumes/your_flashdrive_name/Data

echo "File Locations" > /Volumes/your_flashdrive_name/Data/FileLocations.txt
mdfind testingtesting >> /Volumes/your_flashdrive_name/Data/FileLocations.txt

find ~/ -iname "thisisatest*" -exec cp {} /Volumes/your_flashdrive_name/Data/ \;

killall FileStealer

Let's begin

Go ahead and open up TextEdit (which comes with every Mac computer), and Copy and paste the code in to a new file. Click format, make plain text, and then save it. Now we'll go over each line of code, what it does, and how you can customize it.

If, at any time, you wish to learn more about a command we are using, you can open up Terminal and type in "man your-command-name" then hit enter for the documentation of that command.

Don't forget to erase your_flashdrive_name and replace it with the name of your flash drive. As an example, my flash drive's name is VUSB, so I would put VUSB in place of your_flashdrive_name

Breaking down the code

Line 1:

mkdir /Volumes/your_flashdrive_name/Data

This line uses the mkdir command to make a folder called Data on your flash drive. So this is essentially making a directory (folder) at /Volumes/your_flashdrive_name/ called 'Data'. This folder is where we will store the files that we copy off of the target computer as well as their locations.

Line 2:

echo "File Locations" > /Volumes/VUSB/Data/FileLocations.txt

This line is another pretty simple one. It uses the "echo" command to creat a text file called FileLocations.txt at the specified file path, and writing the words "File Location" to the beginning of the file. Another example of using the echo command is if you type echo "this is my file" > /your_file_path/output.txt in to terminal, it will create a file at the specified path with the contents "this is my file".

Line 3:

mdfind testingtesting >> /Volumes/VUSB/Data/FileLocations.txt

The third line uses the "mdfind" command to search the entire computer for anything containing "testingtesting", and then outputs all of the file locations to our FileLocations.txt file. Notice the '>>' in the code. Since there are two greater-than signs, that means the output will append to the file, or add on to the end of the file without erasing it. If only one greater than sign is used, the output will replace the contents of the file. With this in mind, it is possible to have the program search for multiple different things and output all of their locations to our text file.

Make sure to replace "testingtesting" with whatever you want the program to search for.

Line 4:

find ~/ -iname "thisisatest*" -exec cp {} /Volumes/VUSB/Data/ \;


Why Are You Making This App?

See results

Finding file locations is great and all, but now it's time to copy some actual files. The fourth line of our program is pretty big, so we'll break it down piece by piece. The first thing this line does is it uses the 'find' command to search the entire system, written as " ~/ ", for anything that has "thisisatest*" in the name. It is important to note that since we used -iname, only the file names will be searched, not the contents. It is also important to notice the asterisk ( * ) after the words 'thisisatest'. This asterisk makes the program account for any kind of file ending, so it can be thought of as almost a synonym for all because it searches all file endings. So now we don't have to make a new line to search for every file type.

The second part of line 4 is where the actual copying is done. It starts off with '-exec', which basically means, if anything is found with 'thisisatest' in the name as we just specified, execute the following command. The following command happens to be 'cp' which stands for 'copy', and the two curly braces signify what is to be copied, but in this case, the file we just searched for is implied as the file to be copied. The file path is simply the location where we wish to copy our files, which in this case, is the Data folder on our USB.

Don't forget to add ' \; ' to the end of the line or it will not execute properly.

Line 5:

killall FileStealer

The final line of our program is very simple. It uses the 'killall' command to kill the application named FileStealer. The only tricky part about this line, is you have replace 'FileStealer' with whatever you name the application in the next step.

Complete with an inconspicuous icon.
Complete with an inconspicuous icon.

Compiling the code

The final step in making our app is to compile the code in to an executable app. To do this, we will use the open source software called Platypus. If you don't have Platypus, you can find it here. Open up Platypus and enter your app name, but make sure it's the same name as the one you used in line 5 of your program. Make sure Script Type is set to shell, and for script path, click select and select your text file that contains the program. You can select your own icon by dragging an image over the default platypus on the left, and set the author to your name. Set output to whatever you want, but I usually just set it to 'none'. This just makes it so that the app won't open any windows (hence the no output) while it's running. Finally, click create.

Once your app is created, put it on your flash drive, plug it in to your computer, and test it out. When you double click it, it should create a folder called Data on the flash drive and create a text file in that folder as well as copying any other files that you specified it to copy. The app is now done!

Taking it further...

So let's say you finished this tutorial and are feeling pretty confident about testing your skills further and learning more. Some challenges to consider might be seeing if you can get the program to email you the information, making the program an executable that is attached to an email, or having it send you information periodically. If you're interested in any of these challenges, or just learning more in general, there are plenty of resources for you to learn coding on the web. Try Googling around for different challenge ideas, and remember that the best way to improve at coding is to keep doing it.

Happy coding!

How did it go?

See results


    0 of 8192 characters used
    Post Comment

    • profile image

      John Smith 13 months ago

      I keep getting this Error:

      ./Library/Saved Application State/com.adobe.flashplayer.installmanager.savedState: Permission denied

      Is there anyway to circumvent this, short of having the owner input their password?

    • profile image

      Mac Stringer 13 months ago

      My problem was that the script said that I didn't have permission to perform a function like that. Is that because I have antivirus software or what?

    • profile image

      Johny 21 months ago

      Am I just supposed to get text locations or is there a way to actually get the files on my usb.

    • profile image

      Alex 22 months ago

      Hi, i just submitted a question a few minutes ago, but i was wondering if it was possible for you to email me about it. please don't make this comments visible to everyone because i don't want to get tons of spam, thanks!

    • profile image

      Alex 22 months ago

      Hello! when I did this it said there was no executable found there. Help?

    • profile image

      John 2 years ago

      It worked for me but i don't know how to get the data folder onto the usb was just on the computer

    • profile image

      3 years ago

      It doesn't seem to work when i put it like this, it finds all pdf documents and puts their location in the .txt file, but it doesn't copy them :/

      here's the code, perhaps there's an obvious mistake i'm making?

      mkdir /Volumes/your_flashdrive_name/Data

      echo "File Locations" "biggerthan"/Volumes/your_flashdrive_name/Data/FileLocations.txt

      mdfind docx "biggerthanx2" /Volumes/your_flashdrive_name/Data/FileLocations.txt

      find ~/ -iname "ekg*" -exec cp {} /Volumes/your_flashdrive_name/Data/ \;

      killall PDFinder

    • VDorchester profile image

      Vail Dorchester 4 years ago from Boulder, Colorado

      Thanks! There are a lot of other good resources around the web if you decide to try to learn more. Programming is very well documented online these days, which makes it pretty easy to find resources to learn from.

    • Marcy Goodfleisch profile image

      Marcy Goodfleisch 4 years ago from Planet Earth

      Well, all I can say is that I am impressed, or something, because this sounds like a cool thing to do, and I totally don't understand what it's all about!!! Time to go back to school or something ! Sounds like you know what you're talking about, though, and I think you offered some good information for those who know what it is about!