hwntools¶
hwntools: pwntools for hardware.
A scripting toolkit for authorized hardware security assessments: UART consoles, U-Boot, Linux shells over serial, OpenOCD/JTAG, SPI flash via flashrom, and firmware triage.
from hwntools import * brings the common names into scope, like from pwn import *:
from hwntools import *
io = serial("/dev/ttyUSB0", 115200)
ub = UBoot(io)
ub.interrupt()
ub.dump(0x82000000, 0x100000, out="kernel.bin")
The core has no third-party dependencies; serial support needs hwntools[serial].
Exported names¶
from hwntools import * imports:
| Name | Kind | Documented in |
|---|---|---|
serial, serialtube, remote, process, Tube |
tubes | Tubes |
UBoot |
class | U-Boot |
LinuxShell |
class | Linux shell |
autobaud |
function | UART |
OpenOCD |
class | OpenOCD |
Flashrom |
class | SPI flash |
context, log |
objects | Context and logging |
HwnError, HwnTimeoutError, ParseError, SafetyError, ToolNotFoundError |
exceptions | Exceptions |
p8 … p64, u8 … u64, pack, unpack, flat, hexdump, xor, cyclic, cyclic_find, crc32, crc32c, crc16*, crc8, crc_generic, enhex, unhex, b64e, b64d, chunks, printable_ratio |
functions | Utilities |
firmware, linux_shell, openocd, sim, spiflash, uart, uboot, util |
modules | their pages |
__version__ |
str | the installed version |
Note
hwntools.unpack (from the star import) is the struct-style util.unpack, not
firmware.unpack. Use firmware.unpack(...) for firmware images.