Quick File Transfer Hack

Chad Sigler
Virtru Technology Blog
2 min readJul 1, 2020

Virtru Python SDK with Magic Wormhole

Photo by John Paul Summers on Unsplash

Hello from a freshly cleaned and sanitized workspace! I stumbled onto (again) a really useful and easy tool, Magic Wormhole. It is quite possibly the easiest file transfer tool around for on-demand one-off file transfers. I think it is fantastic and well implemented from a usability standpoint. But what if I need to transfer “sensitive” data? I have an answer! Today I will be diving into encrypting data using the Virtru Python SDK and transferring it using Magic Wormhole.

But, I will be using PyPi to get the Virtru SDK onto my system.

Magic Wormhole Usage

Sender

apt install magic-wormhole
wormhole send test.txt
Sending 57.6 kB file named 'test.txt'
On the other computer, please run: wormhole receive
Wormhole code is: 8-dictator-artist
Sending (->relay:tcp:magic-wormhole-transit.debian.net:4001)..
100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 57.6k/57.6k [00:00<00:00, 2.04MB/s]
File sent.. waiting for confirmation
Confirmation received. Transfer complete.

Receiver

apt install magic-wormhole
wormhole receive
Enter receive wormhole code: 8-dictator-artist
(note: you can use <Tab> to complete words)
Receiving file (57.6 kB) into: test.txt
ok? (y/N): y
Receiving (->relay:tcp:magic-wormhole-transit.debian.net:4001)..
100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 57.6k/57.6k [00:00<00:00, 1.03MB/s]
Received file written to test.txt

That's it!

Secure Wormhole Transfer

To ensure my data is not available to unwanted persons, I will be using the following gist project to encrypt and decrypt the data. To make it easier the code is parameterized for reusability clarity.

Virtru Code

Usage

virtru-app.py [-h] -o OWNER -p APPID -a {encrypt,decrypt} -s SOURCE -t TARGET [-u USERS]optional arguments:
-h, --help show this help message and exit
-o OWNER, --owner OWNER
AppId Owner (user@domain.com)
-p APPID, --appid APPID
AppId (1522710c-833f-4a69-8a26-0bbb00b1345c)
-a {encrypt,decrypt}, --action {encrypt,decrypt}
Action
-s SOURCE, --source SOURCE
Source File (Full path or reference path)
-t TARGET, --target TARGET
Target File (Full path or reference path)
-u USERS, --users USERS
Additional users added to the policy
('user1@example.com,user2@domain.com')

Encrypt and Send

pip3 install virtru-sdkpython3 virtru-app.py \
-a encrypt \
-o "bob@example.com" \
-p "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa" \
-s "test.txt" \
-t "test.txt.tdf3" \
-u "karen@demo.com"
wormhole send test.txt.tdf3

Receive and Decrypt

pip3 install virtru-sdkwormhole receive test.txt.tdf3python3 virtru-app.py \
-a decrypt \
-o "karen@demo.com" \
-p "bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb" \
-s "test.txt.tdf3" \
-t "test.txt" \

Conclusion

After refinding the wormhole tool, I will definitely use it when I need to move files around on console sessions and do not want to use SFTP or the like. Another fantastic tool from the open-source community.

--

--