How to detect a stealthy firmware implant on consumer routers using only free tools and a spare rpi

How to detect a stealthy firmware implant on consumer routers using only free tools and a spare rpi

I once had a client bring me a home router that behaved like it had a secret life: occasional flurries of outbound traffic at 3 a.m., DNS responses that sometimes led to odd domains, and a slightly sluggish web UI. The vendor image looked normal and the firmware version matched what the vendor published. That’s the kind of situation where you start suspecting a stealthy firmware implant — code that survives reboots, hides from casual inspection, and uses legitimate-looking channels to exfiltrate data or provide a backdoor.

If you’ve got a spare Raspberry Pi and a handful of free, well-tested tools, you can uncover many of these implants without buying expensive hardware. Below I walk through an approach I’ve used in my lab: a mix of network forensics, offline firmware analysis, and hardware-level access via serial. I’ll show practical commands, what to look for, and how to decide whether an anomaly is malicious or just the router doing its job.

Threat model and preparations

Before we dig in, be explicit about what we’re looking for. A stealthy firmware implant usually:

  • Persists across reboots and firmware updates
  • Hides processes or network sockets from the usual system tools
  • Uses legitimate protocols (HTTPS, DNS, ICMP) to blend in
  • May include a kernel component, modified init scripts, or a hidden boot partition
  • For this guide you need:

  • A spare Raspberry Pi (3 or newer) with Raspbian/Ubuntu and at least 8 GB SD card
  • An Ethernet cable and a switch or an extra USB-to-Ethernet adapter for the Pi
  • Free tools: tcpdump/tshark, nmap, binwalk, strings, dd, sha256sum, socat, screen/minicom, and optionally firmware-mod-kit
  • A PC for analysis and the internet to fetch vendor firmware
  • Step 1 — Put the router on a monitored network tap using the RPi

    The easiest low-risk way to monitor traffic is to place the RPi as a transparent bridge between the WAN and the router, or between the router and your LAN. That gives you canonical packet captures without modifying the router.

  • Install bridge-utils and tcpdump on the Pi:
  • sudo apt update && sudo apt install bridge-utils tcpdump tshark -y
  • Create a bridge (example assumes eth0 connected to router, eth1 to modem):

  • sudo ip link set eth0 up
  • sudo ip link set eth1 up
  • sudo brctl addbr br0
  • sudo brctl addif br0 eth0 eth1
  • sudo ip link set br0 up
  • Start capturing full packets to disk while you observe the router for a few hours (or over a period of suspicious activity):

  • sudo tcpdump -i br0 -w router_capture.pcap
  • What to look for in the capture (open with Wireshark or tshark):

  • Unexpected DNS queries to strange domains or high volume of TXT/ANY queries
  • Outbound HTTPS to rarely-seen hosts; check SNI for suspicious names
  • Large periodic uploads (exfiltration) or beaconing intervals
  • Traffic over unusual ports (high-number TCP/UDP), DNS-over-HTTPS, or tunneled traffic
  • Step 2 — Active network probing (nmap & co.)

    With the router isolated on your test network, scan it to enumerate open services and odd ports. Implants sometimes open hidden management ports.

  • sudo nmap -A -p- 192.168.1.1
  • Key checks:

  • Unexpected open TCP/UDP ports
  • Services that claim to be one thing (e.g., httpd) but have strange banners
  • SSH on a non-standard port or multiple SSH daemons
  • Also scan local devices behind the router — implants can proxy traffic or expose internal hosts.

    Step 3 — Try the management interfaces and look for inconsistencies

    Login to the router UI and check:

  • Installed packages list (for OpenWrt/LEDE look at System > Software)
  • Startup scripts: /etc/init.d, /etc/rc.local
  • Crontab entries
  • Firewall rules (iptables -L; iptables-save)
  • If the web UI looks normal but you can SSH in, run:

  • ps aux | grep -v 'ps aux' | less
  • ss -tulpen
  • cat /proc/modules; lsmod
  • Be aware: a rootkit may hide processes and sockets. That’s why we combine this with offline firmware analysis.

    Step 4 — Dump the firmware image (vendor image or router dump)

    There are two routes: download the vendor’s official firmware image from their site, or extract a dump from the device itself. Start with the vendor image to compare later.

  • Download vendor firmware file and run:
  • binwalk -e vendor_firmware.bin
  • Binwalk will extract squashfs or other filesystems. Examine the extracted rootfs with strings, grep, and file checksums:

  • find _vendor_firmware.extracted -type f -exec sha256sum {} \; > vendor_checksums.txt
  • If you can’t get a vendor image (or want the exact running image), you can dump the flash. Some routers allow firmware readback via /dev/mtdblock or via a "backup" function. If not, use serial/JTAG (next step).

    Step 5 — Use serial console (TTL) to inspect boot and persistent storage

    This is the point where the RPi is invaluable as a USB-to-serial adapter. Many consumer routers expose a 3.3V TTL serial header. With the router powered off:

  • Connect router TX -> Pi RX (GPIO 15), router RX -> Pi TX (GPIO 14), and common GND
  • On Pi run: sudo apt install minicom screen
  • sudo screen /dev/serial0 115200
  • Watch the entire boot log. Look for:

  • Unexpected scripts executed during init
  • Mounts of hidden partitions
  • Loader modifications (U-Boot environment changes)
  • If the bootloader or kernel has been modified, you’ll often see custom command lines or additional init scripts referencing odd paths.

    Step 6 — Offline analysis: compare running image to vendor

    Once you have a firmware extract from the live device and the vendor image extracted, do a recursive diff and checksum comparison:

  • cd live_extracted && find . -type f -exec sha256sum {} \; | sort > live_checksums.txt
  • diff -u vendor_checksums.txt live_checksums.txt
  • Pay attention to:

  • Files present in live image that aren’t in vendor image (backdoors, custom binaries)
  • Modified system binaries (busybox, libc) — run strings and look for suspicious embedded domains or IP addresses
  • New init scripts, suspicious cron jobs, unusual SUID files
  • Example: find suspicious files by name or inode flags

  • grep -R "http\|exec\|openssl\|base64" live_extracted
  • Step 7 — Kernel modules and hidden code

    Some implants install kernel modules to hide processes or network sockets. In the boot log and /proc/modules you may see unexpected modules. Offline, check for .ko files in the firmware and calculate their build timestamps; a module that doesn’t match the vendor’s kernel likely indicates tampering.

  • find live_extracted -name "*.ko" -exec strings {} \; | grep -i suspicious_domain
  • Step 8 — Monitor for stealthy behavior over time

    Capture DNS, HTTP(S) metadata and TLS handshakes. Tools like tshark can export SNI and certificate fingerprints even if traffic is encrypted:

  • tshark -r router_capture.pcap -Y "tls.handshake.type==1" -T fields -e tls.handshake.extensions_server_name -e x509sat.*
  • Look for recurring patterns: same remote host, evenly spaced beacons, DNS lookups followed by short TCP connections — classic C2 behavior.

    Quick reference tool table

    TaskToolWhy
    Packet capturetcpdump/tsharkFull network visibility; extract SNI and certificate metadata
    Port/service discoverynmapFind hidden listening services and unusual ports
    Firmware extractionbinwalkUnpack squashfs/jffs2 and expose files
    Serial consolescreen/minicom via RPi GPIOObserve boot, access shell when OS is tampered
    File inspectionstrings, sha256sum, diffFind embedded domains, compare vendor vs live

    One last practical tip: keep everything reproducible. Save the pcap, extracted firmware, and checksums. If you find convincing evidence of a firmware implant, preserve evidence and avoid making ad hoc changes that could destroy indicators. Also, reach out to your vendor with the evidence — sometimes false positives happen due to vendor telemetry or third-party packages.


    You should also check the following news:

    Cybersecurity

    Which budget android phones still get security updates and how to lock one down for private messaging

    12/04/2026

    I get asked all the time: “Can I keep a cheap Android phone and still get security updates?” and “How do I turn that phone into something safe...

    Read more...
    Which budget android phones still get security updates and how to lock one down for private messaging