Commit Graph

197 Commits

Author SHA1 Message Date
Cobra 93592ae2ff Add bounds checks to netlink and DHCP parsers — prevent exception flood on malformed packets 2026-04-10 15:49:03 -04:00
Cobra c6fb35430d Fix P1 blockers: configurable port, connection leak, race condition, DB path + WAL
- P1 #551: Add STATUS_PORT env var (default 9191) for configurable HTTP status server port
- P1 #552: Fix SQLite connection leak — wrap all sqlite3.connect() with try/finally in lookup_person(), seed_persons_from_db(), log_signal(), log_presence_change()
- P1 #553: Fix race condition in update_person_state() — compute certainty snapshot under devices_lock, determine state transition under persons_lock, send alert outside locks to prevent stale snapshot
- P2 #559 (included): Add WAL mode + pragmas to init_db() for concurrent write safety
- Database path: Align to /opt/sensor/presence.db in both daemon and install.sh
- Increase connection timeout from 1s to 10s across all functions
- install.sh: Document PRESENCE_STATUS_PORT and PRESENCE_MATRIX_WEBHOOK env vars
2026-04-10 15:49:03 -04:00
Cobra 6e0a293075 Add presence daemon user documentation and architecture guide 2026-04-10 15:49:03 -04:00
Cobra d1abd45173 Add passive presence daemon — multi-signal WiFi/ARP/DHCP/BLE with exponential decay
Implements DevTrack #530: Person Presence Intelligence daemon for BigBrother drop implant.

Core components:
- presence_daemon.py: 4 sensor threads (probe, ARP, DHCP, BLE) with exponential decay
- presence_schema.sql: SQLite schema for persons, devices, signals, occupancy log
- install.sh: Deployment script (copies to /opt/sensor/, creates systemd service)
- AUDIT_impl.md: Implementation notes, limitations, audit checklist

Features:
- Exponential decay model (lambda=0.08/min) for signal certainty
- Presence anchor (45-min hold time prevents false VACANT)
- Person state machine: UNKNOWN → PRESENT ↔ ABSENT
- Multi-signal fusion: max + 0.08×min for device aggregate
- Thread-safe in-memory state with SQLite persistence
- Matrix webhook alerting (if configured)
- HTTP status endpoint on 127.0.0.1:9191
- Graceful BLE degrade if bleak unavailable
- No tool fingerprints in output or service names
2026-04-10 15:49:03 -04:00
Cobra ea973f9ebe Revert "Add presence DB schema; fix BLE passive scan mode (bleak #1440)"
This reverts commit 2499db6147be65c76e7e202190b81855ba7b9100.
2026-04-10 15:49:03 -04:00
Cobra 7f54cd00c0 Revert "Add Phase 1 WiFi presence daemon — mDNS + ARP fusion with exponential decay and presence anchor"
This reverts commit b9adf498106c52f1c7508a791a7aac30d5ca1955.
2026-04-10 15:49:03 -04:00
Cobra 715654666b Add Phase 1 WiFi presence daemon — mDNS + ARP fusion with exponential decay and presence anchor 2026-04-10 15:49:03 -04:00
Cobra 80fc79709a Add presence DB schema; fix BLE passive scan mode (bleak #1440) 2026-04-10 15:49:03 -04:00
Cobra c4d6262bd2 Apply QA corrections to consolidated security review: deconflict APT-001 triage, add deduplication transparency, document exploit chain dependencies 2026-04-10 15:49:03 -04:00
n0mad1k 8223751490 Add comprehensive test suites for 7 bigbrother modules
Cover packet_capture (rotation/zstd/AES), credential_db (dedup/hashcat/bulk),
ja3_spoofer (profiles/cipher mapping/randomization), responder_mgr (hash
capture/dedup/conf gen), ntlm_relay (protocol inference/command building/
coordination), ids_tester (risk assessment/preflight/caplet), and bridge
(setup/teardown/ebtables/watchdog). 187 tests total, all passing.
2026-04-10 07:38:28 -04:00
n0mad1k fded0ff4e7 Add responder_mgr NTLM hash capture validation tests 2026-04-10 07:37:22 -04:00
n0mad1k 7aab56cbe0 Add ntlm_relay wrapper and ADCS relay validation tests 2026-04-10 07:36:16 -04:00
n0mad1k 79baaa61b7 Add ids_tester IDS evasion self-test validation tests 2026-04-10 07:34:49 -04:00
n0mad1k ecec702937 Add validation tests for packet_capture, credential_db, and ja3_spoofer
Tests cover:
- packet_capture: zstd compression, AES-256-GCM encryption, rotation
  pipeline, disk purge, file locking (15 tests)
- credential_db: ingestion, deduplication at scale (1000+), hashcat
  export filtering, crack status management, bulk update, CSV/JSON
  export, query helpers (25 tests)
- ja3_spoofer: builtin profile validation, cipher ID mapping, external
  DB loading, auto-selection, SSL context config, randomization
  validation (28 tests)

Addresses DevTrack items #424, #425, #437.
2026-04-10 07:29:08 -04:00
n0mad1k ddb4c5d0a8 Expand p0f OS fingerprint signatures from 16 to 102 entries
Comprehensive p0f-style TCP SYN signatures covering Linux (kernel 2.0-6.x,
Android, Chrome OS, Alpine, containers), Windows (2000 through 11/Server
2022, XP, Embedded), macOS (Tiger through Sonoma), iOS/iPadOS/tvOS/watchOS,
BSDs (Free/Open/Net/DragonFly), Solaris/illumos, network devices (Cisco
IOS/NX-OS/IOS-XE, Juniper, MikroTik, Ubiquiti, pfSense, OPNsense,
Fortinet, Palo Alto, Aruba, F5, HP ProCurve, Arista), printers (HP,
Brother, Epson, Canon, Xerox, Ricoh, Kyocera, Lexmark, Zebra), embedded/
IoT (lwIP, uIP, VxWorks, QNX, Zephyr, ESP-IDF, FreeRTOS, Contiki-NG,
Windows IoT), gaming consoles, and virtualization guests.

DevTrack: bigbrother #419
2026-04-10 07:06:50 -04:00
n0mad1k 05a3f7553b Expand MAC profiles from 55 to 132 innocuous device profiles
Added profiles for: more streaming devices (Shield TV, Roku 4K),
additional smart TVs (Hisense, Insignia, Philips, Toshiba), more smart
speakers (Sonos Era, HomePod, Bose, Echo Pop/Studio), extensive IoT
devices (Arlo, Eufy, Chamberlain, Lutron, Lifx, Roborock, SmartThings,
August, Honeywell), more printers (Kyocera, Lexmark, Ricoh, Xerox),
additional gaming (Xbox Series S, Switch OLED, Steam Deck), more phones
(Pixel, OnePlus, Xiaomi), wearables (Apple Watch, Fitbit, Garmin,
Galaxy Watch), network gear (Linksys, ASUS, eero), and NAS devices
(Synology, QNAP). New device_type categories: wearable, network, nas.

DevTrack: bigbrother #417
2026-04-10 07:05:25 -04:00
n0mad1k 2cb408af4f Expand JA3 fingerprint database from 4 to 501 profiles
New seed_ja3.py generates comprehensive JA3 TLS fingerprint profiles
covering Chrome/Chromium (100-124 x 4 platforms), Firefox (100-125 x 3),
Edge, Safari (macOS + iOS), Opera, Brave, Tor Browser, Vivaldi, ChromeOS,
TLS libraries (OpenSSL, BoringSSL, GnuTLS, NSS, Go, Java, .NET, Node.js,
mbedTLS, wolfSSL, rustls), common tools (curl, wget, Python, httpx),
mobile clients (Samsung Internet, Android WebView, iOS WKWebView),
VPN clients (AnyConnect, GlobalProtect, OpenVPN, WARP), Electron apps,
and IoT/embedded devices (ESP32, AWS IoT, smart home).

JA3 hashes are computed correctly from TLS ClientHello parameters using
the standard MD5(version,ciphers,extensions,curves,formats) formula.

DevTrack: bigbrother #416
2026-04-10 07:02:56 -04:00
Cobra 296bb08c56 Fix ble_alerter: MAC name filter, Matrix 429 backoff, active scanner
- Reject dash/colon MAC-format device names (e.g. 45-48-39-7F-73-C7)
  from open mode — were slipping past is_generic_name()
- Add exponential backoff (1s, 2s) on Matrix 429/5xx, max 3 attempts —
  startup burst was rate-limiting and dropping alerts
- Commit active scanner flag (scanning_mode=active) that was in working
  tree but not in prior commit 8686eb5 despite the commit message
- Add 3 tests: MAC format filter, 429 retry success, 429 give-up

Fixes DevTrack #518
2026-04-10 06:44:13 -04:00
Cobra 8686eb520e Switch BLE scanner to active mode — bleak 0.20 passive requires or_patterns on BlueZ
Passive mode fails on Debian bookworm bleak 0.20.2 without or_patterns filter.
Active mode is functionally equivalent for building-level presence detection
and actually yields more complete advertisement data including device names.
2026-04-10 06:37:30 -04:00
Cobra a1d6266c33 Fix test_too_short test (abc/abd are hex characters) 2026-04-10 06:33:38 -04:00
Cobra 8429ab10ff Restore execute permission on operator_setup.sh 2026-04-10 06:32:31 -04:00
Cobra 7a453ede6a Add BLE alerter configuration to operator_setup.sh (mode, devices, timeout, Matrix creds) 2026-04-10 06:32:29 -04:00
Cobra c778d27bac Update deploy-daemon.sh to deploy both net_alerter and ble_alerter 2026-04-10 06:31:55 -04:00
Cobra 6fac58aead Add unit tests for BLE alerter (mocked bleak, async scenarios) 2026-04-10 06:31:41 -04:00
Cobra 77dbf1baa3 Add systemd unit for BLE alerter (after bluetooth.target) 2026-04-10 06:31:39 -04:00
Cobra 358e07f7f6 Add BLE alerter daemon (passive scan, named-device tracking, Matrix alerts) 2026-04-10 06:31:38 -04:00
Cobra 6447a462c2 Fix ARRIVED spam — mark departing instead of popping from known_devices
When on_departure popped the device from known_devices, rapid RTM_NEWNEIGH
events during ARP cache rebuild each triggered on_arrival as if the device
was brand new, flooding the Matrix room with 5-10+ duplicate ARRIVED alerts.

Fix: keep device in known_devices with departing=True flag. on_arrival
silently cancels pending departure timers and returns without alerting when
it sees this flag. Timer callback checks flag before sending the alert and
only pops the device when departure is confirmed after 15 minutes.
2026-04-09 14:34:46 -04:00
Cobra 67cf907f74 Fix on_arrival() to always cancel departure timer on device re-arrival
- Bug: device departs → timer starts, but last_departed_time not set yet
  If device re-arrives before timer fires, timer never cancelled
  Result: false DEPARTED alert sent after re-arrival debounce expires

- Fix: Cancel any pending departure timer immediately on re-arrival,
  before checking last_departed_time

- Test: Added regression test that verifies timer is cancelled when
  device re-arrives before 15-min debounce expires, preventing false alerts

- All 10 tests passing
2026-04-09 13:28:34 -04:00
Cobra 504be80325 Deploy OUI database as part of net_alerter daemon installation
- scp oui.db to /opt/net_alerter/oui.db after daemon script
- Verify DB on remote via Python/sqlite3
- Confirm row count on target host
2026-04-09 13:05:34 -04:00
Cobra ab0688e1b3 Add SQLite OUI database lookup to net_alerter
- lookup_oui() now tries SQLite first (/opt/net_alerter/oui.db)
- Falls back to inline OUI_DICT if DB missing or query fails
- No network calls, local SQLite reads only
- Debug-level logging for failures (no output noise)
2026-04-09 13:05:18 -04:00
Cobra caf44576b6 Add false positive suppression to net_alerter — fix for #467
- Infrastructure IPs (gateway, self, broadcast) silently ignored in
  on_arrival() and on_departure(); seeded at startup from 'ip route'
- 15-minute departure debounce: alert only fires if device is still
  absent after 900s, eliminating ARP cache flush false positives
- 5-minute re-arrival suppression: ARRIVED alert skipped when device
  returns within 5 min of a recorded departure (covers interface flap)
- DHCP renewal dedup: known device re-announcing within 30 min skips
  ARRIVED alert
- Tests added for all four suppression paths (9 total, all passing)
2026-04-09 09:44:37 -04:00
Cobra 25f5775b6f Append QA review findings to consolidated security report
Delta reviewer validation completed:
- 12-item checklist validated (10 PASS, 2 PASS WITH CORRECTIONS, 1 FAIL)
- All 101 agent findings verified as complete and accurate
- 3 corrective actions identified: APT-001 deconfliction, bidirectional cross-refs, dedup transparency
- Report ready for remediation planning with low-effort corrections
2026-04-09 08:31:26 -04:00
Cobra c50be60f51 Append 4 operator Q&A sections with detailed exploitation scenarios and OPSEC analysis 2026-04-09 08:25:52 -04:00
Cobra f7b3796725 Make net_alerter alerts readable — fix hostname dedup and inline OUI lookup
- Replace broken OUI file lookup with inline dict of 200+ common vendors (works on Armbian)
- Fix hostname/IP duplication when reverse DNS fails (show IP once, not twice)
- Add format_arrival() and format_departure() helpers for consistent alert formatting
- Update on_arrival/on_departure to use new formatting functions
- Add comprehensive tests for hostname dedup and OUI lookup
2026-04-08 22:40:35 -04:00
Cobra 2ada26cbfe Update module count assertions to reflect reverse_tunnel removal 2026-04-08 22:26:06 -04:00
Cobra 95714885cd Strip OPSEC tool identity fingerprints
Replace all sensor.* logger namespaces with __name__ (generic module
identifiers instead of discoverable 'sensor.*' prefixes).

Change hardcoded 'bb' API user to 'admin' in config and code defaults.

Change hardcoded relay_user 'bb' to 'operator' — prevents network
profiling from exposing tool identity via SSH config.

Fixes #457, #458, #459
2026-04-08 22:18:35 -04:00
Cobra 84fa2d7b56 Add net_alerter README with quick start guide 2026-04-08 21:56:28 -04:00
Cobra a194642941 Add Orange Pi Zero 3 specific deployment guide 2026-04-08 21:56:03 -04:00
Cobra eb6221d29c Add net_alerter daemon deployment documentation 2026-04-08 21:55:39 -04:00
Cobra 571033f8dc Add deployment script for net_alerter daemon 2026-04-08 21:55:18 -04:00
Cobra e74ef10d1b Rebuild net_alerter as persistent daemon — DHCP sniffer + Netlink RTM_NEWNEIGH/DELNEIGH; removes 5-min cron, zero active probing 2026-04-08 21:55:02 -04:00
Cobra 1f90f9ca25 Replace nmap ARP scan with passive /proc/net/arp read — no active probing (#449)
- Removed get_local_subnets() and scan_subnet() — no longer needed
- Added read_arp_cache() to read kernel ARP table from /proc/net/arp
- Added fallback to 'ip neigh show' if /proc/net/arp unavailable
- Added lookup_oui() to query system /usr/share/hwdata/oui.txt for vendor names
- Removed subprocess nmap call and re import (no longer needed)
- run() now directly reads ARP cache instead of scanning subnets
- Zero active network traffic — purely passive monitoring
- Removed sudo requirement
2026-04-08 21:01:12 -04:00
Cobra 44b497ef41 Add missing detect_interface_with_retry function to fix engine startup 2026-04-08 20:59:35 -04:00
Cobra 245731e73b Robust interface detection — retry fallback chain for headless boot (#206)
Fixes interface auto-detection failures on Pi Zero 2W where wlan0 doesn't exist
at boot. Implementation:

- Added detect_interface_with_retry() function with 3x retry fallback chain
- Config-supplied interface preferred, then /proc/net/route, then UP interface
- Exponential backoff: 5s, 10s, 20s delays between retries
- Filters excluded prefixes: lo, tailscale*, wg*, tun*, docker*, veth*, br-*
- Used in Engine.__init__(), PacketCapture.start(), MacManager.start()
- Full test coverage: 10 tests for detection, backoff, filtering

Addresses issue where network stack initializes after boot and interfaces
become available after 5-10 second delay.
2026-04-08 20:58:43 -04:00
Cobra 6f421511de Add test to verify Engine instantiates and injects CaptureBus into passive modules (#204) 2026-04-08 20:57:10 -04:00
Cobra 6a79516a28 Enrich net_alerter alerts with OUI vendor and reverse DNS hostname
Parse nmap vendor name from MAC Address line (filtering out 'Unknown').
Fall back to socket.gethostbyaddr for IPs nmap didn't resolve a hostname
for. Alert label is now: 'hostname (vendor)' | 'hostname' | 'vendor' |
'unknown', in that priority order.
2026-04-08 20:31:49 -04:00
Cobra d164958831 Fix Cloudflare bot detection blocking net_alerter Matrix sends
urllib's default Python-urllib user agent is flagged by Cloudflare Bot
Fight Mode (error 1010) when m.mealeyfamily.com homeserver sits behind
Cloudflare. Add a browser-like User-Agent to Matrix PUT/POST requests so
Cloudflare passes the traffic through.
2026-04-08 20:19:24 -04:00
Cobra 019a96b205 Fix flash bugs: remove netplan wifi conflict, suppress eth default route, force IPv4 for Tailscale install
- Remove 20-wifi.yaml netplan block (Bug 1): causes netplan to spawn its own wpa_supplicant instance, which claims ctrl_iface and blocks wpa_supplicant@wlan0.service. The per-interface systemd service is the correct approach.
- Add cleanup line to remove any pre-existing 20-wifi.yaml from the Armbian image.
- Patch 10-dhcp-all-interfaces.yaml to suppress default route on ethernet (Bug 2): without this, ethernet DHCP default route metric 100 beats WiFi metric 1024, routing internet traffic to ethernet which has no upstream. Causes Tailscale and firstboot to fail.
- Force IPv4 resolution in Tailscale curl (Bug 3): some homelab/ISP networks lack IPv6 internet routes. IPv6 DNS resolution for tailscale.com causes immediate curl failure on first boot.
2026-04-08 19:37:38 -04:00
Cobra 248ba78e15 Fix WiFi: enable wpa_supplicant@wlan0 — instance was never linked 2026-04-08 15:56:48 -04:00
Cobra 334f9830e1 Replace .bigbrother with .implant in all identity strings — avoid tool name exposure on fresh flash 2026-04-08 14:08:00 -04:00