How 0x4133/eth0 works
1. System shape
- This is a single firmware repository for an ESP32-S3 + W5500 Ethernet probe rather than a multi-service application.
- The main entrypoint is eth0/eth0.ino, which wires together the runtime modules under eth0/ and runs the command-driven control loop.
2. Hardware / runtime boundary
- The core hardware interfaces are:
- W5500 Ethernet controller over SPI (spi_bus.*, pins.h)
- microSD card for storage and PCAP capture
- NeoPixel LED for status/alert signaling (led.h)
- Serial USB/UART console at 460800 baud
- The project is built in the Arduino ecosystem for ESP32-S3, with Arduino IDE/arduino-cli as the build environment and Ethernet2 plus Adafruit NeoPixel as key libraries.
3. Packet ingress pipeline
- Raw Ethernet frames enter from the W5500 and are parsed by the frame/network utilities (eth_frame.*, ip_util.*, dns_util.*).
- From there, traffic fans out to multiple consumers:
- capture to PCAP
- filtering
- IDS / anomaly detection
- network mapping / discovery
- This “one packet, many observers” model is the central data flow in the firmware.
4. Capture and storage subsystem
- Capture is a first-class path: frames can be written to rotating PCAP files on SD via pcap_writer.*.
- filter.* controls what gets captured or acted on.
- hexdump.* provides inspection of packet contents for the operator.
- This creates a clean separation between live inspection and durable logging.
5. State, statistics, and network model
- state.*, stats.*, network_map.*, and arp_table.h hold the firmware’s shared view of the network.
- These modules act as the internal “model” used by recon, IDS, and attack features.
- nvs_config.* provides persistent configuration across reboots, while runtime counters and observations are accumulated separately in memory.
6. Passive and active recon subsystem
- Recon is split into focused modules for different discovery methods:
- recon_arp_sweep.*
- recon_port_scan.*
- recon_service_scan.*
- recon_os_fingerprint.*
- recon_lldp.*, recon_stp.*, recon_mdns.*, recon_netbios.*, recon_vlan_discover.*
- These modules consume the packet/state layers and update the shared network view rather than directly managing I/O.
7. Packet injection and attack subsystem
- inject.* and packet_replay.* provide the low-level ability to craft and emit Ethernet/IP traffic.
- Higher-level offensive behaviors are isolated into dedicated modules:
- ARP MITM: attack_arp_mitm.*
- DHCP starvation: attack_dhcp_starve.*
- DNS spoofing: attack_dns_spoof.*
- MAC spoofing: attack_mac_spoof.*
- NBNS poisoning: attack_nbns_poison.*
- TCP RST injection: attack_tcp_rst.*
- These attacks depend heavily on packet construction utilities and the current network state.
8. IDS / detection path
- ids.* implements inline detection for suspicious network conditions such as spoofing, rogue DHCP behavior, cleartext credentials, DNS anomalies, and scan behavior.
- Alerts are surfaced through the LED/status layer and can also be exported via svc_syslog.*.
- This is the main defensive counterbalance to the offensive tooling in the same firmware.
9. Built-in services and covert channels
- Several modules expose lightweight protocol endpoints or specialized data paths:
- svc_irc.* — minimal IRC server
- svc_kasa.* — TP-Link Kasa query support
- svc_udp_tunnel.* — AES-128-CBC over UDP tunnel
- svc_dns_covert.* — DNS-based covert channel
- svc_syslog.* — external log forwarding
- These are separate protocol adapters, not part of the capture/recon pipeline, but they reuse the packet and state infrastructure.
10. Command and operator control plane
- The firmware is controlled through a serial command shell and a Web Serial UI (web-ui/index.html).
- The browser UI is static and client-side; it talks directly to the device over the Web Serial API rather than via a backend server.
- Operator commands drive capture toggles, filters, recon jobs, injections, attacks, and service actions.
11. Persistence and configuration
- Device identity/configuration is persisted in NVS through nvs_config.*.
- Runtime observations are maintained separately in state.* and network_map.*, making it clear which data survives reboot and which is ephemeral.
- The SD card is used for artifact persistence, mainly PCAP capture.
12. Tooling and validation boundaries
- tests/ contains host-side unit tests for pure utilities like parsing, checksum, CIDR math, and DNS name decoding.
- CI splits into:
- full firmware build with arduino-cli
- host tests with g++
- This indicates a deliberate separation between hardware-dependent firmware behavior and pure logic that can be validated off-device.
13. Repository organization
- The codebase is intentionally modular: most features live in single-purpose .cpp/.h pairs under eth0/.
- Supporting documentation in docs/ is part of the architecture: ARCHITECTURE.md, PROTOCOLS.md, HARDWARE.md, and FEATURES.md define the external and internal contracts that the firmware modules implement.
14. Diagram takeaway
- A good architecture diagram for this repo should center on the ESP32-S3 firmware core, with inbound links from Ethernet, serial, SD, and Web Serial, and outbound branches to capture/storage, IDS, recon, injection/attacks, and protocol services.
- The dominant boundary is between raw packet I/O on hardware and feature modules that interpret, store, or emit packets.
Main entry points: state.cpp Runtime state · eth_frame.cpp Frame parse · network_map.cpp Network map · eth0.ino Main loop
Components 34
Firmware Core
ESP32-S3 runtime, hardware interfaces, and operator control plane.
- Main loop · Wires subsystems together and runs the command-driven firmware loop.
eth0/eth0.ino - SPI bus · Shared SPI transport to the Ethernet controller and other peripherals.
eth0/spi_bus.cpp - Pins · ESP32-S3 pin assignments and board-specific wiring constants.
eth0/pins.h - LED status · NeoPixel-based alert and activity signaling.
eth0/led.h - Config store · NVS-backed device identity and persistent settings.
eth0/nvs_config.cpp
Packet Pipeline
Frame parsing, filtering, capture, and shared network model.
- Runtime state · Ephemeral firmware state used by recon, IDS, and operator actions.
eth0/state.cpp - Counters · Runtime statistics and measurements accumulated in memory.
eth0/stats.cpp - Network map · Aggregated view of discovered hosts, services, and relationships.
eth0/network_map.cpp - Frame parse · Ethernet frame handling and low-level packet structure utilities.
eth0/eth_frame.cpp - IP utils · IPv4/packet utility helpers used across parsing and feature modules.
eth0/ip_util.cpp - DNS utils · DNS parsing and encoding helpers.
eth0/dns_util.cpp - Filter · Selects which frames are captured, inspected, or acted on.
eth0/filter.cpp - PCAP writer · Writes captured traffic to rotating PCAP files on SD.
eth0/pcap_writer.cpp - Hexdump · Operator-facing packet content display.
eth0/hexdump.cpp - IDS · Inline anomaly and suspicious-traffic detection.
eth0/ids.cpp
Recon
Passive and active discovery modules that update the network view.
- ARP sweep · Discovers live hosts via ARP probing.
eth0/recon_arp_sweep.cpp - Port scan · Checks exposed TCP/UDP ports on discovered hosts.
eth0/recon_port_scan.cpp - Service scan · Identifies services from responses and banners.
eth0/recon_service_scan.cpp - OS fingerprint · Infers host OS characteristics from network behavior.
eth0/recon_os_fingerprint.cpp - LLDP · Passively learns neighbors from LLDP traffic.
eth0/recon_lldp.cpp - STP · Observes spanning-tree traffic for topology clues.
eth0/recon_stp.cpp - mDNS · Discovers devices and services via multicast DNS.
eth0/recon_mdns.cpp - NetBIOS · Finds Windows-oriented hosts and names.
eth0/recon_netbios.cpp - VLAN discover · Identifies VLAN-related network structure.
eth0/recon_vlan_discover.cpp
Attacks
Packet injection and offensive traffic generators.
- Injector · Low-level packet crafting and emission over the wire.
eth0/inject.cpp - Replay · Replays captured or constructed packets.
eth0/packet_replay.cpp - ARP MITM · Man-in-the-middle via ARP spoofing/poisoning.
eth0/attack_arp_mitm.cpp - DHCP starve · Consumes DHCP leases to disrupt addressing.
eth0/attack_dhcp_starve.cpp - DNS spoof · Injects forged DNS replies.
eth0/attack_dns_spoof.cpp - MAC spoof · Changes apparent source identity on the network.
eth0/attack_mac_spoof.cpp - NBNS poison · Poisons NetBIOS name resolution.
eth0/attack_nbns_poison.cpp - TCP RST · Injects reset packets to tear down flows.
eth0/attack_tcp_rst.cpp
Services
Protocol endpoints and covert/forwarding features.
- Syslog · Exports alerts and events to an external syslog target.
eth0/svc_syslog.cpp - IRC server · Minimal IRC protocol endpoint.
eth0/svc_irc.cpp
Connections 48
- Main loop → SPI bus: init hardware · Initializes the shared SPI transport.
- Main loop → Config store: load config · Reads persistent device settings.
- Main loop → Runtime state: seed state · Creates the runtime view used by feature modules.
- Main loop → Counters: start counters · Begins telemetry accumulation.
- Main loop → IDS: run loop · Dispatches inbound traffic and operator commands into detection logic.
- Main loop → Filter: control · Uses operator policy to gate actions.
- Main loop → PCAP writer: capture · Enables SD-backed packet logging.
- Main loop → LED status: status · Surfaces activity and alerts.
- Frame parse → IP utils: decode · Builds higher-level IP packet understanding.
- Frame parse → DNS utils: decode · Interprets DNS payloads when present.
- Filter → PCAP writer: allow/deny · Determines which traffic is persisted.
- Frame parse → Filter: frames · Raw frames are evaluated against capture and action policy.
- Frame parse → IDS: inspect · Packet content feeds inline detection.
- Frame parse → Hexdump: view · Provides packet bytes for operator inspection.
- Frame parse → Network map: learn · Observed hosts and relationships update the topology model.
- IDS → LED status: alert · Highlights suspicious conditions through the status LED.
- IDS → Syslog: export · Can forward alerts to external logging.
- Network map → Runtime state: share view · Feeds the shared runtime model.
- Runtime state → ARP sweep: targeting · Discovery uses the current observed network state.
- Runtime state → Port scan: targeting · Scanning focuses on known hosts and ranges.
- Runtime state → Service scan: targeting · Service discovery uses known endpoints.
- Runtime state → OS fingerprint: targeting · Fingerprinting uses collected host observations.
- Frame parse → LLDP: observe · Passively consumes LLDP traffic.
- Frame parse → STP: observe · Passively consumes STP traffic.
- Frame parse → mDNS: observe · Passively consumes mDNS traffic.
- Frame parse → NetBIOS: observe · Passively consumes NetBIOS traffic.
- Frame parse → VLAN discover: observe · Consumes VLAN-related traffic for topology clues.
- ARP sweep → Network map: update · Adds newly discovered hosts.
- Port scan → Network map: update · Records open ports and reachability.
- Service scan → Network map: update · Stores identified services and banners.
- OS fingerprint → Network map: update · Attaches inferred OS characteristics.
- LLDP → Network map: update · Adds switch and neighbor relationships.
- STP → Network map: update · Adds topology hints from spanning-tree traffic.
- mDNS → Network map: update · Records discovered devices and services.
- NetBIOS → Network map: update · Adds NetBIOS names and host hints.
- VLAN discover → Network map: update · Records VLAN structure clues.
- Injector → Replay: emit · Low-level packet emission is reused for replay.
- Runtime state → Injector: context · Injection uses current network context and identities.
- Runtime state → ARP MITM: context · MITM routines depend on learned host relationships.
- Runtime state → DHCP starve: context · Starvation logic depends on network state.
- Runtime state → DNS spoof: context · Spoofing depends on names and targets.
- Runtime state → MAC spoof: context · MAC identity changes use current configuration.
- Runtime state → NBNS poison: context · Poisoning depends on discovered names and hosts.
- Runtime state → TCP RST: context · RST injection targets active flows.
- Injector → ARP MITM: craft · Builds forged ARP traffic.
- Injector → DHCP starve: craft · Builds DHCP request floods.
- Injector → DNS spoof: craft · Builds forged DNS responses.
- Injector → MAC spoof: craft · Builds packets with spoofed identity.