I usually kick off every year with the aforementioned greeting, but 2015 will stand as the year I really got sick of what the GNU/Linux ecosystem has become... in pretty much the same way I have been sick of what the Windows ecosystem has become. The mainstream Linux distributions have all become painful to me in ways that I couldn't have imagined just a few years ago. It's been a long, arduous slog. You can ask any of my nerd friends. I've gotten pretty salty over the state of Linux in the past year. And don't get me started on the nightmares of El Capitan and Windows 10, also making 2015 especially brutal.
This evening, though, Linux is weighing especially heavy on my mind. I'm sure the recent passing of Ian Murdock has something to do with it as well. We really did lose one of the heroes this week.
I will still use Linux and Windows for the tasks that they excel in. I will continue to experiment with and master their secrets in order to figure out how they work -- just as I do with other operating systems.
My new year's resolution is to get more and more of my personal stuff migrated to some kind of BSD.
Best wishes to all of you in 2016 from Ax0n.
2015-12-31
No more "Hacky GNU Year"
2015-12-20
Raspberry Pi Zero inside a Lapdock 100
A lot of folks have used the Motorola Lapdock as a portable complement to the Raspberry Pi. It usually ends up as a big mess of cables. My Lapdock was actually used a lot with my last phone, as it was intended to. Occasionally, people would ask me if I was using it for a Pi. My response was "If I can figure out how to fit it inside, I'll try." I always figured it would involve de-soldering all the GPIO headers, network and USB jacks to make it thin enough to fit, then a bunch of soldering to hard-wire everything together.
With the announcement of the Raspberry Pi Zero, I knew it was finally time.
I did a little bit of recon inside the Lapdock case. Plenty of room for a Raspberry Pi Zero and some cables.
Opening up the LapDock isn't too hard. Start by prying the keyboard loose from the top, with a small flat-blade screwdriver or a spudger. Underneath, you will find a single ribbon cable for the keyboard, and a number of screws. Remove the keyboard and all visible screws. The only thing left holding the case together after that are the four screws on the bottom case, one at each corner.
Once I saw the layout inside, my plan was to place some pigtail connectors inside the chamber that the dock connector rests in when not in use. The speaker on the left bottom corner is kind of in the way.
I ordered two cables from Amazon:
Micro HDMI Female to Mini-HDMI Male
USB On-The-Go Extension
I tested everything outside the lapdock first.
Miraculously, both cables worked great. I'd read many horror stories of HDMI cables and adapters that didn't work well with the Raspberry Pi. Not bad for 12 bucks.
Inside, I got to work. First things first, remove the speaker, held in by two screws. Remove the battery, too. It sits loose in the case and is easily unplugged.
At this point, it was obvious to me that I couldn't put the pigtails inside the case where I had planned. There's just not enough room under the speaker. I took the top case apart a little further by removing the screws marked below.
I cut away a little piece of plastic under the speaker to open up some space near where the dock cable rests.
Then, I pried apart the upper part of the dock on one side, giving me enough room to make a cross-shaped hole in the rubber dock membrane by making two slices with a knife.
I'll have to run the pigtails through this corner of the phone dock. I routed the cables through the maze of plastic and shoved them through this hole.
I had to make sure the plugs were oriented properly for a good fit with the dock connector.
To make room for the Pi, I took a knife blade to some of the plastic structures inside the case. A tab (not shown) on the lower case lid also needed to be trimmed.
The final part before reassembly was trying to find a good way to route the cables so that the Lapdock could be reassembled nicely. I held the Raspberry Pi Zero down with some double-sided foam mounting tape once I had everything in position. This tape also insulates Pi from the metallic coating on the inside of the Lapdock's case, so don't skimp on it.
Once everything was buttoned back up, I plugged the dock connector into the pigtails again and powered the dock up.
The end result is a nice, self-contained computer powered by the Raspberry Pi Zero, but the dock is still usable for other devices.
Update: 2015-01-24
Frequently, you have to use the reset button on the bottom of the lapdock to get it to boot proplerly, and I wanted to be able to reset the dock with my pinkie finger. Also, I wanted a way to easily swap out MicroSD cards. To fix these two issues, I used a stepped drill bit to enlarge the reset pinhole and to give me access to the Pi Zero's card slot.
Labels: archlinux, linux, pizero, raspberrypi
2015-12-12
PiTether: Mobile phone to ethernet bridge
Introduction
If you saw me at DefCon this year, you probably saw me using my HP Jornada. There was also a pretty good chance that you saw me getting it online in strange ways...HACK THE PLANET! (Or just dial up a BBS...) |
Yes, that's a Raspberry Pi Model B inside a case made of LEGO bricks. |
Setting up Arch Linux
Being no stranger to building embedded systems, I decided to go with a bare-bones Arch Linux ARM install on a 2GB SD card. You could likely run with an even smaller card if you wanted to. The installation instructions are pretty straight-forward if you're familiar with the command line.Once you have Arch Linux up and running on the Pi, I recommend changing the default passwords (alarm/alarm, root/root) and then doing a system update to get the latest packages from base. Simply connect the Pi to the Internet through its ethernet port, then run "pacman -Syyu" as root.
Configuring the network
The 3 interfaces we worry about are eth0, usb0 and br0. The first two basically work right out of the box:/etc/systemd/network/eth0.network exists from the default installation, so the ethernet port is already set up for us.
When you activate USB Tethering from Android while plugged in to most modern Linux distros, it shows up as a network device (in this case, usb0) without any extra configuration.
br0 (the bridge interface) needs to be configured. First, we establish a netctl profile for it. Put the following text into a file called /etc/netctl/br0
Description="PiTether USB/Ethernet connection"Next, create a service file for systemd that calls netctl for the br0 interface. Put these contents in /etc/systemd/system/netctl@br0.service
Interface=br0
Connection=bridge
BindsToInterfaces=(eth0 usb0)
IP=dhcp
SkipForwardingDelay=yes
.include /usr/lib/systemd/system/netctl@.serviceRun the following command as root to enable the interface during start-up:
[Unit]
Description=PiTether USB/Ethernet connection
BindsTo=sys-subsystem-net-devices-eth0.device
BindsTo=sys-subsystem-net-devices-usb0.device
After=sys-subsystem-net-devices-eth0.device
After=sys-subsystem-net-devices-usb0.device
netctl enable br0
Reboot the Pi to make sure everything works as planned. To test:
- Plug in your phone and activate USB Tethering.
- Plug a device into the ethernet port of the Raspberry Pi
- Request a DHCP Lease (happens automatically on most devices)
- Try to browse the web or connect to something over the Internet (ping, ssh, etc)
You can probably do this by sliding the write-protect tab on the SD card (for Pi A and B only) however, I opted to mark both filesystems "ro" in /etc/fstab. Apparently, root (/) is optional in fstab, but I added it by copying the /boot line and slightly altering the device and mountpoint fields. My /etc/fstab looks like this:
#You can give it one more reboot and test after that if you want. If you ever want to change anything in the filesystem, you can temporarily remount it read-write again by using the command "mount -o remount,rw /" while logged in as root. You can use that to remove ",ro" from the fstab options or to occasionally update packages.
# /etc/fstab: static file system information
#
# file system dir type options dump pass
/dev/mmcblk0p0 / ext4 defaults,ro 0 0
/dev/mmcblk0p1 /boot vfat defaults,ro 0 0
Labels: archlinux, ethernet, linux, mobile, networking, raspberrypi
2015-12-06
Raspberry Pi Zero in a USB Hub (Part 1)
I've had this USB Hub kicking around for a while. I like it because it came with a good power supply and it can handle things like 1-Watt USB Wi-Fi adapters, RTL-SDR receivers and USB-powered hard drives with ease. It's small enough to stash in my backpack.
As powered hubs go, this one isn't anything spectacular.You can probably do something similar if you find the right hub.
This hub's case popped open easily with just a spudger and some fingernails. I took the circuit board out and found a spot to get 5VDC near the power input port. I soldered some wire to a pad, and another wire to ground. I attached these to the +5V and ground rails through the Raspberry Pi Zero's GPIO header (Pins 4 and 6 respectively)
Next, I cut some notches in the plastic case for HDMI and the USB OTG cable. I'd like to eventually wire the USB directly to the hub's board, but that'll be for part 2. For now, I need a hole in the case for USB. Everything lines up nicely.
I used electrical tape to insulate the bottom of the Pi, and the top of the USB ports inside.
Some 3M double-sided mounting tape holds everything in place. Sorry for the blurry shot. I didn't review some of these photos until everything was stuck back together.
Since I haven't gotten USB hooked up inside the case (I'll need some fine wire, a really good SMD soldering iron and a steady hand to attempt that), I still have to hook the Pi's USB OTG port on the front to the USB port on the back of the hub.
Not terribly elegant, but it works.
That's pretty much all there is to it. Plug in the Mini-HDMI cable and the power supply and watch it go. You've got a computer that's better than anything I had in the early 2000s in something roughly the size of a pack of gum, and you'll have a decent number of USB ports to work with, too!
Labels: Electronics, hacks, linux, raspberrypi, unix
2015-10-17
"USB Killer" Hype
This week, there was lots of fuss about the latest generation of "USB Killer" hype. I won't link to any articles. The device looks like a USB flash drive but overvolts and reportedly bricks computers. It was announced back in March. The "2.0" version was announced recently, and the hype is back.
Here's my take:
Since the chances of running into one of these in the wild are virtually nil, I think the real lessons here are not to leave your computer unattended, and not to let strangers plug things into your computer. These are more useful security measures than refusal to plug in a stray USB stick. These actions also defend against more attacks (e.g. evil maid, Thunderstrike, data extraction and others, not to mention outright theft of the computer.)
There are only a few extant devices in a "thumb drive" form-factor that are engineered to fry the logic board of whatever you plug it into. The people who have these devices (those who made them) probably won't leave them laying around. I know I wouldn't. They're expensive to build and re-usable. If I were up to no good, I'd want to be the one to plug it into something. Then, I'd take it out and move to the next target.
Until this class of device sees commercial availability, we all have much more nefarious things to be concerned about. In that case, prying the case off of a suspicious USB device might not be a bad idea. You wouldn't see a bank of large surface-mount capacitors taking up most of the space in a real flash drive.
2015-06-14
OpenBSD PHP/MySQL Walk-throughs are up to date (Finally!)
First and foremost, I finally took the time to wrap my brain around OpenBSD's new relayd-based httpd. You can see the walk-through here:
While I was at it, I refreshed the guides for nginx and apache.
These should be maintained for future versions of OpenBSD going forward. Enjoy!
2015-04-01
Raspberry Pi random host generator
Say you have a really watchful network/systems administrator that keeps a close eye on new devices being joined to the network...
You know where this is going. It's April 1st.
Toss this into /home/pi, then make it executable.
#!/bin/sh
while true
do
mac=`echo -n 00:03:BA; dd bs=1 count=3 if=/dev/urandom 2>/dev/null | hexdump -v -e '/1 ":%02X"'`
newhost=`dd if=/dev/urandom bs=35 count=1 2>/dev/null | tr -dc "a-z"`
echo $mac $newhost
ifconfig eth0 down
pkill dhclient
hostname $newhost
ifconfig eth0 hw ether $mac
rm /etc/ssh/ssh_host_rsa_key /etc/ssh/ssh_host_dsa_key
ssh-keygen -f /etc/ssh/ssh_host_rsa_key -N '' -t rsa -P ''
ssh-keygen -f /etc/ssh/ssh_host_dsa_key -N '' -t dsa -P ''
ifconfig eth0 up
dhclient eth0
ip addr show eth0 | grep "inet "
echo "Sleeping..."
sleep 60
done
You can add the below line before "exit 0" line at the end of /etc/rc.local on Raspbian to make it start up at boot. You have a random host generator that spawns a new MAC Address, random host name and new SSH keys every minute or so.
nohup /home/pi/mac.sh >> /tmp/mac.out&
A few notes:
- This will totally hose all of your SSH host keys on the pi. Make backups of them if they're important to you.
- I chose an OUI (00:30:BA) that I knew would not match anything else on the target network. You may wish to do some research and change the hard-coded OUI prefix in the code above.
- The interface fluxing will also make remote management troublesome unless you have a wireless adapter that's on a more stable network, but this can betray you, as the host keys keep changing to match the wired interfaces.
- I took the additional step of leaving the Pi powered on for a few minutes before attaching the ethernet cable, so that it wouldn't ever show up on the network with a Raspberry Pi MAC address, since it had time to generate a new fake address before I hooked it in.
- There are some very simple ways to defend against something like this.
- It goes without saying, but pranks at work can lead to disciplinary action.
Labels: pranks, raspberrypi, shell, unix