Skip to content

Commit 2eaf9d5

Browse files
authored
Merge pull request #2020 from HackTricks-wiki/update_Now_You_See_mi__Now_You_re_Pwned_20260317_190722
Now You See mi Now You're Pwned
2 parents 72cbf34 + 08ae268 commit 2eaf9d5

1 file changed

Lines changed: 38 additions & 6 deletions

File tree

  • src/hardware-physical-access/firmware-analysis

src/hardware-physical-access/firmware-analysis/README.md

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,19 @@ Obtaining firmware can be approached through various means, each with its own le
5656
- **Dumping** from the bootloader or network
5757
- **Removing and reading** the storage chip, when all else fails, using appropriate hardware tools
5858

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+
5972
## Analyzing the firmware
6073

6174
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
311324

312325
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.
313326

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+
314340
## Binary Exploitation and Proof-of-Concept
315341

316342
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.
317343

344+
### uClibc fastbin exploitation notes (embedded Linux)
345+
346+
- **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+
318351
## Prepared Operating Systems for Firmware Analysis
319352

320353
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
388421
- Damn Vulnerable IoT Device (DVID)
389422
- [https://github.com/Vulcainreo/DVID](https://github.com/Vulcainreo/DVID)
390423

424+
## Trainning and Cert
425+
426+
- [https://www.attify-store.com/products/offensive-iot-exploitation](https://www.attify-store.com/products/offensive-iot-exploitation)
427+
391428
## References
392429

393430
- [https://scriptingxss.gitbook.io/firmware-security-testing-methodology/](https://scriptingxss.gitbook.io/firmware-security-testing-methodology/)
394431
- [Practical IoT Hacking: The Definitive Guide to Attacking the Internet of Things](https://www.amazon.co.uk/Practical-IoT-Hacking-F-Chantzis/dp/1718500904)
395432
- [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-
398433
- [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)
399-
400-
## Trainning and Cert
401-
402-
- [https://www.attify-store.com/products/offensive-iot-exploitation](https://www.attify-store.com/products/offensive-iot-exploitation)
434+
- [Now You See mi: Now You're Pwned](https://labs.taszk.io/articles/post/nowyouseemi/)
403435

404436
{{#include ../../banners/hacktricks-training.md}}

0 commit comments

Comments
 (0)