Saturday, March 29, 2014

#3: Kali Linux on the Beaglebone Black

Ethernet and USB Problems

I tried Fedora on the BBB, but it is slightly behind the curve (strange for Fedora, which is usually bleeding edge), the ethernet and USB ports do not work yet since it needs a newer kernel.  The Debian distributions are better on the BBB.

So, one can blow against the wind, or try Debian...

Penetration Tests

I am working on a networked project which is an island system - it is not connected to anything else at the moment.  I say at the moment - since I know that sooner or later, the bosses will demand that it be connected to the something else, at which point the lack of attention to security will come to bite everyone.

There is a small security and penetration test oriented Debian based distribution called Kali Linux that you can get here http://docs.kali.org/armel-armhf/install-kali-arm-on-a-beaglebone-black

Kali installs on a SD card, so your original Angstrom Linux on the BBB will remain unaltered, which makes it worth a try.

An interesting feature of Kali, is the website, which was nicely translated into 13 languages.

With this version, you should be able to do various nefarious things to your fellow developers using the Metasploit package...

Get it and Prepare an SD Card

You can download the ARM HF image here http://www.kali.org/downloads/

Specifically:

Uncompress it with xzcat:
(For a Mac, get the xz utilities here: http://macpkg.sourceforge.net/)


xzcat kali-linux-1.0.6-armhf.img.xz > kali-linux-1.0.6-armhf.img


and copy it to the SD card with Data Definition like this: 
$ su -
password
# dd if=kali-linux-1.0.6-armhf.img of=/dev/sdb bs=512k

Using Data Definition on a Mac

Stop the automounter called diskarbitrationd temporarily, otherwise the SD card will be mounted and 'busy': 
$ sudo launchctl list | grep diskarbitrationd
16 - com.apple.diskarbitrationd 

$ sudo kill -SIGSTOP 16

Only now, stick the SD card into the Mac SD slot.

Open a terminal and type
$ ls /dev/disk*
/dev/disk0    /dev/disk0s2    /dev/disk1
/dev/disk0s1    /dev/disk0s3    /dev/disk1s1
 

The disk0 is your SSD and you don't want to mess with that!
The disk1 is the SD card.

Now, with the SD card unmounted, you can use dd to copy the BBB image to disk1:
$ sudo dd if=kali-linux-1.0.6-armhf.img of=/dev/disk1 bs=512k

On a Mac, Ctrl-T will show the dd progress.

Note that if you accidentally dd to /dev/disk0, then you will destroy your Mac system.
So, don't do that!

Finally, re-enable the automounter:
$ sudo kill -SIGCONT 16

Accessing the SD card from a Virtual Machine

I run Fedora 20 on my Macbook Pro and getting Virtualbox to see the SD card is somewhat painful.

First of all make sure that the Fedora virtual machine is NOT running.

Stop the automounter as above to ensure that the SD card is not mounted, then access it using a raw disk image.

Make a raw disk image file for Virtualbox:
$ VBoxManage internalcommands createrawvmdk -filename /path/to/file.vmdk -rawdisk /dev/disk1


Attach the raw disk to a guest VM within the VirtualBox UI:
  1. Ensure the guest VM is not running.
  2. Open the settings area for the guest VM
  3. Click on "Storage" in the toolbar
  4. Next to the controller click on the icon to "Add Hard Disk"
  5. Select "Choose existing disk"
  6. Navigate to the /path/to/file.vmdk you used in step 3 and select it
  7. You should now be returned to the Storage tab and see your file.vmdk in the list.
  8. Start the VM
  9. The SD card will then be available as /dev/sdb 
Now you can use the Fedora VM to access the SD card normally and finally, when done, you can re-enable the automounter using kill -SIGCONT.

Boot Kali

Unplug the USB power cable, install the serial cable (Black wire at the little dot), plug in both USBs and run screen:
$ screen /dev/ttyUSB0 115200
or on a Mac:
$ ls /dev/tty.usb*
/dev/tty.usbserial-AH0142BF
$ screen /dev/tty.usbserial-AH0142BF 115200
Now plug in the USB power cable again and watch her boot.
There is also a little reset button on the corner at the 4 LEDs.

Bugs

Finally, I managed to boot the SD card and got this:
Hit any key to stop autoboot:  0
gpio: pin 53 (gpio 53) value is 1
mmc0 is current device
micro SD card found
mmc0 is current device
gpio: pin 54 (gpio 54) value is 1
SD/MMC found on device 0
** File not found uEnv.txt **
gpio: pin 55 (gpio 55) value is 1
** Invalid partition 2 **
U-Boot#


Hmm... now I'm wondering whether the mods on the Fedora BBB page are required here too:
$ cd /media
$ cp __/usr/share/uboot-beaglebone/* uboot/ 
$ cp uboot/uEnv.txt.beaglebone uboot/uEnv.txt
$ nano uboot/uEnv.txt 
abcboard=am335x-bone > abcboard=am335x-boneblack 
Some more sleuthing is required to sort this out.

Soooo, remove the USB power cable, remove the SD card and stick it into the Mac.
Aaaargh! Stupid automounter and stupid Mac that doesn't support the file system...

Boot a Linux machine and stick it in again.

An error occurred while accessing DEBIAN_LIVE...

Bah, humbug!  No wonder it won't boot either.

It really looks like it is time to find another distro again, or to build the darn thing myself.

Build It Yourself

If you are more adventurous, the Kali build scripts are on github here https://github.com/offensive-security/kali-arm-build-scripts

Get bbb.sh and README.md for the details.

I think I'll rather install QEMU and build my own version of Fedora ARM, since that is the distribution I like the most.   More on this later.

Eish...

No comments:

Post a Comment

On topic comments are welcome. Junk will be deleted.