One of the things that I sometimes find myself in need of is to share a file, fast. Occasionally I have found that I need to have a large file given to me, or I need to give someone an inconveniently large file myself. In the past, I have resorted to many different types of shenanigans. There are lots and lots of ways to share files on the Internet, some fairly shady, some not. Take a look at drop.io, or isendr for some of my favorite ways to do this. In many cases, someone wants to send me an infected file for analysis, and just as often I need to send out a private document. In these cases, using any number of Internet sites is unacceptable, dangerous, or simply not an option. Even if the website doesn’t centrally host the document, (isendr doesn’t), it can be unreliable. So I look to the command line. One trick that I like and probably will continue to use for some cases is the python SimpleHTTPServer. Run it like this to share all the files in your current working directory:
python -m SimpleHTTPServer 8080
As I said, this shares the contents of your current working directory. It is a quick and dirty way to do it, however, and although it won’t allow directory traversal per se, everything in your hierarchy below this is going to be available. Also it is not particularly graceful when quitting. Use with caution. So while this works to a certain extent, there are limitations. One big roadblock is that this is not something that I can usually recommend for someone trying to share a file with me. There are simply to many hurdles (firewall, NAT, python installed?, etc) that I don’t want to try to troubleshoot.
This is where a few great python scripts available around the Internet shine. These handy little snippets of code perform simple tasks with grace and aplomb. Let me take you through what each one does, and then walk you through the process of installing them. First scenario, you have a file that you need to share. Woof does a great job of creating a one time link for a file from my machine, and then it closes itself down as soon as it is downloaded. Perfect. To install it, first you need to have python installed. OSX has it by default, Linux users probably already have it installed. Then you need to get the latest version from here. Now you have a file sitting in your downloads folder. You can either run it with the python interpreter (not recommended) while in that directory like this:
python woof.sh somefile.txt
which will spit out a link for you to give your friend who needs the file, and then will end the program after the file has been transferred, or you can set it up the convenient way. I will give the specific code for people using OSX, if you are running Linux you will have to modify where you put it, probably. First, make the file executable:
chmod u+x woof.sh
Then rename the file so you don’t have to worry about extensions
mv woof.sh woof
Then you can copy the file into your bin, which will allow you to run it from any folder straight from the command line:
mv woof /usr/bin
If you are running linux, you can move it to the root /bin, or depending on your version you may put it in /home/bin. After that you can restart your terminal session, and it should work just fine. Now just navigate to the file you want to share, and woof it over to the receiver:
woof ~/Downloads/someawesomefile.blam
Which gives you a line like this:
Now serving on http://10.10.52.16:8080/
Just give that line to the person, they punch it into their browser, and the download will commence. After the download is complete, the server automatically exits, preventing others from accesing the file, even if you forget. Not to shabby. Very useful for serving up one quick file from your computer to someone else’s.Now what if someone wants to give you a file? Not to worry, Droopy has you covered. Droopy is another quick little python server that allows people to visit a website temporarily created on your computer and upload any number of files to a directory that you specify. It even lets you give them a friendly message. I first saw it in this post on WebWorkerDaily. After they are done, I can simply quit the program from the command line with ctl+c. It gracefully closes down the program. First download the latest copy from here. You can then follow the steps outlined above to move it into your /usr/bin directory so that you can run it anywhere. Then run it like this
droopy -d ~/uploads
Assuming that you created the uploads folder previously, then this will create a snazzy little webpage that you can direct people to that will allow them to upload a file directly onto your system, in the folder specified. w00t! Here is a screenshot of what my page looks like:
There are also other fun little things that you can do with it, like give them a message to read, or a picture to look at on the upload page. Check out the -h option for all those details.
