You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/hardware-physical-access/firmware-analysis/README.md
+38-6Lines changed: 38 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -56,6 +56,19 @@ Obtaining firmware can be approached through various means, each with its own le
56
56
-**Dumping** from the bootloader or network
57
57
-**Removing and reading** the storage chip, when all else fails, using appropriate hardware tools
58
58
59
+
### UART-only logs: force a root shell via U-Boot env in flash
60
+
61
+
If UART RX is ignored (logs only), you can still force an init shell by **editing the U-Boot environment blob** offline:
62
+
63
+
1. Dump SPI flash with a SOIC-8 clip + programmer (3.3V):
64
+
```bash
65
+
flashrom -p ch341a_spi -r flash.bin
66
+
```
67
+
2. Locate the U-Boot env partition, edit `bootargs` to include `init=/bin/sh`, and **recompute the U-Boot env CRC32** for the blob.
68
+
3. Reflash only the env partition and reboot; a shell should appear on UART.
69
+
70
+
This is useful on embedded devices where the bootloader shell is disabled but the env partition is writable via external flash access.
71
+
59
72
## Analyzing the firmware
60
73
61
74
Now that you **have the firmware**, you need to extract information about it to know how to treat it. Different tools you can use for that:
@@ -311,10 +324,30 @@ At this stage, either a real or emulated device environment is used for analysis
311
324
312
325
Runtime analysis involves interacting with a process or binary in its operating environment, using tools like gdb-multiarch, Frida, and Ghidra for setting breakpoints and identifying vulnerabilities through fuzzing and other techniques.
313
326
327
+
For embedded targets without a full debugger, **copy a statically-linked `gdbserver`** to the device and attach remotely:
328
+
329
+
```bash
330
+
# On device
331
+
gdbserver :1234 /usr/bin/targetd
332
+
```
333
+
334
+
```bash
335
+
# On host
336
+
gdb-multiarch /path/to/targetd
337
+
target remote <device-ip>:1234
338
+
```
339
+
314
340
## Binary Exploitation and Proof-of-Concept
315
341
316
342
Developing a PoC for identified vulnerabilities requires a deep understanding of the target architecture and programming in lower-level languages. Binary runtime protections in embedded systems are rare, but when present, techniques like Return Oriented Programming (ROP) may be necessary.
-**Fastbins + consolidation:** uClibc uses fastbins similar to glibc. A later large allocation can trigger `__malloc_consolidate()`, so any fake chunk must survive checks (sane size, `fd = 0`, and surrounding chunks seen as "in use").
347
+
-**Non-PIE binaries under ASLR:** if ASLR is enabled but the main binary is **non-PIE**, in-binary `.data/.bss` addresses are stable. You can target a region that already resembles a valid heap chunk header to land a fastbin allocation on a **function pointer table**.
348
+
-**Parser-stopping NUL:** when JSON is parsed, a `\x00` in the payload can stop parsing while keeping trailing attacker-controlled bytes for a stack pivot/ROP chain.
349
+
-**Shellcode via `/proc/self/mem`:** a ROP chain that calls `open("/proc/self/mem")`, `lseek()`, and `write()` can plant executable shellcode in a known mapping and jump to it.
350
+
318
351
## Prepared Operating Systems for Firmware Analysis
319
352
320
353
Operating systems like [AttifyOS](https://github.com/adi0x90/attifyos) and [EmbedOS](https://github.com/scriptingxss/EmbedOS) provide pre-configured environments for firmware security testing, equipped with necessary tools.
@@ -388,17 +421,16 @@ To practice discovering vulnerabilities in firmware, use the following vulnerabl
-[Practical IoT Hacking: The Definitive Guide to Attacking the Internet of Things](https://www.amazon.co.uk/Practical-IoT-Hacking-F-Chantzis/dp/1718500904)
395
432
-[Exploiting zero days in abandoned hardware – Trail of Bits blog](https://blog.trailofbits.com/2025/07/25/exploiting-zero-days-in-abandoned-hardware/)
396
-
397
-
398
433
-[How a $20 Smart Device Gave Me Access to Your Home](https://bishopfox.com/blog/how-a-20-smart-device-gave-me-access-to-your-home)
0 commit comments