Tooling Tuesday: Magic Wormhole
Have you ever needed to send a file to someone who is in the same room? Now where did you put that USB stick?
So what is it?
This is a tool written in Python to send files over a local network by creating a direct link between two devices, a wormhole!
Magic Wormhole was created by Brian Warner and demonstrated at PyCon 2016.
It is a tool to send files direct from two devices in the same room / location where the sender and recipient can speak to one another.
Let's take a typical scenario, where I have some files that I need to transfer to a friends laptop. I reach in my pocket but my USB drives are at home, and yes so are my friends!! So how do I send the files quickly? Well I use Magic Wormhole!
So how do I install it?
Ubuntu / Debian / Raspbian
sudo apt install magic-wormhole
sudo dnf install magic-wormhole
sudo zypper install python-magic-wormhole
sudo snap install wormhole
Mac / OSX
brew install magic-wormhole
Install via pip as there is no dedicated install candidate. Also create a virtual environment to ensure your core Python files are not touched.
virtualenv venv source venv/bin/activate pip install magic-wormhole
If you like what you read...
Sorry to interrupt! But would you like to buy me a cup of coffee? It helps me to pay for hosting this blog, and to buy stuff to hack from Poundshops / Dollar Stores which are used in free projects on this blog. Thanks!
So how do I use it?
To send a file
I'm sat at my laptop and I want to send a file
Th3-M4nd410r14n.mp4 to my friends computer. So I open a terminal and type.
wormhole send Th3-M4nd410r14n.mp4
This will then trigger the following text.
Sending 657 Bytes file named 'Th3-M4nd410r14n.mp4' On the other computer, please run: wormhole receive Wormhole code is: 75-disbelief-cobra
To receive a file
My friend on the other laptop runs the command
and is asked for the Wormhole code. So I shout the code over to them and they press Enter. After confirming the transfer is correct the file is sent over to them.
Do I need to remember the code?
Nope! It is a one time / single use code that is randomly generated and easy to read.
That's it! Easy!
Behind the scenes wormhole opens a random port and sends the file over. In my tests I saw it open many different ports, so anyone wishing to intercept the data would need to port scanning the sender. And this leads me on to security. This is fine for the odd file, but I would never trust any sensitive data with a tool such as this. Follow the security guidelines where you work!
This is a handy tool which I shall add to my toolkit, you never know when you need to transfer a file in a hurry!