hwntools¶
pwntools for hardware. UART, U-Boot, JTAG, SPI flash and firmware triage, scripted from one Python file.
Every hardware assessment starts the same way: find the UART, stop U-Boot, dump the flash by
hand, unpack it, grep for passwords. hwntools turns that first day into a script, with the
same recvuntil / sendline feel as pwntools, for
IoT, embedded Linux and edge-AI devices.
Three lines¶
Stop U-Boot and dump the SPI flash over the serial console:
from hwntools import *
ub = UBoot(serial("/dev/ttyUSB0", 115200)); ub.interrupt() # now power-cycle the target
ub.run("sf probe; sf read 0x82000000 0x0 0x1000000") # flash -> RAM
ub.dump(0x82000000, 0x1000000, out="flash.bin") # RAM -> file, resumable md.b dump
No board on your desk yet? The Learn track walks you through a whole assessment of a simulated router, and the same calls run against the built-in simulator, in-process and without any extra packages:
from hwntools import UBoot
from hwntools.sim import FakeUBoot, SimTube
ub = UBoot(SimTube(FakeUBoot(memory=bytes(range(256)) * 16)))
ub.interrupt()
print(ub.printenv()["bootcmd"], ub.dump(0x80000000, 0x1000)[:16].hex())
Install¶
pip install hwntools # core: zero third-party dependencies
pip install "hwntools[serial]" # + pyserial for real serial ports
Python 3.10 or newer. See Installation for the optional external programs.
What it covers¶
-
Serial consoles
pwntools-style tubes over serial, TCP (ser2net) and processes. Auto-detect the baud rate.
-
U-Boot
Stop autoboot, read and audit the environment, resumable
md.bflash dumps, one-shotinit=/bin/sh. -
Linux shells
Classify the prompt, log in, run commands with exit codes, pull files out and push tools in, all over UART.
-
JTAG / SWD and SPI flash
OpenOCD TCL RPC (halt, registers, memory, flash banks) and flashrom with double-read verification.
-
Firmware triage
hwn fw analyze: unpack with unblob / binwalk / a safe built-in extractor, then find credentials, open shells and weak boot settings. -
Simulator
A fake U-Boot and Linux shell, in-process or on a real pseudo-terminal, so you can write the script before the board arrives.
Authorized use only
hwntools is meant for testing devices you own or are explicitly permitted to assess. Flash writes and environment changes can permanently damage hardware. Read Safety and legal before connecting anything.
Project status¶
hwntools is alpha software (version 0.2). uart, openocd, spiflash and tools are
experimental: they are tested against simulated devices and recorded tool output, not yet
against real hardware, and their APIs may change in minor releases. See the
changelog.
hwntools is built and maintained by Reflex Hardware Security, a hardware security assessment company for robots, drones, edge AI and IoT devices.