net.sniff: offline PCAP mode unnecessarily starts net.recon
Summary
When net.sniff.source is set to a PCAP file, net.sniff on still auto-starts net.recon as a hard module requirement. The sniffer correctly opens and parses the file without a live capture handle, but the session also starts a live ARP-cache discovery worker. On minimal Linux systems without iproute2, that worker repeatedly logs missing-ip errors even though offline dissection succeeds.
Steps to reproduce
- Build bettercap at revision
2359c0be7900c8bf16ed867b49f78d819f14aa62(observed withbettercap v2.41.7on Linux/arm64, built with Go 1.26.5). - In a root container where the
ipbinary is absent (a minimal Debian Bookworm image withoutiproute2), prepare a small Ethernet PCAP with at least one IPv4/TCP payload, such as a single HTTP request. - Run a non-interactive session:
bettercap -no-history -no-colors -iface lo -eval \
'set net.sniff.source /path/to/sample.pcap; set net.sniff.verbose true; set net.sniff.local true; set net.sniff.output /path/to/out.pcapng; net.sniff on; sleep 2; net.sniff stats; active; net.sniff off; active; q'- Observe the session log while the offline sniffer runs.
Expected behavior
With net.sniff.source set to a readable PCAP, starting the sniffer should open that file (and optional output) without requiring live host discovery. Documentation for net.sniff.source describes reading from the PCAP file instead of the current interface; offline analysis should not mandate net.recon or host ip/gateway discovery.
Actual behavior
The session starts net.recon before the offline sniffer and the recon worker then reports failures because ip is absent:
[sys.log] [inf] net.sniff starting net.recon as a requirement for net.sniff
[sys.log] [err] net.recon exec: "ip": executable file not found in $PATH
[sys.log] [war] executable ip not found in $PATH
[net.sniff.http.request] http local GET proof.invalid/offline-proof
[sys.log] [inf] Wrote Packets : 8The same run parsed the HTTP request, wrote all eight captured packets to a non-empty PCAPNG, and showed net.recon still active after net.sniff off. This demonstrates that offline parsing itself does not need the recon worker, while the unconditional dependency adds live host-discovery behavior and errors.
Affected area
modules/net_sniff:NewSniffercallsRequires("net.recon")unconditionally- Session module start path that auto-runs required modules before the sniffer worker
- Documented offline parameter
net.sniff.source
Runtime or environment
- bettercap
v2.41.7, Linux/arm64, Go 1.26.5 - Source revision
2359c0be7900c8bf16ed867b49f78d819f14aa62 - Root in a disposable Debian Bookworm container without
iproute2(ipconfirmed absent) - Loopback-generated input PCAP;
net.sniff.sourceset; no live sniffer handle requested
Evidence
- At the current
masterpin,modules/net_sniff/net_sniff.goregistersmod.SessionModule.Requires("net.recon")unconditionally, whilemodules/net_sniff/net_sniff_context.goseparately selectspcap.OpenOfflinewhennet.sniff.sourceis non-empty. session/module.goiterates every required module, logsstarting %s as a requirement for %s, and executes<module> onbefore marking the requested module running.- The disposable offline run showed recon auto-start and repeated missing-
iperrors alongside successful HTTP dissection and PCAPNG output. Focusedsessionandnet_recontests passed;modules/net_sniffcurrently has no test files. - The official
net.sniffdocumentation saysnet.sniff.sourcereads from a PCAP file instead of the current interface; it does not document starting host discovery for this path.
Impact
- Offline and forensic PCAP workflows unexpectedly start live ARP-cache discovery and invoke host tooling (
ip neighon Linux). - Minimal containers and locked-down lab images show hard errors even when sniffing succeeds.
- Automated agents treating log errors as failure may mark a successful offline parse as failed.
net.reconremains active afternet.sniff off, so ARP-table polling and endpoint events can continue until recon is explicitly stopped or the session exits.
Additional context
The test container also emitted session-start warnings because netstat was absent and no gateway was detected. Those warnings occurred before net.sniff on and are not attributed here to the recon dependency; the recon-specific failure is the repeated net.recon exec: "ip" error after the requirement-start log.
Closure signal: with net.sniff.source set to a valid PCAP and no live-capture intent, net.sniff on does not start net.recon (or otherwise does not require host ip/gateway discovery), offline packets still parse, and the session log is free of recon requirement errors for that path. Live interface sniffing may continue to use recon if that remains an intentional design for Ethernet identity.
Source: bettercap/bettercap