In the last post, we setup an Ubuntu 18.04 system for hardware hacking, and used the built-in package manager to install some software we will use.
There are several tools that are better to be installed from source, for a few reasons:
- They will be as up-to-date as possible
- You can modify them and rebuild them if need be.
Organisation
I tend to keep all of my tools in a subdirectory called “tools”. Not everything is installed into the path, and this helps keep everything neat.
Binwalk
Binwalk is a tool used to examine embedded filesystems and extract them for analysis. The one installed using the package manager in Ubuntu and Kali is out-of-date and missing dependencies that are essential. Crucially, it will not unpack JFFS2 filesystems, which are incredibly common.
Installation is easy:
sudo apt install python git clone https://github.com/ReFirmLabs/binwalk cd binwalk sudo ./deps.sh
The deps.sh script will install the packages required, downloads some repositories, build and install them. This is around 350MByte of downloads, so be prepared to wait a bit.
Answer “Yes” to Ubuntu 18 being detected.
Finally run:
sudo python3 setup.py install
Binwalk should now be installed in the path.
Flashrom
Flashrom is a tool used to interact with SPI flash chips. You can use many USB adapters like the CH431A and FT2232H, or a single-board computer (SBC) like the Raspberry Pi or Beaglebone Black.
Note that if you are going to use an ARM-based SBC, you should compile the tool on the device rather than try and cross-compile in on your Intel machine.
I often find that I need to tweak how Flashrom interacts with chips, especially with the proliferation of cloned devices that misreport JEDEC IDs.
Installation is easy:
sudo apt install build-essential libpci-dev libusb-dev libusb-1.0-0-dev libftdi-dev linux-headers-generic git clone https://github.com/flashrom/flashrom cd flashrom make sudo make install
That should be it!
OpenOCD
OpenOCD is used to interact with devices using JTAG and SWD. Packaged versions tend to be old and not support all the tools.
sudo apt install libusb-1.0-0-dev libhidapi-dev libhidapi-libusb0 libftdi-dev libtool automake pkg-config git clone --recursive https://github.com/ntfreak/openocd cd openocd ./bootstrap ./configure make sudo make install
ST-Link
Although we can do nearly everything we need to with STM32 processors using OpenOCD, some scripts and tutorials use ST-Link instead.
sudo apt install make cmake libusb-1.0-0-dev gcc build-essential git clone https://github.com/stlink-org/stlink cd stlink cmake . make sudo make install sudo ldconfig
That last step is just to reload the shared libraries, as the make install does not do it.