When I was looking into nifty Raspberry Pi projects, I stumbled across the PirateBox project. The website describes it well:
PirateBox is a DIY anonymous offline file-sharing and communications system built with free software and inexpensive off-the-shelf hardware.
In other words, it’s a bit of preconfigured software you can run on a Raspberry Pi that lets folks chat, share files, and peruse forums on an offline network created by the Pi. Oh, and it’s GPLv3! Open source software FTW!
I have always disliked sharing files via Airplay (Mac-only), Dropbox, or other methods. They work, but require some mental overhead and for everything to magically work. There’s also sharing via USB, but with USB C, that got slightly more annoying.
To me, PirateBox sounded perfect. I could quickly fire up a network from my backpack and share files with those around me. I could use it at meetups or WordPress events after loading it up with some WordPress stuff so folks don’t have to deal with sketchy internet to download software. All pretty pragmatic uses.
I also really like the idea of firing it up when I’m working at busy coffee shops and at conferences to see what folks do with it. Will they try to add malicious software? Will they add poetry and selfies? I guess I will find out!
Yesterday, I downloaded the PirateBox software and loaded it onto a Raspberry Pi Zero W. That’s the itty bitty Raspberry Pi. The folks who put the PirateBox together did an excellent job. It was super straightforward to set up and didn’t require a monitor, or any attached keyboard or mouse. I spotted the PirateBox network on my Mac, joined it, and connected via SSH.
For those of you unfamiliar with SSH, you can crack open Terminal (in Mac) or a console in Linux and talk to another computer. PirateBox walks through the process right on the site.
After I followed the short and sweet setup instructions, I opened a browser window and was greeted with the PirateBox interface.
I tested out just about everything (except the forum) to make sure it worked. Then I decided it was time for me to do some design magic to the interface. It was not the easiest process to figure out as I had to locate the files and understand their build.
How to customize the interface
The important files are all over the place and were somewhat of a mystery to locate. This should help out folks in the future.
The home page
/mnt/sdshare/share/content and its subdirectories. They are fairly straightforward. There is some jQuery in use so make sure you keep an eye on which IDs are changed to avoid breaking jQuery functionality. I mostly rewrote the CSS keeping a few of the things from the original. I’ll be open sourcing these shortly (when I figure out the best format).
Much to my surprise and delight, there is some basic, but functional localization of the web app. If you want to change text on the home page, you will likely need to change it in multiple places. You will need to change it in the HTML and in the corresponding file in
/mnt/sdshare/share/content/locales/. Bonus points if you translate your new or modified strings!
The file browser HTML
I found the file browser HTML to be one of the quirkiest bits. It’s split into three parts. The two you likely will want to mess with are located in
/mnt/sdshare/share/Shared/. This is also where your uploads end up by default.
The two files are the first half of the page and last half of the page. The first half is
HEADER.txt. Why it is a
txt file is beyond me. The second half is in
README.txt. Again, why these are this way are a mystery. However, they are just basic HTML and are easy enough to modify.
The chat content
If you for some reason want to clear out the chat or remove a comment, you will need to modify at least one file. The important one is
/opt/piratebox/www/cgi-bin/data.pso. If you remove content from this file. the next time someone uses the chatbox, it will regenerate the second file,
/opt/piratebox/www/chat_content.html, which is used to render the chat and. This will remove the content. If you want it gone from the chat view immediately, you will need to remove the same content from both.
I wanted to add some breathing room, make it feel friendlier (for my non-pirate friends), and make it look good on high resolution screens so I did just that.
As you can see, it’s not perfect. The header’s a bit big, but hey I did this in an afternoon and I can fix that up as I iterate. I also need to style the upload a bit nicer.
It’s also mobile-friendly and should be fairly accessible. I think a few of the chat box’s form fields could use labels so maybe I’ll add those the next time I mess with it.
For those curious, here’s what the final build looks like.
It’s just a Raspberry Pi Zero W with an SD card and power supply. I put it in a nifty case I found on Amazon, but that’s unnecessary. It might even be cool to strip off unused ports to lighten it and put it in a book, wallet, or maybe even a clever laptop case.
What do you think of this idea? What cool things would you use it for? Leave a comment!
in this tutorial, author said use ethernet for first usage. But in Zero-W, we don’t have ethernet port. What are you doing ?
What is the code you use for that UI I want to do that
Sadly I locked myself out of that box. I will likely redo it for a future defcon and open source the code.