I have a lot of little ideas of what to do with the Raspberry Pi, but many of
them would make for very short articles amounting to a few pics and some lines
of code. This page will be a place for me to collect these small notes into
“Raspberry Pi Recipes” and to link to any larger Raspberry Pi articles I do.

This recipe will show you how to get a basic install of Metasploit on the
Raspberry Pi. If you want more, skip to the bottom of this recipe. I’m using the
Debian “wheezy” public beta (2012-06-18-wheezy-beta
http://www.raspberrypi.org/archives/1435)
but other distros may work as well. First we need to get root privileges,
download the framework, ruby, subversion and libpcap. Depending on the modules
you use you may need more. Then we can run msfconsole, though it will take
awhile to load and if you are running another memory intensive app on your
Raspberry Pi you may receive errors:

You guys know I love hardware keyloggers (which reminds me, at $35 for the
Raspberry Pi and $16 for a Teensy I should work on a network enabled hardware
keylogger), but why not an ethernet logger? The idea is simple, use the built-in
Ethernet of the Raspberry Pi, add another USB Ethernet adapter, set up bridging
and log everything with TCPDump! Or for that matter, you can use TCPDump’s
capture filters to just grab what you want and pass on the rest (someone
mentioned to me that making a Wall of Sheep/Wall of Social Science Majors would
be a cool idea). I’d highly recommend finding a case to put your Raspberry Pi in
for this project, this laying naked on the floor on in a wiring closet will
stand out. Also, it will likely drop throughput quite a bit, especially if you
are trying to work at gigabit speeds (We are talking a USB 2 Ethenet dongle
after all). My script needs more testing, if the Raspberry Pi fails, the
victim’s connection will go down.

First up, we need to install bridge-utils so we can set up a man in the middle
Ethernet bridge, then use an editor to write a script to set up bridging and
logging:

Below is the startbridgeandlog.sh script I am using. The core thing you need to
change is the IP you will be remoting in on to get the pcap files, but if you
just plan to come and pick-up the device by hand then you may not need to change
anything (I’d try setting it to 0.0.0.0 then). You will also want to look at the
MAN page for TCPDump to understand the options I’m using. With the options I
have set below, it will write the packets to mycap.pcap0 till it reaches 1
billion bytes (base 10, so not really 1GB) then moves on to the files
mycap.pcap1, and then mycap.pcap2. When mycap.pcap2 is 1 billion bytes, it moves
back and overwrites mycap.pcap0. Adjust your setting according to how much data
you want to log and how big your SD card is.

This is the hello world of
electronics. All it consists of is an LED and some jumper wires. I recommend
getting a bunch of male and female jumpers. The circuit is simple, though I should
probably have added a current limiting resistor.

The code is also simple, you could just type this all into a command line
after SSHing into your Raspberry Pi, or you could make a script. All this does
is turn the LED on and off at 1 second intervals.

The blinky example is ok, but the GPIO
pins on the Raspberry Pi work at 3.3 volts, what if we want to interface with
something that is working at 5v? For example, lets say you want to hook it up to
an Arduino or a Teensy. The simplest solution might be to buy some logic level
converters:

All it does is watch to see if the line goes to 5v. If it
does, it print "high" using the Teensy's option to act as a USB HID
keyboard. I turn the Raspberry Pi's GPIO 4 on and off by setting it for
output using:

Here is a video
of the results (with some really crappy camera phone work):

UART/Serial Output from the Raspberry Pi

We can also use the logic level
converters to work with UART/Serial and interface with a Teensy or Arduino. Here
is a simple diagram/schematic of the hook up. Keep in mind that TX from the Teensy goes to
the RX on the Raspberry Pi and vice versa.

The code is also simple, I based it on some Paul had up on the
Teensy website. All
it does is print whatever comes in over the UART interface (notice I'm using
115200 bps as the connection speed).

// This line defines a "Uart" object to access
the serial port HardwareSerialUart=HardwareSerial();

Now I can cat or echo things out to /dev/ttyAMA0, and the
Teensy should print them out as seen in this video (again, crappy camera
work):

These are just
simple examples of using a Raspberry Pi to output to an Arduino or Teensy.
The Raspberry Pi is cheaper than many Ethernet Shields for the Arduino, and
a lot more powerful/flexible in it's own right. I plan to work later on bidirectional serial
interfacing with the Raspberry Pi.

In this section I'll cover setting up a Raspberry Pi to send you a
Reverse Shell using SSH (AKA: Shovel a shell). This is pretty good for
blowing past NAT and some firewalls with weak egress filtering. The idea is
that you can use these as drop boxes to leave behind on someone else's network,
then have them remote back out to you. These instructions should work pretty
much the same on any *nix device or distro that uses OpenSSH. Make
sure you have OpenSSH installed, but most distros I've seen do.

These are
the non-automated commands to do a reverse SSH connection and set up a
Proxy/Pivot using OpenSSH: On Raspberry Pi use the following command :