Hacker / CamSniff_dataset.json
Ananthusajeev190's picture
Upload 10 files
a2abc04 verified
[
{
"file_name": "README.md",
"relative_path": "README.md",
"extension": ".md",
"size_bytes": 17580,
"content": "# CamSniff\n\n> **Automated IP Camera & Network Video Stream Reconnaissance Toolkit**\n> Smart, mode-aware reconnaissance that maps every camera and stream across your infrastructure, from living rooms to datacenters.\n\n<div align=\"center\">\n\n[![Last Commit](https://img.shields.io/github/last-commit/John0n1/CamSniff?style=flat-square\\&logo=github\\&color=red)](https://github.com/John0n1/CamSniff/commits/main)\n[![Shell](https://img.shields.io/badge/language-bash-black?logo=gnubash\\&style=flat-square)](#)\n[![Python](https://img.shields.io/badge/language-python-black?logo=python\\&style=flat-square)](#)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](LICENSE)\n\n**Current version:** `2.2.3` \u00b7 \n\n<img src=\"docs/camsniff.png\" alt=\"CamSniff logo\" width=\"320\" />\n\n</div>\n\n---\n\n# Table of contents\n\n1. [Overview](#overview)\n2. [Why CamSniff?](#why-camsniff)\n3. [Feature matrix](#feature-matrix)\n4. [Architecture & flow](#architecture--flow)\n5. [Project layout](#project-layout)\n6. [Scanning modes](#scanning-modes)\n7. [Install & quick start](#install--quick-start)\n8. [Command line examples](#command-line-examples)\n9. [Output format & artifacts](#output-format--artifacts)\n10. [Discovery & profiling logic (short)](#discovery--profiling-logic-short)\n11. [Credential probing behavior](#credential-probing-behavior)\n12. [Configuration & extending dictionaries](#configuration--extending-dictionaries)\n13. [Analysis helper & IVRE integration](#analysis-helper--ivre-integration)\n14. [Dependencies](#dependencies)\n15. [Troubleshooting & tips](#troubleshooting--tips)\n16. [Hardening, ethics & responsible use](#hardening-ethics--responsible-use)\n17. [Contributing & roadmap](#contributing--roadmap)\n18. [License](#license)\n\n---\n\n# Overview\n\n**CamSniff** is a modular reconnaissance toolkit focused on discovering, profiling and opportunistically acquiring snapshots/streams from IP cameras and networked video sources on *local networks*. It blends active scanning (Nmap, optional Masscan), passive discovery (Avahi/mDNS/SSDP), short traffic sampling (TShark), HTTP/ONVIF banner pulls, and vendor templates (`data/catalog/paths.csv`) to produce structured, reproducible results.\n\nKey design points:\n\n* Mode-aware: tune from **stealth** \u2192 **nuke** for noise vs coverage tradeoffs\n* Multi-protocol: RTSP, ONVIF, HLS, WebRTC, SRT, RTMP, CoAP probes, etc.\n* Output: structured JSON (`discovery.json`, `credentials.json`) + thumbnails & logs\n* Offline-friendly: no external lookups required \u2014 vendor intelligence lives in `data/`\n\n> \u26a0\ufe0f **Responsible use only** \u2014 Do **not** scan or capture media from devices/networks you are not explicitly authorized to test. Treat captured imagery and credentials as highly sensitive.\n\n---\n\n# Why CamSniff?\n\n* Reduce repetitive manual recon: one command yields a consistent, auditable dataset.\n* Templated vendor intelligence speeds up discovery of likely snapshot/RTSP endpoints.\n* Tunable credential probing keeps operations traceable and bounded by the chosen mode.\n* Designed to be integrated with IVRE for persistent, queryable reconnaissance databases.\n\n---\n\n# Feature matrix\n\n| Area | Highlights |\n| ------------------- | ---------------------------------------------------------------------------------- |\n| Discovery | Nmap TCP/UDP scan, NSE RTSP brute, optional Masscan + SSDP broadcast sweep |\n| Target specification| Auto-detect local network or load from JSON/text files with `--targets` |\n| Passive | Avahi/mDNS & SSDP filtering for camera/service keywords; HTTP banner harvesting |\n| Traffic sampling | Targeted TShark captures to extract observed URIs |\n| Protocols | ONVIF (incl. device info), RTSP, HLS, WebRTC/STUN, RTMP, SRT, CoAP `/.well-known/core` |\n| Vendor profiling | `data/catalog/paths.csv` maps OUI/heuristics \u2192 RTSP/HTTP templates + CVEs |\n| Credential strategy | Mode-limited curated username/password lists, default combos |\n| Acquisition | ffmpeg RTSP grabs, HTTP snapshot requests, optional ASCII previews (chafa) |\n| Output | `discovery.json`, `credentials.json`, thumbnails, HTTP/ONVIF/SSDP metadata logs |\n| Extras | IVRE sync script, post-scan analysis scripts, enrichers |\n\n---\n\n# Architecture & flow (concise)\n\n1. Decide mode (timings, breadth, credential caps) via `scripts/core/mode-config.sh`.\n2. Active scan: Nmap (scripted RTSP brute NSE); optional Masscan merges ports.\n3. Passive discovery: SSDP broadcast sweep + Avahi/mDNS for camera/service keywords.\n4. Traffic sampling: TShark capture on observed hosts to find candidate URIs.\n5. UDP micro-scan for STUN/WS-Discovery/SRT indicators.\n6. CoAP probe to `/.well-known/core` for constrained devices.\n7. HTTP metadata & ONVIF device-info pulls for banner/realm correlation.\n8. Vendor matching using `data/catalog/paths.csv` \u2192 produce candidate RTSP/HTTP templates.\n9. Assemble `discovery.json` and run credential/media acquisition phase.\n10. Optionally, push to IVRE with `--extra ivre`.\n\n---\n\n# Project layout\n\n* `scripts/camsniff.sh` \u2014 launcher/orchestrator for every scan phase.\n* `scripts/core/` \u2014 mode/port profile logic and other shared knobs.\n* `scripts/setup/` \u2014 dependency/bootstrap helpers (libcoap build, package install).\n* `scripts/probes/` \u2014 SSDP, ONVIF, credential probe, and related active modules.\n* `scripts/helpers/` \u2014 Python utilities for catalog enrichment, HTTP parsing, RTSP summaries.\n* `scripts/integrations/` \u2014 IVRE sync and manager utilities.\n* `scripts/tools/` \u2014 analysis/reporting helpers.\n* `scripts/ui/` \u2014 banner and terminal rendering helpers.\n* `data/catalog/` \u2014 vendor templates + CVEs.\n* `data/dictionaries/` \u2014 credentials, HTTP/RTSP dictionaries.\n* `data/examples/` \u2014 sample target lists.\n* `data/protocols/` \u2014 NSE RTSP brute script and protocol assets.\n\n---\n\n# Scanning modes (summary)\n\nEach mode adjusts port profiles, timing, Masscan usage, NSE breadth, and maximum credential attempts.\n\n| Mode | Masscan | Nmap speed | Creds (max) | TShark (s) | Use case |\n| -----------: | :-----: | :------------------: | :---------: | :--------: | ----------------------- |\n| `stealth+` | no | -T1 | 8 | 15 | Minimal noise, slowest |\n| `stealth` | no | -T2 | 12 | 20 | Quiet local scans |\n| `medium` | yes | -T4 | 32 | 35 | Default balanced |\n| `aggressive` | yes | -T4 -A | 64 | 45 | More scripts/versioning |\n| `war` | yes | -T5 -A | 96 | 55 | Broad vendor coverage |\n| `nuke` | yes | -T5 -A --script vuln | 128 | 75 | Full sweep (1\u201365535) |\n\nDefault: `--mode medium`. Example: `sudo camsniff --mode stealth`.\n\n---\n\n# Install & quick start\n\n## A \u2014 From releases (Debian package)\n\n```bash\n# download latest release .deb\nsudo apt install ./camsniff_*amd64.deb\n# run\nsudo camsniff --mode medium\n```\n\n## B \u2014 From source (developer / live edits)\n\n```bash\ngit clone https://github.com/John0n1/CamSniff.git\ncd CamSniff\nchmod +x scripts/*.sh data/*.sh\nsudo scripts/camsniff.sh # first run bootstraps dependencies if needed\n```\n\n> On first run the script attempts to install or build missing runtime tooling (where possible). Read logs in `dev/results/<run>/logs/` if a dependency fails.\n\n---\n\n# Command line examples\n\n```bash\n# quick balanced scan (default intensity)\nsudo camsniff --mode medium\n\n# quiet scan (low footprint)\nsudo camsniff --mode stealth+\n\n# aggressive, include IVRE ingestion\nsudo camsniff --mode aggressive --extra ivre\n\n# skip confirmation (non-interactive)\nsudo camsniff --yes\n\n# pin output location and tag the run\nsudo camsniff --output-root /mnt/scan-results --run-name office\n\n# force a specific capture interface for tshark\nsudo camsniff --interface eth0\n\n# skip automated credential probing\nsudo camsniff --skip-credentials\n\n# skip dependency installation (assumes tools are already present)\nsudo camsniff --skip-install\n\n# generate a markdown or HTML report\nsudo camsniff --report markdown\nsudo camsniff --report html\n\n# smart target shaping and confidence ranking\nsudo camsniff --smart --smart-min 35 --smart-max 60\n\n# enrich SSDP results with device descriptions\nsudo camsniff --ssdp-describe\n\n# encrypt results (auto-selects age/gpg)\nsudo camsniff --encrypt-results --encrypt-recipient \"age1example...\"\n\n# force gpg encryption with a key id\nsudo camsniff --encrypt-results gpg --encrypt-recipient \"KEYID\"\n\n# scan specific IP ranges from a JSON file\nsudo camsniff --mode medium --targets /path/to/targets.json\n\n# scan specific IP ranges from a text file\nsudo camsniff --mode war --targets /path/to/targets.txt\n\n# show help / version\nsudo camsniff --help\nsudo camsniff --version\n```\n\n---\n\n# Output format & artifacts\n\nAll run outputs live in `dev/results/<UTC_TIMESTAMP>/` by default:\n\nYou can override the base directory with `--output-root` and append a label with\n`--run-name`. Example: `/mnt/scan-results/20250101T000000Z-office/`.\n\nReports are written as `report.md` or `report.html` inside each run directory.\nWhen `--encrypt-results` is enabled an encrypted `.tar.gz.age` or `.tar.gz.gpg`\narchive is created alongside the run directory (plaintext remains on disk).\nFor GPG symmetric encryption without prompts, set `CAM_ENCRYPT_PASSPHRASE`.\n\n* `discovery.json` \u2014 canonical host dataset with enrichment metadata + confidence scoring\n* `credentials.json` \u2014 credential attempts & successes per host\n* `thumbnails/` \u2014 JPEG snapshots of successful grabs (organized per run)\n* `logs/` \u2014 raw phase logs (`nmap-output.txt`, `masscan-output.json`, `avahi-services.txt`, `tshark-traffic.csv`, `coap-probe.log`, `http-metadata.jsonl`, `ssdp-discovery.jsonl`, `onvif-discovery.jsonl`)\n* `analysis/` \u2014 optional aggregated statistics from `scripts/tools/analyze.sh`\n\n`discovery.json` snapshot example (trimmed):\n\n```jsonc\n{\n \"ip\": \"192.168.1.42\",\n \"mac\": \"AA:BB:CC:DD:EE:FF\",\n \"sources\": [\"Nmap\",\"TShark\",\"Avahi\"],\n \"ports\": [80,554,8443],\n \"observed_paths\": [\"/onvif/device_service\", \"rtsp://...\"],\n \"profile_match\":{\n \"vendor\":\"VendorX\",\n \"model\":\"ModelY\",\n \"matched_by\":\"oui\",\n \"rtsp_candidates\":[...],\n \"http_snapshot_candidates\":[...],\n \"cve_ids\":[\"CVE-2024-XXXX\"]\n },\n \"confidence\": {\n \"score\": 78,\n \"level\": \"high\",\n \"classification\": \"camera\",\n \"reasons\": [\"rtsp url discovered\", \"onvif detected\"]\n }\n}\n```\n\n---\n\n# Discovery & profiling logic (short)\n\n* **Observed evidence**: Nmap + TShark + Avahi merge into a host record.\n* **Heuristics**: port fingerprints, OUI regex, observed HTTP/RTSP URIs, ONVIF/SSDP/HTTP banners.\n* **Vendor templates**: `data/catalog/paths.csv` contains OUI & port heuristics \u2192 RTSP/HTTP templates + CVEs.\n* **Enrichment**: small Python post-processor ranks candidates and annotates `discovery.json`.\n* **Smart targeting**: `--smart` prioritizes deeper probes using early signals and prints a confidence ranking.\n* **SSDP describe**: `--ssdp-describe` fetches device descriptions to boost fingerprints.\n\n---\n\n# Credential probing behavior\n\n`scripts/credential-probe.sh` uses:\n\n1. Vendor default combos (from `data/catalog/paths.csv`) + blank/empty password checks.\n2. Curated, mode-bounded username/password pair lists (`data/dictionaries/usernames.txt`, `data/dictionaries/passwords.txt`).\n3. Enumerated RTSP paths (profile + brute + observed from TShark).\n4. HTTP snapshot templated endpoints (`data/dictionaries/http-paths.txt`).\n\nSuccessful attempts record: credential pair, endpoint used, thumbnail path, timestamp. **Credentials are stored in plain JSON** \u2014 treat them as sensitive material and secure results directories accordingly.\n\n---\n\n# Target file formats\n\nCamSniff can ingest IP addresses and CIDR ranges from external files using the `--targets` flag. This allows for pre-defined target lists and integration with other reconnaissance tools.\n\n## JSON format\n\n```json\n{\n \"targets\": [\n \"192.168.1.0/24\",\n \"10.0.0.1\",\n \"172.16.0.0/28\"\n ]\n}\n```\n\nThe JSON file must contain a `targets` array with IP addresses and/or CIDR ranges as strings.\n\n## Text format\n\n```\n# Comment lines starting with # are ignored\n192.168.1.0/24\n10.0.0.1\n\n# Another network\n172.16.0.0/28\n```\n\nText files support one IP address or CIDR range per line. Empty lines and lines starting with `#` are ignored. Whitespace is automatically trimmed.\n\n## Usage examples\n\n```bash\n# Scan targets from JSON file\nsudo camsniff --mode medium --targets /path/to/targets.json\n\n# Scan targets from text file\nsudo camsniff --mode war --targets /path/to/targets.txt\n\n# Use the included example files\nsudo camsniff --mode medium --targets data/examples/example-targets.json\n```\n\nExample target files are provided in the `data/` directory:\n- `data/examples/example-targets.json` \u2014 JSON format example\n- `data/examples/example-targets.txt` \u2014 Text format example\n\nWhen using `--targets`, the script bypasses automatic network detection and scans only the specified targets.\n\n---\n\n# Configuration & extending dictionaries\n\nAll dictionaries live in `data/` and are editable:\n\n* `catalog/paths.csv` \u2014 vendor OUI regex \u2192 default creds, RTSP/HTTP templates, CVE IDs\n* `dictionaries/rtsp-urls.txt` \u2014 extend RTSP brute dictionary for NSE\n* `dictionaries/http-paths.txt` \u2014 fallback HTTP snapshot endpoints (templated)\n* `dictionaries/usernames.txt` / `dictionaries/passwords.txt` \u2014 curated credential lists (comments ignored)\n* `vendors/<vendor>/http-paths.txt` \u2014 vendor-specific HTTP snapshot templates\n* `vendors/<vendor>/rtsp-paths.txt` \u2014 vendor-specific RTSP templates\n* `core/port-profiles.sh` \u2014 logical named port sets used per scanning mode\n\nAfter edits, next run will use updated files. Keep additions concise, verifiable, and documented (one vendor per row ideally).\n\nVendor dictionary format:\n\n- HTTP: `template|port|channel|stream|label`\n- RTSP: `template|port|channel|stream|transport|label`\n\nTemplates may include `{{ip_address}}`, `{{username}}`, `{{password}}`, `{{port}}`,\n`{{channel}}`, and `{{stream}}` placeholders.\n\n---\n\n# Analysis helper & IVRE integration\n\n* `scripts/tools/analyze.sh` \u2014 prints host counts, vendor diversity, RTSP discovery volume, credential success rate.\n* `scripts/integrations/ivre-manager.sh` \u2014 optionally bootstraps a Python venv with IVRE + pymongo and pushes enriched hosts into IVRE (use `--extra ivre`).\n\n---\n\n# Dependencies\n\nCore runtime (auto-installed where possible):\n\n* nmap, masscan (optional), tshark (wireshark/tshark), avahi-utils, ffmpeg, curl, jq, python3 (+ venv), chafa (optional, for ASCII previews), libpcap.\n* Build tools for libcoap / `coap-client` (`git`, `cmake`, `build-essential`, `pkg-config`) \u2014 script `scripts/setup/build-coap.sh` will attempt to build if missing.\n\n---\n\n# Troubleshooting & tips\n\n* **Empty `discovery.json`** \u2014 verify interface, ARP visibility, run non-stealth mode for testing.\n* **Masscan skipped** \u2014 ensure `--mode` permits it (e.g., `medium`+).\n* **No thumbnails** \u2014 check `ffmpeg` availability and per-host logs in `dev/results/<run>/logs/`.\n* **ONVIF false negatives** \u2014 SSL/certificate redirects or nonstandard ports can hide endpoints \u2014 try `curl -k` manually against suspected endpoints.\n* **CoAP probes failing** \u2014 build `coap-client` via `scripts/setup/build-coap.sh`, inspect `logs/coap-probe.log`.\n* **Performance** \u2014 if `nuke` takes too long, use `medium` or a custom port profile.\n\nEnvironment toggles:\n\n* `NO_ANIM=1` \u2014 skip ASCII/intro animation (useful in CI).\n* `CAM_MODE_PORT_PROFILE` \u2014 override port profile programmatically (advanced).\n\n---\n\n# Hardening, ethics & responsible use\n\n* **Authorization** \u2014 never use CamSniff on networks/devices without explicit, written permission.\n* **Data protection** \u2014 captured images, device metadata and credentials are sensitive \u2014 encrypt and limit access.\n* **Least impact** \u2014 start with `stealth` modes during discovery and escalate only when authorized.\n* **CVE data** \u2014 treated as advisory; manual verification and safe disclosure practices required.\n* **Avoid uncontrolled credential spraying** \u2014 credential attempts are mode-bounded; respect target operational stability.\n\n---\n\n# Contributing\n\n1. Fork \u2192 create feature branch.\n2. Make focused changes (one concern per PR).\n3. Run `make lint` (uses `shellcheck`) and `scripts/test` if available.\n4. Add sample outputs or before/after notes where relevant.\n5. Submit PR and reference related issues.\n\nGuidelines:\n\n* Document every vendor template change and source of truth.\n* Prefer small, testable commits; avoid large binary additions.\n* Keep default dictionaries conservative \u2014 do not include proprietary credential lists.\n\n---\n\n# Roadmap (short)\n\n* Web dashboard: realtime JSON + thumbnails.\n* Live mosaic / timeline capture mode.\n* Encrypted credential store & role-based access.\n* Pluggable exporters: Markdown/HTML summary reports.\n* Additional protocol signatures (MQTT, SIP, more proprietary APIs).\n\nHave a feature idea? Please open an issue describing the use case.\n\n---\n\n# License\n\nMIT \u2014 see [LICENSE](LICENSE). <sub>\u00a9 2025 John Hauger Mitander. The authors disclaim responsibility for misuse. Practice ethical security research.</sub>\n"
},
{
"file_name": "copilot-instructions.md",
"relative_path": ".github/copilot-instructions.md",
"extension": ".md",
"size_bytes": 3461,
"content": "## Orientation\n- CamSniff is a Bash-driven reconnaissance pipeline for IP cameras; the orchestrator lives in `scripts/camsniff.sh` and must run as root because it invokes packet captures and low-level scans.\n- Startup calls `scripts/setup/deps-install.sh` with a spinner to ensure Nmap/Masscan/TShark/ffmpeg, builds libcoap if missing, and resolves per-mode knobs from `scripts/core/mode-config.sh`.\n- Modes in `scripts/core/mode-config.sh` feed port profiles (`scripts/core/port-profiles.sh`), RTSP threads, credential caps, curl/ffmpeg timeouts, and optional NSE extras; adjust both files together to keep UI labels accurate.\n\n## Workflow\n- Use `sudo scripts/camsniff.sh --mode medium --yes` for an end-to-end scan; the script derives the target CIDR from the default route and stages artifacts under `dev/results/<UTC>/`.\n- Pre-flight tooling with `sudo scripts/setup/deps-install.sh` or `sudo make install-deps`; follow with `make lint` (shellcheck + bash -n) and `make dev` for a dpkg dry run when iterating.\n- The Makefile\u2019s `make run MODE=war RUN_FLAGS='--extra ivre'` wraps the launcher; IVRE sync only stays enabled if MongoDB and the Python `ivre` package are available.\n- After scans, inspect `dev/results/<stamp>/discovery.json` and `credentials.json` with `scripts/tools/analyze.sh`; logs live in `dev/results/<stamp>/logs/`, thumbnails under `thumbnails/`.\n\n## Data & Extension Points\n- Vendor fingerprints, default credentials, CVEs, and HTTP/RTSP templates live in `data/catalog/paths.csv`; edits immediately change enrichment and credential probing.\n- `scripts/core/port-profiles.sh` maps logical profiles to Nmap/Masscan specs and RTSP thread hints\u2014update labels if you add or rename a profile so banners stay truthful.\n- Credential attempts pull from `data/dictionaries/usernames.txt`, `data/dictionaries/passwords.txt`, and fallback HTTP routes in `data/dictionaries/http-paths.txt`; keep comment lines starting with `hash` so the parsers skip them.\n- Protocol heuristics (`detect_onvif`, `detect_hls`, `detect_webrtc`, `detect_srt_from_ports`) live in `scripts/camsniff.sh`; use `record_protocol_hit` and `track_port` helpers to keep discovery JSON consistent.\n\n## Results Contract\n- `discovery.json` stores a `hosts[]` array with `sources`, `ports`, `observed_paths`, `rtsp_bruteforce`, and `additional_protocols`; preserve these keys if you extend the schema because `scripts/ivre-sync.py` consumes them.\n- `credentials.json` is a flat list written by `scripts/credential-probe.sh`; each item records `ip`, `username`, `password`, `success`, `method`, and optional media artifacts used by thumbnail generation.\n- IVRE integration calls `scripts/ivre-sync.py` after discovery when `--extra ivre` is set; it expects the virtualenv at `venv/` and logs to `dev/results/<stamp>/logs/ivre-sync.log`.\n- GeoIP databases under `share/geoip/` seed IVRE lookups; keep the `.version` sidecar files in sync when updating datasets.\n\n## Conventions\n- Bash code consistently uses `set -euo pipefail`, associative arrays, and helper functions close to their call sites; prefer pure functions and guard external commands with `command -v` checks.\n- UI rendering comes from `scripts/ui/banner.sh`; keep additions terminal-safe (tput-aware) because the launcher clears the screen around prompts and progress output.\n- Avoid touching unrelated `dev/results/` artifacts in code changes; they are user-generated outputs and should be ignored by automation.\n"
},
{
"file_name": "FUNDING.yml",
"relative_path": ".github/FUNDING.yml",
"extension": ".yml",
"size_bytes": 810,
"content": "# These are supported funding model platforms\n\ngithub: John0n1\npatreon: # Replace with a single Patreon username\nopen_collective: # Replace with a single Open Collective username\nko_fi: # Replace with a single Ko-fi username\ntidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel\ncommunity_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry\nliberapay: # Replace with a single Liberapay username\nissuehunt: # Replace with a single IssueHunt username\nlfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry\npolar: # Replace with a single Polar username\nbuy_me_a_coffee: John0n1\nthanks_dev: # Replace with a single thanks.dev username\ncustom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']\n"
},
{
"file_name": "customisation.md",
"relative_path": "docs/customisation.md",
"extension": ".md",
"size_bytes": 4966,
"content": "## Customisation hints\n\n- Extend `data/catalog/paths.csv` with new vendor fingerprints, CVE IDs, default credentials, and snapshot/stream templates.\n- Update `data/dictionaries/usernames.txt` and `data/dictionaries/passwords.txt` to broaden credential probing.\n- Swap in an alternate RTSP dictionary by editing `data/protocols/rtsp-url-brute.nse` or passing `rtsp-url-brute.urlfile=<path>` through the Nmap script arguments (see comments in the script).\n- Add vendor-specific dictionaries in `data/vendors/<vendor>/http-paths.txt` and `data/vendors/<vendor>/rtsp-paths.txt` using the `template|port|channel|stream|label` / `template|port|channel|stream|transport|label` formats.\n- Modes, timeouts, and credential limits are centralised in `scripts/core/mode-config.sh`.\n- Protocol heuristics for ONVIF/RTMP/HLS/WebRTC/SRT are implemented in `scripts/camsniff.sh` under `probe_additional_protocols`; adjust or extend them there.\n\n## IVRE Integration\n\nCamSniff includes full integration with [IVRE](https://ivre.rocks), an open-source network reconnaissance framework that stores scan results in MongoDB for advanced querying, analysis, and visualization.\n\n### Features\n\nThe IVRE integration provides:\n\n- **Fully automatic setup**: MongoDB and IVRE are installed and configured automatically when using `--extra ivre`\n- **Automated schema mapping**: Discovery data is automatically converted to IVRE's Nmap-compatible format\n- **Vendor enrichment**: MAC address-based vendor identification from `data/catalog/paths.csv`\n- **Credential tracking**: Successful authentication attempts are tagged and searchable\n- **Thumbnail references**: Links to captured camera snapshots are stored in host metadata\n- **CVE tracking**: Known vulnerabilities are associated with discovered cameras\n- **Protocol categorization**: Cameras are tagged by supported protocols (RTSP, ONVIF, CoAP, WebRTC, SRT)\n\n### Automatic Usage\n\nSimply add `--extra ivre` to any CamSniff scan:\n\n```bash\nsudo scripts/camsniff.sh --mode medium --extra ivre --yes\n```\n\nCamSniff will automatically:\n1. Check if IVRE is installed\n2. Install MongoDB if needed\n3. Create Python virtual environment\n4. Install IVRE Python packages\n5. Initialize IVRE databases\n6. Sync discovery results after the scan\n\nNo additional configuration is required!\n\n### Manual Operations\n\nThe unified IVRE manager handles all operations:\n\n```bash\n# Check IVRE status\nscripts/integrations/ivre-manager.sh check\n\n# Manual setup (if needed)\nsudo scripts/integrations/ivre-manager.sh setup\n\n# Ingest specific run\nscripts/integrations/ivre-manager.sh ingest dev/results/20251010T215139Z/discovery.json\n\n# Bulk ingest all historical runs\nscripts/integrations/ivre-manager.sh bulk-ingest\n\n# Show summary statistics\nscripts/integrations/ivre-manager.sh summary\n\n# Export results\nscripts/integrations/ivre-manager.sh export json > cameras.json\nscripts/integrations/ivre-manager.sh export csv > cameras.csv\n```\n\n### Querying IVRE Data\n\nUse the query helper for common analysis:\n\n```bash\n# Use the original query script for detailed analysis\nscripts/ivre-query.sh summary\nscripts/ivre-query.sh vendors\nscripts/ivre-query.sh credentials\nscripts/ivre-query.sh dashboard\n```\n\nOr access IVRE directly:\n\n```bash\nsource venv/bin/activate\n\n# Show all CamSniff discoveries\nivre scancli --category camsniff\n\n# Filter by vendor\nivre scancli --category vendor:hikvision\n\n# Show cameras with credentials\nivre scancli --category credentials-found\n\n# Export to JSON\nivre scancli --category camsniff --json > all_cameras.json\n```\n\n### IVRE Web Interface\n\nLaunch the web interface for interactive exploration:\n\n```bash\nscripts/ivre-query.sh web\n# Or directly:\nsource venv/bin/activate\nivre httpd\n```\n\nAccess at `http://localhost:8080` to view interactive maps, statistics, and detailed host information.\n\n### Schema Details\n\nCamSniff maps discovery data into IVRE with these fields:\n\n**Host-level scripts:**\n- `camsniff-summary`: Mode, network, sources, vendor, credentials, protocols\n- `camsniff-vendor`: Company, model, CVEs, credentials (if found)\n- `camsniff-protocols`: List of detected protocols (ONVIF, CoAP, etc.)\n- `camsniff-rtsp-responses`: RTSP probe results\n\n**Categories (tags):**\n- `camsniff`: All CamSniff hosts\n- `camsniff-mode:<name>`: Hosts discovered in specific mode\n- `vendor:<company>`: Hosts from specific vendor\n- `credentials-found`: Hosts with successful authentication\n\n**Credential structure:**\n```json\n{\n \"username\": \"admin\",\n \"password\": \"12345\",\n \"method\": \"rtsp\",\n \"rtsp_url\": \"rtsp://...\",\n \"http_url\": \"http://...\",\n \"thumbnail\": \"/path/to/snapshot.jpg\"\n}\n```\n\n### Troubleshooting\n\n**Check IVRE status:**\n```bash\nscripts/integrations/ivre-manager.sh check\n```\n\n**Re-setup IVRE:**\n```bash\nsudo scripts/integrations/ivre-manager.sh setup\n```\n\n**View sync logs:**\n```bash\ntail -f dev/results/*/logs/ivre-sync.log\n```\n\n**Clear all CamSniff data:**\n```bash\nsource venv/bin/activate\nivre scancli --category camsniff --delete\n```\n"
},
{
"file_name": "dev-helpers.md",
"relative_path": "docs/dev-helpers.md",
"extension": ".md",
"size_bytes": 806,
"content": "## Development helpers\n\nThe top-level `Makefile` bundles a few convenience targets:\n\n```bash\nmake build # dpkg-buildpackage -us -uc (Debian package build)\nmake clean # drop build artefacts and staging directories\nmake lint # shellcheck + bash -n across project scripts\nmake dev # run lint plus a smoke dpkg-buildpackage --dry-run\n```\n\nAll targets respect the repository layout, so you can iterate locally before publishing `.deb` builds.\n\nKey entrypoints in the tree:\n\n* `scripts/camsniff.sh` \u2014 orchestrator (call via `sudo`).\n* `scripts/core/` \u2014 mode/port profiles and shared knobs.\n* `scripts/setup/` \u2014 dependency/bootstrap helpers.\n* `scripts/probes/` \u2014 credential probe + SSDP/ONVIF helpers.\n* `scripts/tools/analyze.sh` \u2014 quick stats for `dev/results/<run>/`.\n"
},
{
"file_name": "rtsp-urls.txt",
"relative_path": "data/dictionaries/rtsp-urls.txt",
"extension": ".txt",
"size_bytes": 3510,
"content": "#!comment: The following dictionary contains a list of well-known RTSP URLs\n#!comment: used by common video surveillance equipment.\n/\n/0\n/0/video1\n/0/profile2/media.smp\n/1\n/1.AMP\n/1/1\n/1/1:1/main\n/1/2\n/1/cif\n/1/h264major\n/1/stream1\n/1/profile2/media.smp\n/11\n/12\n/4\n/CAM_ID.password.mp2\n/CH001.sdp\n/CH002.sdp\n/GetData.cgi\n/H264\n/HighResolutionVideo\n/HighResolutionvideo\n/Image.jpg\n/LiveChannel/0/media.smp\n/LiveChannel/1/media.smp\n/LowResolutionVideo\n/MJPEG.cgi\n/MediaInput/h264\n/MediaInput/h264/stream_1\n/MediaInput/mpeg4\n/ONVIF/MediaInput\n/ONVIF/channel1\n/PSIA/Streaming/channels/0?videoCodecType=H.264\n/PSIA/Streaming/channels/1\n/PSIA/Streaming/channels/1?videoCodecType=MPEG4\n/PSIA/Streaming/channels/h264\n/Possible\n/ROH/channel/11\n/Streaming/Channels/1\n/Streaming/Channels/101\n/Streaming/Channels/102\n/Streaming/Channels/103\n/Streaming/Channels/2\n/Streaming/Unicast/channels/101\n/Streaming/channels/101\n/Video?Codec=MPEG4&Width=720&Height=576&Fps=30\n/VideoInput/1/h264/1\n/access_code\n/access_name_for_stream_1_to_5\n/av0_0\n/av0_1\n/av2\n/avn=2\n/axis-media/media.amp\n/axis-media/media.amp?videocodec=h264&resolution=640x480\n/axis-media/media.amp?videocodec=h265\n/cam\n/cam/realmonitor\n/cam/realmonitor?channel=1&subtype=0\n/cam/realmonitor?channel=1&subtype=00\n/cam/realmonitor?channel=1&subtype=01\n/cam/realmonitor?channel=1&subtype=1\n/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif\n/cam0_0\n/cam0_1\n/cam1/h264\n/cam1/h264/multicast\n/cam1/mjpeg\n/cam1/mpeg4\n/cam1/onvif-h264\n/cam4/mpeg4\n/camera.stm\n/cgi-bin/viewer/video.jpg?resolution=640x480\n/ch0\n/ch0.h264\n/ch001.sdp\n/ch01.264\n/ch0_0.h264\n/ch0_unicast_firststream\n/ch0_unicast_secondstream\n/ch1/main/av_stream\n/ch1/sub/av_stream\n/channel1\n/dms.jpg\n/dms?nowprofileid=2\n/h264\n/h264.sdp\n/h264/ch1/main/av_stream\n/h264/ch1/sub/av_stream\n/h264/ch1/sub/\n/h264/media.amp\n/h264Preview_01_main\n/h264Preview_01_sub\n/h265Preview_01_main\n/h265Preview_01_sub\n/h264_vga.sdp\n/image.jpg\n/image.mpg\n/image/jpeg.cgi\n/img/media.sav\n/img/video.asf\n/img/video.sav\n/ioImage/1\n/ipcam.sdp\n/ipcam/stream.cgi?nowprofileid=2\n/ipcam_h264.sdp\n/jpg/image.jpg?size=3\n/live\n/live.sdp\n/live/av0\n/live/ch0\n/live/ch00_0\n/live/ch00_1\n/live/ch1\n/live/ch2\n/live/h264\n/live/h264/ch1\n/live/main\n/live/mpeg4\n/live/sub\n/live0.264\n/live1.264\n/live1.sdp\n/live2.sdp\n/live3.sdp\n/live_h264.sdp\n/live_mpeg4.sdp\n/livestream\n/livestream/\n/media\n/media.amp\n/media/media.amp\n/media/video1\n/media/video2\n/media/video3\n/medias1\n/mjpeg.cgi\n/mjpeg/media.smp\n/mobotix.mjpeg\n/mp4\n/mpeg4\n/mpeg4/1/media.amp\n/mpeg4/media.amp\n/mpeg4/media.amp?resolution=640x480\n/mpeg4/media.smp\n/mpeg4cif\n/mpeg4unicast\n/mpg4/rtsp.amp\n/multicaststream\n/multicast/stream0/mobotix.mjpeg\n/now.mp4\n/nph-h264.cgi\n/nphMpeg4/g726-640x\n/nphMpeg4/g726-640x480\n/nphMpeg4/nil-320x240\n/onvif-media/media.amp\n/onvif/live/2\n/onvif1\n/onvif2\n/onvif/profile1/media.smp\n/play1.sdp\n/play2.sdp\n/profile\n/profile1\n/profile2\n/profile3/media.smp\n/recognizer\n/rtpvideo1.sdp\n/rtsp_tunnel\n/rtsph264\n/rtsph2641080p\n/stream1\n/stream2\n/stream3\n/streaming/mjpeg\n/synthesizer\n/tcp/av0_0\n/ucast/11\n/unicast/c1/s0/live\n/unicast/c1/s1/live\n/user.pin.mp2\n/user_defined\n/video\n/video.3gp\n/video.cgi\n/video.cgi?resolution=VGA\n/video.cgi?resolution=vga\n/video.h264\n/video.mjpg\n/video.mp4\n/video.pro1\n/video.pro2\n/video.pro3\n/video/mjpg.cgi\n/video1\n/video1+audio1\n/video2.mjpg\n/videoMain\n/videoSub\n/videostream.asf\n/videostream.cgi\n/videostream.cgi?rate=0\n/videoinput_1:0/h264_1/onvif.stm\n/vis\n/wfov\n/user=admin_password=tlJwpbo6_channel=1_stream=0.sdp?real_stream"
},
{
"file_name": "http-paths.txt",
"relative_path": "data/dictionaries/http-paths.txt",
"extension": ".txt",
"size_bytes": 4217,
"content": "# template|port|channel|stream|label\nhttp://{{username}}:{{password}}@{{ip_address}}/snapshot.jpg|80|1|0|generic snapshot\nhttp://{{username}}:{{password}}@{{ip_address}}/image.jpg|80|1|0|generic image\nhttp://{{username}}:{{password}}@{{ip_address}}/jpg/image.jpg|80|1|0|grandstream image\nhttp://{{username}}:{{password}}@{{ip_address}}/cgi-bin/snapshot.cgi|80|1|0|generic cgi snapshot\nhttp://{{username}}:{{password}}@{{ip_address}}/cgi-bin/api.cgi?cmd=Snap&channel={{channel}}&rs={{stream}}|80|1|0|reolink api\nhttp://{{username}}:{{password}}@{{ip_address}}/cgi-bin/snapshot.cgi?channel={{channel}}&subtype={{stream}}|80|1|0|dahua subtype snapshot\nhttp://{{username}}:{{password}}@{{ip_address}}/Streaming/channels/{{channel}}01/picture|80|1|0|hikvision legacy snapshot\nhttp://{{username}}:{{password}}@{{ip_address}}/ISAPI/Streaming/channels/{{channel}}01/picture|80|1|0|hikvision isapi snapshot\nhttp://{{username}}:{{password}}@{{ip_address}}/axis-cgi/jpg/image.cgi|80|1|0|axis jpg image\nhttp://{{username}}:{{password}}@{{ip_address}}/cgi-bin/viewer/video.jpg|80|1|0|vivotek viewer\nhttp://{{username}}:{{password}}@{{ip_address}}/webcapture.jpg?command=snap&channel={{channel}}|80|1|0|swann webcapture\nhttp://{{username}}:{{password}}@{{ip_address}}/image/jpeg.cgi|80|1|0|panasonic/dlink jpeg\nhttp://{{username}}:{{password}}@{{ip_address}}/GetData.cgi?CH={{channel}}&Codec=mjpeg|80|1|0|wirepath mjpeg\nhttps://{{username}}:{{password}}@{{ip_address}}/cgi-bin/snapshot.cgi|443|1|0|https snapshot\nhttp://{{username}}:{{password}}@{{ip_address}}/video.jpg|80|1|0|amcrest/generic snapshot\nhttp://{{username}}:{{password}}@{{ip_address}}/onvif-http/snapshot?channel={{channel}}&stream={{stream}}|80|1|0|onvif snapshot\nhttp://{{username}}:{{password}}@{{ip_address}}/snap.jpg|80|1|0|bosch snapshot\nhttp://{{username}}:{{password}}@{{ip_address}}/record/current.jpg|80|1|0|mobotix current\nhttp://{{username}}:{{password}}@{{ip_address}}/cgi-bin/faststream.jpg|80|1|0|mobotix faststream\nhttp://{{username}}:{{password}}@{{ip_address}}/LAPI/V1.0/Channels/{{channel}}/Media/Video/Streams/{{stream}}/Snapshot|80|1|0|uniview lapi snapshot\nhttp://{{username}}:{{password}}@{{ip_address}}/images/snapshot.jpg|80|1|0|uniview legacy\nhttp://{{username}}:{{password}}@{{ip_address}}/jpeg|80|1|0|pelco sarix jpeg\nhttp://{{username}}:{{password}}@{{ip_address}}/jpeg/pull|80|1|0|pelco sarix pull\nhttp://{{username}}:{{password}}@{{ip_address}}/snapshot.jpg?user={{username}}&pwd={{password}}&strm={{channel}}|80|1|0|avtech snapshot\nhttp://{{username}}:{{password}}@{{ip_address}}/cgi-bin/guest/Video.cgi?media=JPEG|80|1|0|geovision guest\nhttp://{{username}}:{{password}}@{{ip_address}}/cam{{channel}}.jpg|80|1|0|geovision cam\nhttp://{{username}}:{{password}}@{{ip_address}}/cgi-bin/mjpeg|80|1|0|basler mjpeg\nhttp://{{username}}:{{password}}@{{ip_address}}/cgi-bin/media.cgi?action=getSnapshot|80|1|0|brickcom snapshot\nhttp://{{username}}:{{password}}@{{ip_address}}/cgi-bin/CGIProxy.fcgi?cmd=snapPicture&usr={{username}}&pwd={{password}}|80|1|0|foscam cgi proxy\nhttp://{{username}}:{{password}}@{{ip_address}}/oneshotimage.jpg|80|1|0|sony oneshot\nhttp://{{username}}:{{password}}@{{ip_address}}/img/snapshot.cgi?size=3|80|1|0|cisco snapshot\nhttp://{{username}}:{{password}}@{{ip_address}}/image|80|1|0|arecont/generic image\nhttp://{{username}}:{{password}}@{{ip_address}}/tmpfs/auto.jpg|80|1|0|zkteco/generic\nhttp://{{username}}:{{password}}@{{ip_address}}/api/v1/snap.cgi?chn=0|80|1|0|wansview api\nhttp://{{username}}:{{password}}@{{ip_address}}/cgi-bin/net_jpeg.cgi?ch={{channel}}|80|1|0|wansview legacy\nhttp://{{username}}:{{password}}@{{ip_address}}/snap.jpeg|80|1|0|ubiquiti anonymous\nhttp://{{username}}:{{password}}@{{ip_address}}/cgi-bin/video.cgi?msubmenu=jpg|80|1|0|hanwha/samsung\nhttp://{{username}}:{{password}}@{{ip_address}}/goform/video2|80|1|0|trendnet/linksys\nhttp://{{username}}:{{password}}@{{ip_address}}/cgi-bin/jpg/image.cgi|80|1|0|trendnet jpg\nhttp://{{username}}:{{password}}@{{ip_address}}/-wvhttp-01-/GetOneShot?frame_id=1|80|1|0|canon vb\nhttp://{{username}}:{{password}}@{{ip_address}}/image/jpeg.cgi?profileid=1|80|1|0|dlink profile\nhttp://{{username}}:{{password}}@{{ip_address}}/dms.jpg|80|1|0|dlink dms"
},
{
"file_name": "passwords.txt",
"relative_path": "data/dictionaries/passwords.txt",
"extension": ".txt",
"size_bytes": 907,
"content": "admin\n12345\n123456\n12345678\npassword\nusername\nroot\ncamera\n000000\n1111\n1234\n4321\n9999\nubnt\npass\ndefault\nadmin123\nsupport\nchangeme\nsecurity\nsupervisor\nsystem\nuser\nguest\n123456789\n1234567890\n888888\n666666\n777777\n00000000\nqwerty\nletmein\nadmin1234\nadminadmin\n123qwe\n1q2w3e4r\npassw0rd\nP@ssw0rd\npassword1\npassword123\ncamera123\nguest123\nmonitor\nsurveillance\nstream\nonvif\nvision\n111111\n1111111\n222222\n555555\n123123\n1234567\n54321\n123456789abc\n1234567890a\na1234567\nvizxv\nxc3511\nmeinsm\nservice\ntechnician\ninstaller\ninstall\nsetup\nconfig\noperator\nmanage\nmanager\nrealtime\nupgrade\nipcam\nipcamera\ncctv\ndvr\nnvr\nhvr\nxvr\nhikvision\ndahua\nfoscam\naxis\nsamsung\npanasonic\npolycom\ncisco\njvc\nblue\nubiquiti\nms1234\nikwb\n7ujMko0admin\ntlJwpbo6\nadmin!123\nAdmin123\nAdmin@123\nPassword123\n123456aA\n1qaz2wsx\nqazwsx\nzxcvbn\nasdfgh\n147258\n2580\n0000\nadmin01\nadmin888\nwebadmin\nsysadmin\nmaster\nsuperuser\npass@1234\nklv123\nklv1234\njido\nsystem\nactadmin"
},
{
"file_name": "usernames.txt",
"relative_path": "data/dictionaries/usernames.txt",
"extension": ".txt",
"size_bytes": 852,
"content": "admin\nAdmin\nADMIN\nadministrator\nAdministrator\nadmin1\nadmin01\nadmin123\nadmin888\nwebadmin\nsysadmin\nroot\nRoot\nROOT\nsuperuser\nsuperadmin\nsuper\nrootadmin\nmaster\nsystem\nsys\nservice\nservice1\nservicetech\nsupport\nsupport1\ntech\ntechsupport\ntechnician\ninstaller\ninstall\nmaintenance\nsupervisor\nsupervisor1\nmanager\nman\noperator\noperator1\nviewer\nview\nmonitor\nsecurity\nguard\nguest\nguest1\nuser\nUser\nuser1\nuser01\ndefault\npublic\nanonymous\ndemo\ntest\ntester\ndebug\nshell\nbin\ndaemon\nftp\nftpuser\ntelnet\nubnt\nubiquiti\nhik\nhikvision\ndahua\nvizxv\namcrest\nfoscam\naxis\npolycom\ncisco\nrealtek\nbosch\nsanyo\nsamsung\njvc\nsony\nmobotix\nsynnet\nadv\nkiosk\ncamera\ncam\nipcam\nipcamera\nwebcam\ncctv\ndvr\nnvr\nhvr\nxvr\nonvif\nvideo\nstream\nlive\nmedia\nav\n666666\n888888\n1111\n1234\n1000\n1001\n2000\n12345\n123456\nudp\ntcp\nhttp\nmac\nmonitor1\nspy\nowner\nmother\nfather\nmeinsm\n3xLogic\n8888\n6666\nadmin2\nuser2\noperator2"
},
{
"file_name": "cves.json",
"relative_path": "data/catalog/cves.json",
"extension": ".json",
"size_bytes": 14311,
"content": "[\n {\n \"id\": \"CVE-2025-60855\",\n \"severity\": \"Critical\",\n \"cvss\": 9.8,\n \"summary\": \"Reolink Video Doorbell Wi-Fi (DB_566128M5MP_W) performs insufficient validation of firmware update signatures, allowing remote attackers to upload malicious images and achieve root RCE.\",\n \"references\": [\"https://nvd.nist.gov/vuln/detail/CVE-2025-60855\"]\n },\n {\n \"id\": \"CVE-2025-60856\",\n \"severity\": \"High\",\n \"cvss\": 7.6,\n \"summary\": \"Reolink Video Doorbell Wi-Fi exposes an unsecured UART serial console that grants direct root shell access without authentication to attackers with physical access.\",\n \"references\": [\"https://nvd.nist.gov/vuln/detail/CVE-2025-60856\"]\n },\n {\n \"id\": \"CVE-2025-31700\",\n \"severity\": \"Critical\",\n \"cvss\": 9.8,\n \"summary\": \"Dahua ONVIF request handler stack-based buffer overflow allowing unauthenticated remote code execution (RCE) via crafted packets.\",\n \"references\": [\"https://nvd.nist.gov/vuln/detail/CVE-2025-31700\"]\n },\n {\n \"id\": \"CVE-2025-39247\",\n \"severity\": \"Critical\",\n \"cvss\": 9.8,\n \"summary\": \"Hikvision HikCentral Professional access control bypass allowing unauthenticated remote attackers to gain full administrative privileges.\",\n \"references\": [\"https://nvd.nist.gov/vuln/detail/CVE-2025-39247\"]\n },\n {\n \"id\": \"CVE-2025-30023\",\n \"severity\": \"Critical\",\n \"cvss\": 9.0,\n \"summary\": \"Axis Camera Station Pro and Device Manager critical remote code execution (RCE) vulnerability via the proprietary 'Remoting' protocol.\",\n \"references\": [\"https://nvd.nist.gov/vuln/detail/CVE-2025-30023\"]\n },\n {\n \"id\": \"CVE-2025-34065\",\n \"severity\": \"Critical\",\n \"cvss\": 9.8,\n \"summary\": \"AVTECH IP cameras and NVRs authentication bypass in the 'streamd' web server via URL manipulation (e.g., /nobody/..).\",\n \"references\": [\"https://nvd.nist.gov/vuln/detail/CVE-2025-34065\"]\n },\n {\n \"id\": \"CVE-2025-34067\",\n \"severity\": \"Critical\",\n \"cvss\": 10.0,\n \"summary\": \"Hikvision Integrated Security Management Platform deserialization vulnerability via Fastjson, leading to unauthenticated RCE.\",\n \"references\": [\"https://nvd.nist.gov/vuln/detail/CVE-2025-34067\"]\n },\n {\n \"id\": \"CVE-2025-4975\",\n \"severity\": \"High\",\n \"cvss\": 8.8,\n \"summary\": \"TP-Link Tapo Android app contains a privilege escalation vulnerability where interacting with a 'low battery' notification on a shared device grants full power control permissions.\",\n \"references\": [\"https://nvd.nist.gov/vuln/detail/CVE-2025-4975\"]\n },\n {\n \"id\": \"CVE-2025-1099\",\n \"severity\": \"High\",\n \"cvss\": 7.5,\n \"summary\": \"TP-Link Tapo C500 Wi-Fi cameras contain a hardcoded RSA private key in the firmware, enabling man-in-the-middle (MitM) attacks against device communications.\",\n \"references\": [\"https://nvd.nist.gov/vuln/detail/CVE-2025-1099\"]\n },\n {\n \"id\": \"CVE-2025-9383\",\n \"severity\": \"Critical\",\n \"cvss\": 9.8,\n \"summary\": \"FNKvision Y215 CCTV Camera critical weakness in /etc/passwd handling allowing unauthenticated root access.\",\n \"references\": [\"https://nvd.nist.gov/vuln/detail/CVE-2025-9383\"]\n },\n {\n \"id\": \"CVE-2025-1316\",\n \"severity\": \"Critical\",\n \"cvss\": 9.8,\n \"summary\": \"Edimax IC-7100 and related IoT devices allow unauthenticated remote code execution, actively exploited by Mirai botnets.\",\n \"references\": [\"https://nvd.nist.gov/vuln/detail/CVE-2025-1316\"]\n },\n {\n \"id\": \"CVE-2025-5572\",\n \"severity\": \"Critical\",\n \"cvss\": 8.7,\n \"summary\": \"D-Link DCS-932L stack-based buffer overflow via setSystemEmail parameter allows unauthenticated RCE.\",\n \"references\": [\"https://nvd.nist.gov/vuln/detail/CVE-2025-5572\"]\n },\n {\n \"id\": \"CVE-2024-8956\",\n \"severity\": \"Critical\",\n \"cvss\": 9.1,\n \"summary\": \"PTZOptics camera authentication bypass allows unauthenticated remote attackers to overwrite configuration and gain control.\",\n \"references\": [\"https://nvd.nist.gov/vuln/detail/CVE-2024-8956\"]\n },\n {\n \"id\": \"CVE-2024-6476\",\n \"severity\": \"Medium\",\n \"cvss\": 4.2,\n \"summary\": \"Axis Camera Station Pro privilege escalation via file deletion redirect during service restart.\",\n \"references\": [\"https://nvd.nist.gov/vuln/detail/CVE-2024-6476\"]\n },\n {\n \"id\": \"CVE-2023-28478\",\n \"severity\": \"Critical\",\n \"cvss\": 9.8,\n \"summary\": \"TP-Link Kasa EC70 Spot Pan Tilt cameras contain a stack-based buffer overflow in the authentication header, allowing unauthenticated remote code execution as root.\",\n \"references\": [\"https://nvd.nist.gov/vuln/detail/CVE-2023-28478\"]\n },\n {\n \"id\": \"CVE-2023-31994\",\n \"severity\": \"High\",\n \"cvss\": 7.5,\n \"summary\": \"Hanwha Vision (Samsung) cameras (A/X/P series) are vulnerable to Denial of Service (DoS) via empty UDP packets sent to the WS-Discovery service.\",\n \"references\": [\"https://nvd.nist.gov/vuln/detail/CVE-2023-31994\"]\n },\n {\n \"id\": \"CVE-2023-47353\",\n \"severity\": \"High\",\n \"cvss\": 8.8,\n \"summary\": \"Imou GO (Dahua) Android app arbitrary file download vulnerability.\",\n \"references\": [\"https://nvd.nist.gov/vuln/detail/CVE-2023-47353\"]\n },\n {\n \"id\": \"CVE-2023-51625\",\n \"severity\": \"High\",\n \"cvss\": 8.0,\n \"summary\": \"D-Link DCS-8300LHV2 ONVIF command injection via malicious XML timezone parameters.\",\n \"references\": [\"https://nvd.nist.gov/vuln/detail/CVE-2023-51625\"]\n },\n {\n \"id\": \"CVE-2023-26609\",\n \"severity\": \"High\",\n \"cvss\": 7.2,\n \"summary\": \"ABUS TVIP cameras allow RCE via /cgi-bin/mft/wireless_mft.\",\n \"references\": [\"https://nvd.nist.gov/vuln/detail/CVE-2023-26609\"]\n },\n {\n \"id\": \"CVE-2023-39509\",\n \"severity\": \"High\",\n \"cvss\": 7.2,\n \"summary\": \"Bosch IP cameras command injection for authenticated administrators.\",\n \"references\": [\"https://nvd.nist.gov/vuln/detail/CVE-2023-39509\"]\n },\n {\n \"id\": \"CVE-2022-30525\",\n \"severity\": \"Critical\",\n \"cvss\": 9.8,\n \"summary\": \"Ubiquiti Edge devices allow remote code execution through crafted HTTP requests.\",\n \"references\": [\"https://nvd.nist.gov/vuln/detail/CVE-2022-30525\"]\n },\n {\n \"id\": \"CVE-2022-37255\",\n \"severity\": \"Critical\",\n \"cvss\": 9.8,\n \"summary\": \"TP-Link Tapo C310 cameras (firmware 1.3.0) use hardcoded RTSP credentials, allowing any unauthenticated network user to view the live video feed.\",\n \"references\": [\"https://nvd.nist.gov/vuln/detail/CVE-2022-37255\"]\n },\n {\n \"id\": \"CVE-2022-21199\",\n \"severity\": \"High\",\n \"cvss\": 7.5,\n \"summary\": \"Reolink RLC-410W cameras allow unauthenticated information disclosure via the 'netserver' service, leaking device configuration details.\",\n \"references\": [\"https://nvd.nist.gov/vuln/detail/CVE-2022-21199\"]\n },\n {\n \"id\": \"CVE-2022-27145\",\n \"severity\": \"High\",\n \"cvss\": 8.8,\n \"summary\": \"Vivotek cameras allow remote command injection through crafted CGI parameters.\",\n \"references\": [\"https://nvd.nist.gov/vuln/detail/CVE-2022-27145\"]\n },\n {\n \"id\": \"CVE-2022-38700\",\n \"severity\": \"High\",\n \"cvss\": 8.8,\n \"summary\": \"OpenHarmony OS (used in various smart cameras) authentication bypass in multimedia subsystem.\",\n \"references\": [\"https://app.opencve.io/cve/CVE-2022-38700\"]\n },\n {\n \"id\": \"CVE-2021-36260\",\n \"severity\": \"Critical\",\n \"cvss\": 9.8,\n \"summary\": \"Hikvision cameras and NVRs command injection vulnerability in the web server component.\",\n \"references\": [\"https://nvd.nist.gov/vuln/detail/CVE-2021-36260\"]\n },\n {\n \"id\": \"CVE-2021-28372\",\n \"severity\": \"Critical\",\n \"cvss\": 9.6,\n \"summary\": \"ThroughTek Kalay P2P SDK remote code execution vulnerability affects millions of IoT devices (Wyze, OEM cams).\",\n \"references\": [\"https://nvd.nist.gov/vuln/detail/CVE-2021-28372\"]\n },\n {\n \"id\": \"CVE-2021-40127\",\n \"severity\": \"High\",\n \"cvss\": 8.1,\n \"summary\": \"Reolink IP cameras allow authentication bypass via predictable session tokens.\",\n \"references\": [\"https://nvd.nist.gov/vuln/detail/CVE-2021-40127\"]\n },\n {\n \"id\": \"CVE-2021-33044\",\n \"severity\": \"High\",\n \"cvss\": 8.8,\n \"summary\": \"Uniview NVR allows remote code execution via crafted RPC call.\",\n \"references\": [\"https://nvd.nist.gov/vuln/detail/CVE-2021-33044\"]\n },\n {\n \"id\": \"CVE-2020-25506\",\n \"severity\": \"High\",\n \"cvss\": 9.1,\n \"summary\": \"Dahua cameras allow remote command execution via crafted ONVIF requests.\",\n \"references\": [\"https://nvd.nist.gov/vuln/detail/CVE-2020-25506\"]\n },\n {\n \"id\": \"CVE-2020-8190\",\n \"severity\": \"High\",\n \"cvss\": 8.8,\n \"summary\": \"Ubiquiti UniFi Video cameras vulnerable to authentication bypass on the management API.\",\n \"references\": [\"https://nvd.nist.gov/vuln/detail/CVE-2020-8190\"]\n },\n {\n \"id\": \"CVE-2020-13545\",\n \"severity\": \"High\",\n \"cvss\": 8.1,\n \"summary\": \"Hanwha Techwin Wisenet devices allow stack-based buffer overflow via crafted HTTP request.\",\n \"references\": [\"https://nvd.nist.gov/vuln/detail/CVE-2020-13545\"]\n },\n {\n \"id\": \"CVE-2020-25169\",\n \"severity\": \"High\",\n \"cvss\": 7.5,\n \"summary\": \"Reolink P2P cameras do not sufficiently protect data transfers, allowing attackers to reconstruct cleartext video/audio streams from captured P2P traffic.\",\n \"references\": [\"https://nvd.nist.gov/vuln/detail/CVE-2020-25169\"]\n },\n {\n \"id\": \"CVE-2020-19054\",\n \"severity\": \"High\",\n \"cvss\": 8.6,\n \"summary\": \"Foscam cameras vulnerable to stack overflow via RTSP DESCRIBE command.\",\n \"references\": [\"https://nvd.nist.gov/vuln/detail/CVE-2020-19054\"]\n },\n {\n \"id\": \"CVE-2020-10964\",\n \"severity\": \"High\",\n \"cvss\": 8.1,\n \"summary\": \"Uniview devices vulnerable to authentication bypass in web management interface.\",\n \"references\": [\"https://nvd.nist.gov/vuln/detail/CVE-2020-10964\"]\n },\n {\n \"id\": \"CVE-2020-12271\",\n \"severity\": \"Critical\",\n \"cvss\": 9.8,\n \"summary\": \"Geovision GV-Control Center stack-based buffer overflow allowing RCE.\",\n \"references\": [\"https://nvd.nist.gov/vuln/detail/CVE-2020-12271\"]\n },\n {\n \"id\": \"CVE-2019-15223\",\n \"severity\": \"High\",\n \"cvss\": 8.8,\n \"summary\": \"Axis network cameras allow remote code execution due to insufficient sanitisation of the action parameter.\",\n \"references\": [\"https://nvd.nist.gov/vuln/detail/CVE-2019-15223\"]\n },\n {\n \"id\": \"CVE-2019-9483\",\n \"severity\": \"Critical\",\n \"cvss\": 9.1,\n \"summary\": \"Amazon Ring Video Doorbell Pro mishandles encryption during setup, allowing nearby attackers to intercept Wi-Fi credentials and spoof video feeds.\",\n \"references\": [\"https://nvd.nist.gov/vuln/detail/CVE-2019-9483\"]\n },\n {\n \"id\": \"CVE-2019-5035\",\n \"severity\": \"High\",\n \"cvss\": 8.8,\n \"summary\": \"Google Nest Cam IQ Indoor (Weave protocol) allows brute-forcing of the pairing code, potentially giving an attacker full control over the device.\",\n \"references\": [\"https://nvd.nist.gov/vuln/detail/CVE-2019-5035\"]\n },\n {\n \"id\": \"CVE-2019-3949\",\n \"severity\": \"High\",\n \"cvss\": 7.6,\n \"summary\": \"Arlo Base Stations (VMB4000/5000) lack sufficient physical protection on the UART interface, allowing attackers with physical access to obtain a root shell.\",\n \"references\": [\"https://nvd.nist.gov/vuln/detail/CVE-2019-3949\"]\n },\n {\n \"id\": \"CVE-2019-3950\",\n \"severity\": \"High\",\n \"cvss\": 8.8,\n \"summary\": \"Arlo Base Stations expose a 'passthru' API endpoint that allows authenticated users to upload arbitrary files, leading to potential code execution.\",\n \"references\": [\"https://nvd.nist.gov/vuln/detail/CVE-2019-3950\"]\n },\n {\n \"id\": \"CVE-2019-3948\",\n \"severity\": \"High\",\n \"cvss\": 9.8,\n \"summary\": \"Multiple Dahua OEM products allow remote command execution due to improper authentication.\",\n \"references\": [\"https://nvd.nist.gov/vuln/detail/CVE-2019-3948\"]\n },\n {\n \"id\": \"CVE-2019-12223\",\n \"severity\": \"High\",\n \"cvss\": 7.8,\n \"summary\": \"Hanwha Techwin (Samsung) NVRs allow a system crash and reboot (DoS) by submitting a username exceeding 117 characters.\",\n \"references\": [\"https://nvd.nist.gov/vuln/detail/CVE-2019-12223\"]\n },\n {\n \"id\": \"CVE-2018-6298\",\n \"severity\": \"Critical\",\n \"cvss\": 10.0,\n \"summary\": \"Hanwha Techwin (Samsung) SmartCam devices allow remote code execution with root privileges due to improper input validation in the media server.\",\n \"references\": [\"https://nvd.nist.gov/vuln/detail/CVE-2018-6298\"]\n },\n {\n \"id\": \"CVE-2018-6299\",\n \"severity\": \"High\",\n \"cvss\": 7.5,\n \"summary\": \"Hanwha Techwin (Samsung) SmartCam devices allow authentication bypass, enabling attackers to register new administrative accounts without credentials.\",\n \"references\": [\"https://nvd.nist.gov/vuln/detail/CVE-2018-6299\"]\n },\n {\n \"id\": \"CVE-2018-10660\",\n \"severity\": \"High\",\n \"cvss\": 8.8,\n \"summary\": \"Axis Camera Station and device firmware vulnerable to directory traversal allowing arbitrary file read.\",\n \"references\": [\"https://nvd.nist.gov/vuln/detail/CVE-2018-10660\"]\n },\n {\n \"id\": \"CVE-2018-9995\",\n \"severity\": \"Critical\",\n \"cvss\": 9.8,\n \"summary\": \"TBK/Novo/Many-OEM DVRs authentication bypass via Cookie: uid=admin.\",\n \"references\": [\"https://nvd.nist.gov/vuln/detail/CVE-2018-9995\"]\n },\n {\n \"id\": \"CVE-2017-7921\",\n \"severity\": \"High\",\n \"cvss\": 8.8,\n \"summary\": \"Hikvision devices (and LaView/Annke OEMs) expose backdoor credentials allowing unauthenticated remote access.\",\n \"references\": [\"https://nvd.nist.gov/vuln/detail/CVE-2017-7921\"]\n },\n {\n \"id\": \"CVE-2017-8229\",\n \"severity\": \"High\",\n \"cvss\": 8.8,\n \"summary\": \"Amcrest cameras expose telnet interface with hardcoded credentials allowing root access.\",\n \"references\": [\"https://nvd.nist.gov/vuln/detail/CVE-2017-8229\"]\n },\n {\n \"id\": \"CVE-2017-9763\",\n \"severity\": \"Critical\",\n \"cvss\": 9.8,\n \"summary\": \"Grandstream cameras contain hidden telnet backdoor credentials enabling full compromise.\",\n \"references\": [\"https://nvd.nist.gov/vuln/detail/CVE-2017-9763\"]\n },\n {\n \"id\": \"CVE-2015-2884\",\n \"severity\": \"Critical\",\n \"cvss\": 9.8,\n \"summary\": \"Vivotek (and LaView OEM) cameras contain a buffer overflow in the RTSP service, allowing remote attackers to execute arbitrary code via long strings.\",\n \"references\": [\"https://nvd.nist.gov/vuln/detail/CVE-2015-2884\"]\n }\n]"
},
{
"file_name": "example-targets.json",
"relative_path": "data/examples/example-targets.json",
"extension": ".json",
"size_bytes": 81,
"content": "{\n \"targets\": [\n \"192.168.1.0/24\",\n \"10.0.0.1\",\n \"172.16.0.0/28\"\n ]\n}\n"
},
{
"file_name": "example-targets.txt",
"relative_path": "data/examples/example-targets.txt",
"extension": ".txt",
"size_bytes": 213,
"content": "# Example target file for CamSniff\n# One IP address or CIDR range per line\n# Lines starting with # are comments\n\n# Local network scan\n192.168.1.0/24\n\n# Specific IP address\n10.0.0.1\n\n# Another subnet\n172.16.0.0/28\n"
},
{
"file_name": "README.md",
"relative_path": "data/vendors/README.md",
"extension": ".md",
"size_bytes": 588,
"content": "Vendor dictionaries\n===================\n\nEach vendor directory can include two optional files:\n\n- `http-paths.txt` for HTTP snapshot templates\n- `rtsp-paths.txt` for RTSP stream templates\n\nFormat\n------\n\nHTTP entries:\n\n```\ntemplate|port|channel|stream|label\n```\n\nRTSP entries:\n\n```\ntemplate|port|channel|stream|transport|label\n```\n\nTemplates may include `{{ip_address}}`, `{{username}}`, `{{password}}`,\n`{{port}}`, `{{channel}}`, and `{{stream}}`.\n\nNotes\n-----\n\n- Keep lists short and high-signal.\n- Prefer paths confirmed by vendor docs or field testing.\n- Avoid including credentials.\n"
},
{
"file_name": "rtsp-paths.txt",
"relative_path": "data/vendors/axis/rtsp-paths.txt",
"extension": ".txt",
"size_bytes": 333,
"content": "rtsp://{{username}}:{{password}}@{{ip_address}}:{{port}}/axis-media/media.amp|554|1|0|tcp|axis-media\nrtsp://{{username}}:{{password}}@{{ip_address}}:{{port}}/axis-media/media.amp?videocodec=h264|554|1|0|tcp|axis-h264\nrtsp://{{username}}:{{password}}@{{ip_address}}:{{port}}/axis-media/media.amp?videocodec=h265|554|1|0|tcp|axis-h265\n"
},
{
"file_name": "http-paths.txt",
"relative_path": "data/vendors/axis/http-paths.txt",
"extension": ".txt",
"size_bytes": 318,
"content": "http://{{username}}:{{password}}@{{ip_address}}:{{port}}/axis-cgi/jpg/image.cgi|80|1|0|axis-image\nhttp://{{username}}:{{password}}@{{ip_address}}:{{port}}/axis-cgi/mjpg/video.cgi|80|1|0|axis-mjpeg\nhttp://{{username}}:{{password}}@{{ip_address}}:{{port}}/axis-cgi/jpg/image.cgi?resolution=640x480|80|1|0|axis-image-640\n"
},
{
"file_name": "rtsp-paths.txt",
"relative_path": "data/vendors/avigilon/rtsp-paths.txt",
"extension": ".txt",
"size_bytes": 291,
"content": "rtsp://{{username}}:{{password}}@{{ip_address}}:{{port}}/defaultPrimary|554|1|0|tcp|default-primary\nrtsp://{{username}}:{{password}}@{{ip_address}}:{{port}}/defaultSecondary|554|1|1|tcp|default-secondary\nrtsp://{{username}}:{{password}}@{{ip_address}}:{{port}}/live.sdp|554|1|0|tcp|live-sdp\n"
},
{
"file_name": "http-paths.txt",
"relative_path": "data/vendors/avigilon/http-paths.txt",
"extension": ".txt",
"size_bytes": 244,
"content": "http://{{username}}:{{password}}@{{ip_address}}:{{port}}/snap.jpg|80|1|0|snap\nhttp://{{username}}:{{password}}@{{ip_address}}:{{port}}/snapshot.jpg|80|1|0|snapshot\nhttp://{{username}}:{{password}}@{{ip_address}}:{{port}}/image.jpg|80|1|0|image\n"
},
{
"file_name": "rtsp-paths.txt",
"relative_path": "data/vendors/bosch/rtsp-paths.txt",
"extension": ".txt",
"size_bytes": 269,
"content": "rtsp://{{username}}:{{password}}@{{ip_address}}:{{port}}/rtsp_tunnel|554|1|0|tcp|rtsp-tunnel\nrtsp://{{username}}:{{password}}@{{ip_address}}:{{port}}/live.sdp|554|1|0|tcp|live-sdp\nrtsp://{{username}}:{{password}}@{{ip_address}}:{{port}}/video.sdp|554|1|0|tcp|video-sdp\n"
},
{
"file_name": "http-paths.txt",
"relative_path": "data/vendors/bosch/http-paths.txt",
"extension": ".txt",
"size_bytes": 244,
"content": "http://{{username}}:{{password}}@{{ip_address}}:{{port}}/snap.jpg|80|1|0|snap\nhttp://{{username}}:{{password}}@{{ip_address}}:{{port}}/snapshot.jpg|80|1|0|snapshot\nhttp://{{username}}:{{password}}@{{ip_address}}:{{port}}/image.jpg|80|1|0|image\n"
},
{
"file_name": "rtsp-paths.txt",
"relative_path": "data/vendors/sony/rtsp-paths.txt",
"extension": ".txt",
"size_bytes": 277,
"content": "rtsp://{{username}}:{{password}}@{{ip_address}}:{{port}}/media/video1|554|1|0|tcp|media-video1\nrtsp://{{username}}:{{password}}@{{ip_address}}:{{port}}/media/video2|554|1|1|tcp|media-video2\nrtsp://{{username}}:{{password}}@{{ip_address}}:{{port}}/live.sdp|554|1|0|tcp|live-sdp\n"
},
{
"file_name": "http-paths.txt",
"relative_path": "data/vendors/sony/http-paths.txt",
"extension": ".txt",
"size_bytes": 254,
"content": "http://{{username}}:{{password}}@{{ip_address}}:{{port}}/image.jpg|80|1|0|image\nhttp://{{username}}:{{password}}@{{ip_address}}:{{port}}/snapshot.jpg|80|1|0|snapshot\nhttp://{{username}}:{{password}}@{{ip_address}}:{{port}}/image/jpeg.cgi|80|1|0|jpeg-cgi\n"
},
{
"file_name": "rtsp-paths.txt",
"relative_path": "data/vendors/geovision/rtsp-paths.txt",
"extension": ".txt",
"size_bytes": 263,
"content": "rtsp://{{username}}:{{password}}@{{ip_address}}:{{port}}/live/av0|554|1|0|tcp|live-av0\nrtsp://{{username}}:{{password}}@{{ip_address}}:{{port}}/live/ch0|554|1|0|tcp|live-ch0\nrtsp://{{username}}:{{password}}@{{ip_address}}:{{port}}/live/main|554|1|0|tcp|live-main\n"
},
{
"file_name": "http-paths.txt",
"relative_path": "data/vendors/geovision/http-paths.txt",
"extension": ".txt",
"size_bytes": 268,
"content": "http://{{username}}:{{password}}@{{ip_address}}:{{port}}/Image.jpg|80|1|0|image\nhttp://{{username}}:{{password}}@{{ip_address}}:{{port}}/jpeg/image.jpg|80|1|0|jpeg-image\nhttp://{{username}}:{{password}}@{{ip_address}}:{{port}}/cgi-bin/snapshot.cgi|80|1|0|snapshot-cgi\n"
},
{
"file_name": "rtsp-paths.txt",
"relative_path": "data/vendors/vivotek/rtsp-paths.txt",
"extension": ".txt",
"size_bytes": 265,
"content": "rtsp://{{username}}:{{password}}@{{ip_address}}:{{port}}/live.sdp|554|1|0|tcp|live-sdp\nrtsp://{{username}}:{{password}}@{{ip_address}}:{{port}}/live1.sdp|554|1|0|tcp|live1-sdp\nrtsp://{{username}}:{{password}}@{{ip_address}}:{{port}}/live2.sdp|554|1|1|tcp|live2-sdp\n"
},
{
"file_name": "http-paths.txt",
"relative_path": "data/vendors/vivotek/http-paths.txt",
"extension": ".txt",
"size_bytes": 309,
"content": "http://{{username}}:{{password}}@{{ip_address}}:{{port}}/cgi-bin/viewer/video.jpg|80|1|0|viewer-jpg\nhttp://{{username}}:{{password}}@{{ip_address}}:{{port}}/cgi-bin/viewer/video.jpg?resolution=640x480|80|1|0|viewer-jpg-640\nhttp://{{username}}:{{password}}@{{ip_address}}:{{port}}/snapshot.jpg|80|1|0|snapshot\n"
},
{
"file_name": "rtsp-paths.txt",
"relative_path": "data/vendors/dahua/rtsp-paths.txt",
"extension": ".txt",
"size_bytes": 351,
"content": "rtsp://{{username}}:{{password}}@{{ip_address}}:{{port}}/cam/realmonitor?channel={{channel}}&subtype={{stream}}|554|1|0|tcp|realmonitor-main\nrtsp://{{username}}:{{password}}@{{ip_address}}:{{port}}/cam/realmonitor?channel={{channel}}&subtype=1|554|1|1|tcp|realmonitor-sub\nrtsp://{{username}}:{{password}}@{{ip_address}}:{{port}}/live|554|1|0|tcp|live\n"
},
{
"file_name": "http-paths.txt",
"relative_path": "data/vendors/dahua/http-paths.txt",
"extension": ".txt",
"size_bytes": 353,
"content": "http://{{username}}:{{password}}@{{ip_address}}:{{port}}/cgi-bin/snapshot.cgi|80|1|0|snapshot-cgi\nhttp://{{username}}:{{password}}@{{ip_address}}:{{port}}/cgi-bin/snapshot.cgi?channel={{channel}}|80|1|0|snapshot-channel\nhttp://{{username}}:{{password}}@{{ip_address}}:{{port}}/cgi-bin/snapManager.cgi?action=snap&channel={{channel}}|80|1|0|snap-manager\n"
},
{
"file_name": "rtsp-paths.txt",
"relative_path": "data/vendors/uniview/rtsp-paths.txt",
"extension": ".txt",
"size_bytes": 298,
"content": "rtsp://{{username}}:{{password}}@{{ip_address}}:{{port}}/unicast/c1/s0/live|554|1|0|tcp|unv-main\nrtsp://{{username}}:{{password}}@{{ip_address}}:{{port}}/unicast/c1/s1/live|554|1|1|tcp|unv-sub\nrtsp://{{username}}:{{password}}@{{ip_address}}:{{port}}/Streaming/Channels/101|554|101|0|tcp|stream-101\n"
},
{
"file_name": "http-paths.txt",
"relative_path": "data/vendors/uniview/http-paths.txt",
"extension": ".txt",
"size_bytes": 306,
"content": "http://{{username}}:{{password}}@{{ip_address}}:{{port}}/snapshot.jpg|80|1|0|snapshot\nhttp://{{username}}:{{password}}@{{ip_address}}:{{port}}/cgi-bin/snapshot.cgi|80|1|0|snapshot-cgi\nhttp://{{username}}:{{password}}@{{ip_address}}:{{port}}/cgi-bin/snapshot.cgi?channel={{channel}}|80|1|0|snapshot-channel\n"
},
{
"file_name": "rtsp-paths.txt",
"relative_path": "data/vendors/lorex/rtsp-paths.txt",
"extension": ".txt",
"size_bytes": 351,
"content": "rtsp://{{username}}:{{password}}@{{ip_address}}:{{port}}/cam/realmonitor?channel={{channel}}&subtype={{stream}}|554|1|0|tcp|realmonitor-main\nrtsp://{{username}}:{{password}}@{{ip_address}}:{{port}}/cam/realmonitor?channel={{channel}}&subtype=1|554|1|1|tcp|realmonitor-sub\nrtsp://{{username}}:{{password}}@{{ip_address}}:{{port}}/live|554|1|0|tcp|live\n"
},
{
"file_name": "http-paths.txt",
"relative_path": "data/vendors/lorex/http-paths.txt",
"extension": ".txt",
"size_bytes": 317,
"content": "http://{{username}}:{{password}}@{{ip_address}}:{{port}}/cgi-bin/snapshot.cgi|80|1|0|snapshot-cgi\nhttp://{{username}}:{{password}}@{{ip_address}}:{{port}}/cgi-bin/snapManager.cgi?action=snap&channel={{channel}}|80|1|0|snap-manager\nhttp://{{username}}:{{password}}@{{ip_address}}:{{port}}/snapshot.jpg|80|1|0|snapshot\n"
},
{
"file_name": "rtsp-paths.txt",
"relative_path": "data/vendors/hanwha/rtsp-paths.txt",
"extension": ".txt",
"size_bytes": 263,
"content": "rtsp://{{username}}:{{password}}@{{ip_address}}:{{port}}/onvif1|554|1|0|tcp|onvif1\nrtsp://{{username}}:{{password}}@{{ip_address}}:{{port}}/onvif2|554|1|1|tcp|onvif2\nrtsp://{{username}}:{{password}}@{{ip_address}}:{{port}}/profile1/media.smp|554|1|0|tcp|profile1\n"
},
{
"file_name": "http-paths.txt",
"relative_path": "data/vendors/hanwha/http-paths.txt",
"extension": ".txt",
"size_bytes": 278,
"content": "http://{{username}}:{{password}}@{{ip_address}}:{{port}}/stw-cgi/image.cgi|80|1|0|stw-image\nhttp://{{username}}:{{password}}@{{ip_address}}:{{port}}/cgi-bin/snapshot.cgi|80|1|0|snapshot-cgi\nhttp://{{username}}:{{password}}@{{ip_address}}:{{port}}/image/jpeg.cgi|80|1|0|jpeg-cgi\n"
},
{
"file_name": "rtsp-paths.txt",
"relative_path": "data/vendors/amcrest/rtsp-paths.txt",
"extension": ".txt",
"size_bytes": 272,
"content": "rtsp://{{username}}:{{password}}@{{ip_address}}:{{port}}/cam/realmonitor?channel={{channel}}&subtype={{stream}}|554|1|0|tcp|realmonitor-main\nrtsp://{{username}}:{{password}}@{{ip_address}}:{{port}}/cam/realmonitor?channel={{channel}}&subtype=1|554|1|1|tcp|realmonitor-sub\n"
},
{
"file_name": "http-paths.txt",
"relative_path": "data/vendors/amcrest/http-paths.txt",
"extension": ".txt",
"size_bytes": 353,
"content": "http://{{username}}:{{password}}@{{ip_address}}:{{port}}/cgi-bin/snapshot.cgi|80|1|0|snapshot-cgi\nhttp://{{username}}:{{password}}@{{ip_address}}:{{port}}/cgi-bin/snapshot.cgi?channel={{channel}}|80|1|0|snapshot-channel\nhttp://{{username}}:{{password}}@{{ip_address}}:{{port}}/cgi-bin/snapManager.cgi?action=snap&channel={{channel}}|80|1|0|snap-manager\n"
},
{
"file_name": "rtsp-paths.txt",
"relative_path": "data/vendors/hikvision/rtsp-paths.txt",
"extension": ".txt",
"size_bytes": 314,
"content": "rtsp://{{username}}:{{password}}@{{ip_address}}:{{port}}/Streaming/Channels/101|554|101|0|tcp|stream-main\nrtsp://{{username}}:{{password}}@{{ip_address}}:{{port}}/Streaming/Channels/102|554|102|1|tcp|stream-sub\nrtsp://{{username}}:{{password}}@{{ip_address}}:{{port}}/h264/ch1/main/av_stream|554|1|0|tcp|h264-main\n"
},
{
"file_name": "http-paths.txt",
"relative_path": "data/vendors/hikvision/http-paths.txt",
"extension": ".txt",
"size_bytes": 351,
"content": "http://{{username}}:{{password}}@{{ip_address}}:{{port}}/ISAPI/Streaming/channels/101/picture|80|101|0|isapi-picture-main\nhttp://{{username}}:{{password}}@{{ip_address}}:{{port}}/ISAPI/Streaming/channels/102/picture|80|102|1|isapi-picture-sub\nhttp://{{username}}:{{password}}@{{ip_address}}:{{port}}/Streaming/channels/1/picture|80|1|0|legacy-picture\n"
},
{
"file_name": "rtsp-paths.txt",
"relative_path": "data/vendors/panasonic/rtsp-paths.txt",
"extension": ".txt",
"size_bytes": 301,
"content": "rtsp://{{username}}:{{password}}@{{ip_address}}:{{port}}/MediaInput/h264|554|1|0|tcp|media-h264\nrtsp://{{username}}:{{password}}@{{ip_address}}:{{port}}/MediaInput/h264/stream_1|554|1|0|tcp|media-h264-1\nrtsp://{{username}}:{{password}}@{{ip_address}}:{{port}}/MediaInput/mpeg4|554|1|0|tcp|media-mpeg4\n"
},
{
"file_name": "http-paths.txt",
"relative_path": "data/vendors/panasonic/http-paths.txt",
"extension": ".txt",
"size_bytes": 289,
"content": "http://{{username}}:{{password}}@{{ip_address}}:{{port}}/SnapshotJPEG|80|1|0|snapshotjpeg\nhttp://{{username}}:{{password}}@{{ip_address}}:{{port}}/SnapshotJPEG?Resolution=640x480|80|1|0|snapshotjpeg-640\nhttp://{{username}}:{{password}}@{{ip_address}}:{{port}}/snapshot.jpg|80|1|0|snapshot\n"
},
{
"file_name": "rtsp-paths.txt",
"relative_path": "data/vendors/ezviz/rtsp-paths.txt",
"extension": ".txt",
"size_bytes": 314,
"content": "rtsp://{{username}}:{{password}}@{{ip_address}}:{{port}}/Streaming/Channels/101|554|101|0|tcp|stream-main\nrtsp://{{username}}:{{password}}@{{ip_address}}:{{port}}/Streaming/Channels/102|554|102|1|tcp|stream-sub\nrtsp://{{username}}:{{password}}@{{ip_address}}:{{port}}/h264/ch1/main/av_stream|554|1|0|tcp|h264-main\n"
},
{
"file_name": "http-paths.txt",
"relative_path": "data/vendors/ezviz/http-paths.txt",
"extension": ".txt",
"size_bytes": 351,
"content": "http://{{username}}:{{password}}@{{ip_address}}:{{port}}/ISAPI/Streaming/channels/101/picture|80|101|0|isapi-picture-main\nhttp://{{username}}:{{password}}@{{ip_address}}:{{port}}/ISAPI/Streaming/channels/102/picture|80|102|1|isapi-picture-sub\nhttp://{{username}}:{{password}}@{{ip_address}}:{{port}}/Streaming/channels/1/picture|80|1|0|legacy-picture\n"
},
{
"file_name": "rtsp-paths.txt",
"relative_path": "data/vendors/reolink/rtsp-paths.txt",
"extension": ".txt",
"size_bytes": 202,
"content": "rtsp://{{username}}:{{password}}@{{ip_address}}:{{port}}/h264Preview_01_main|554|1|0|tcp|preview-main\nrtsp://{{username}}:{{password}}@{{ip_address}}:{{port}}/h264Preview_01_sub|554|1|1|tcp|preview-sub\n"
},
{
"file_name": "http-paths.txt",
"relative_path": "data/vendors/reolink/http-paths.txt",
"extension": ".txt",
"size_bytes": 235,
"content": "http://{{username}}:{{password}}@{{ip_address}}:{{port}}/cgi-bin/api.cgi?cmd=Snap&channel={{channel}}|80|0|0|reolink-snap\nhttp://{{username}}:{{password}}@{{ip_address}}:{{port}}/cgi-bin/api.cgi?cmd=Snap&channel=0|80|0|0|reolink-snap0\n"
},
{
"file_name": "rtsp-paths.txt",
"relative_path": "data/vendors/tiandy/rtsp-paths.txt",
"extension": ".txt",
"size_bytes": 279,
"content": "rtsp://{{username}}:{{password}}@{{ip_address}}:{{port}}/profile1|554|1|0|tcp|profile1\nrtsp://{{username}}:{{password}}@{{ip_address}}:{{port}}/profile2|554|1|1|tcp|profile2\nrtsp://{{username}}:{{password}}@{{ip_address}}:{{port}}/Streaming/Channels/101|554|101|0|tcp|stream-101\n"
},
{
"file_name": "http-paths.txt",
"relative_path": "data/vendors/tiandy/http-paths.txt",
"extension": ".txt",
"size_bytes": 281,
"content": "http://{{username}}:{{password}}@{{ip_address}}:{{port}}/snapshot.jpg|80|1|0|snapshot\nhttp://{{username}}:{{password}}@{{ip_address}}:{{port}}/snapshot.cgi|80|1|0|snapshot-cgi\nhttp://{{username}}:{{password}}@{{ip_address}}:{{port}}/cgi-bin/snapshot.cgi|80|1|0|snapshot-cgi-legacy\n"
},
{
"file_name": "requirements.txt",
"relative_path": "scripts/requirements.txt",
"extension": ".txt",
"size_bytes": 128,
"content": "bottle==0.13.4\ncffi==2.0.0\ncryptography==46.0.2\ndnspython==2.8.0\nivre==0.9.20\npycparser==2.23\npymongo==4.15.3\npyOpenSSL==25.3.0\n"
},
{
"file_name": "ivre-sync.py",
"relative_path": "scripts/integrations/ivre-sync.py",
"extension": ".py",
"size_bytes": 19685,
"content": "#!/usr/bin/env python3\n#\n# https://github.com/John0n1/CamSniff\n#\n# Copyright (c) 2026 John Hauger Mitander\n# License: MIT License https://opensource.org/license/MIT\n\n\"\"\"CamSniff to IVRE integration bridge.\"\"\"\n\nfrom __future__ import annotations\n\nimport argparse\nimport csv\nimport datetime as dt\nimport json\nimport sys\nfrom pathlib import Path\nfrom typing import Any, Dict, List, Optional, Set\n\n\ndef build_parser() -> argparse.ArgumentParser:\n parser = argparse.ArgumentParser(\n description=\"Sync CamSniff discovery data into IVRE\"\n )\n parser.add_argument(\n \"--input\",\n required=True,\n help=\"Path to CamSniff discovery.json\",\n )\n parser.add_argument(\n \"--mode\", required=True, help=\"CamSniff mode label\"\n )\n parser.add_argument(\n \"--network\", required=True, help=\"Network scope string\"\n )\n parser.add_argument(\n \"--run-dir\",\n required=True,\n help=\"Run directory for this execution\",\n )\n parser.add_argument(\n \"--timestamp\",\n required=True,\n help=\"UTC timestamp in YYYYMMDDTHHMMSSZ format\",\n )\n parser.add_argument(\n \"--log\",\n required=True,\n help=\"Log file to append integration status\",\n )\n parser.add_argument(\n \"--credentials\",\n help=\"Path to CamSniff credentials.json (optional)\",\n )\n parser.add_argument(\n \"--paths-csv\",\n help=\"Path to paths.csv for vendor mapping (optional)\",\n )\n return parser\n\n\ndef utc_now() -> str:\n return dt.datetime.now(dt.UTC).isoformat().replace(\"+00:00\", \"Z\")\n\n\ndef log_line(log_path: Path, message: str) -> None:\n log_path.parent.mkdir(parents=True, exist_ok=True)\n with log_path.open(\"a\", encoding=\"utf-8\") as handle:\n handle.write(f\"{utc_now()} {message}\\n\")\n\n\ndef normalise_port(value: Any) -> int | None:\n if value is None:\n return None\n if isinstance(value, int):\n if 0 <= value <= 65535:\n return value\n return None\n if isinstance(value, float):\n value_int = int(value)\n if 0 <= value_int <= 65535:\n return value_int\n return None\n if isinstance(value, str):\n stripped = value.strip()\n if not stripped:\n return None\n try:\n value_int = int(stripped, 10)\n except ValueError:\n return None\n if 0 <= value_int <= 65535:\n return value_int\n return None\n\n\ndef load_vendor_database(\n paths_csv: Optional[Path],\n) -> Dict[str, Dict[str, str]]:\n vendor_db: Dict[str, Dict[str, str]] = {}\n\n if not paths_csv or not paths_csv.is_file():\n return vendor_db\n\n try:\n with paths_csv.open(\"r\", encoding=\"utf-8\") as handle:\n reader = csv.DictReader(handle)\n for row in reader:\n company = row.get(\"company\", \"\").strip()\n model = row.get(\"model\", \"\").strip()\n oui_regex = row.get(\"oui_regex\", \"\").strip()\n\n if not company or not oui_regex:\n continue\n\n oui_list = oui_regex.strip(\"()\").split(\"|\")\n for oui in oui_list:\n oui_clean = oui.strip().upper()\n if oui_clean:\n vendor_db[oui_clean] = {\n \"company\": company,\n \"model\": model,\n \"cve_ids\": row.get(\"cve_ids\", \"\"),\n }\n except Exception:\n pass\n\n return vendor_db\n\n\ndef match_vendor_by_mac(\n mac: Optional[str], vendor_db: Dict[str, Dict[str, str]]\n) -> Optional[Dict[str, str]]:\n if not mac or not vendor_db:\n return None\n\n mac_upper = mac.strip().upper().replace(\"-\", \":\")\n oui = \":\".join(mac_upper.split(\":\")[:3])\n\n return vendor_db.get(oui)\n\n\ndef load_credentials(\n credentials_json: Optional[Path],\n) -> Dict[str, Dict[str, Any]]:\n creds_db: Dict[str, Dict[str, Any]] = {}\n\n if not credentials_json or not credentials_json.is_file():\n return creds_db\n\n try:\n with credentials_json.open(\"r\", encoding=\"utf-8\") as handle:\n creds_list = json.load(handle)\n\n for entry in creds_list:\n ip_addr = entry.get(\"ip\")\n if not ip_addr:\n continue\n\n creds_db[ip_addr] = {\n \"success\": entry.get(\"success\", False),\n \"username\": entry.get(\"username\", \"\"),\n \"password\": entry.get(\"password\", \"\"),\n \"method\": entry.get(\"method\", \"\"),\n \"vendor\": entry.get(\"vendor\", \"Unknown\"),\n \"model\": entry.get(\"model\", \"Unknown\"),\n \"protocols\": entry.get(\"protocols\", []),\n \"rtsp_url\": entry.get(\"rtsp_url\", \"\"),\n \"http_url\": entry.get(\"http_url\", \"\"),\n \"thumbnail\": entry.get(\"thumbnail\", \"\"),\n }\n except Exception:\n pass\n\n return creds_db\n\n\ndef build_host_documents(\n data: Dict[str, Any],\n *,\n mode: str,\n network: str,\n run_dir: str,\n timestamp: dt.datetime,\n vendor_db: Dict[str, Dict[str, str]],\n creds_db: Dict[str, Dict[str, Any]],\n) -> List[Dict[str, Any]]:\n from ivre import xmlnmap # type: ignore\n\n hosts = data.get(\"hosts\", []) or []\n documents: List[Dict[str, Any]] = []\n ts_rendered = timestamp.strftime(\"%Y-%m-%d %H:%M:%S\")\n\n for host in hosts:\n ip_addr = host.get(\"ip\")\n if not ip_addr:\n continue\n\n ports_field = host.get(\"ports\", []) or []\n ports_seen: Set[tuple[str, int]] = set()\n port_documents: List[Dict[str, Any]] = []\n\n for port_candidate in ports_field:\n port_number = normalise_port(port_candidate)\n if port_number is None:\n continue\n key = (\"tcp\", port_number)\n if key in ports_seen:\n continue\n ports_seen.add(key)\n entry: Dict[str, Any] = {\n \"protocol\": \"tcp\",\n \"port\": port_number,\n \"state_state\": \"open\",\n \"state_reason\": \"script\",\n }\n if port_number in {\n 80,\n 81,\n 88,\n 8000,\n 8001,\n 8080,\n 8081,\n 8443,\n }:\n entry[\"service_name\"] = \"http\"\n if port_number in {443, 7443, 8443, 9443, 10443}:\n entry[\"service_name\"] = \"http\"\n entry[\"service_tunnel\"] = \"ssl\"\n if port_number == 554:\n entry[\"service_name\"] = \"rtsp\"\n port_documents.append(entry)\n\n rtsp_data = host.get(\"rtsp_bruteforce\", {}) or {}\n observed_paths = host.get(\"observed_paths\", []) or []\n additional_protocols = (\n host.get(\"additional_protocols\", []) or []\n )\n sources = host.get(\"sources\", []) or []\n\n mac_addr = host.get(\"mac\")\n vendor_info = (\n match_vendor_by_mac(mac_addr, vendor_db)\n if mac_addr\n else None\n )\n\n cred_info = creds_db.get(ip_addr)\n\n summary_lines = [\n f\"mode={mode}\",\n f\"network={network}\",\n f\"sources={','.join(sources) if sources else 'n/a'}\",\n ]\n\n if vendor_info:\n summary_lines.append(f\"vendor={vendor_info['company']}\")\n if vendor_info.get(\"model\"):\n summary_lines.append(f\"model={vendor_info['model']}\")\n if vendor_info.get(\"cve_ids\"):\n summary_lines.append(f\"cves={vendor_info['cve_ids']}\")\n elif cred_info:\n summary_lines.append(\n f\"vendor={cred_info.get('vendor', 'Unknown')}\"\n )\n summary_lines.append(\n f\"model={cred_info.get('model', 'Unknown')}\"\n )\n\n if cred_info and cred_info.get(\"success\"):\n summary_lines.append(\"credentials=FOUND\")\n summary_lines.append(\n f\" username={cred_info['username']}\"\n )\n summary_lines.append(\n f\" password={cred_info['password']}\"\n )\n summary_lines.append(f\" method={cred_info['method']}\")\n if cred_info.get(\"rtsp_url\"):\n summary_lines.append(\n f\" rtsp_url={cred_info['rtsp_url']}\"\n )\n if cred_info.get(\"http_url\"):\n summary_lines.append(\n f\" http_url={cred_info['http_url']}\"\n )\n if cred_info.get(\"thumbnail\"):\n summary_lines.append(\n f\" thumbnail={cred_info['thumbnail']}\"\n )\n\n if ports_seen:\n summary_lines.append(\n \"ports=\"\n + \",\".join(\n str(port)\n for _, port in sorted(\n ports_seen, key=lambda item: item[1]\n )\n )\n )\n if observed_paths:\n summary_lines.append(\"observed_paths:\")\n for path in observed_paths[:10]:\n summary_lines.append(f\" - {path}\")\n if rtsp_data.get(\"discovered\"):\n summary_lines.append(\"rtsp_found:\")\n for url in rtsp_data[\"discovered\"][:10]:\n summary_lines.append(f\" - {url}\")\n if additional_protocols:\n summary_lines.append(\"protocol_hits:\")\n for proto in additional_protocols:\n proto_name = proto.get(\"protocol\", \"unknown\")\n detail = proto.get(\"detail\", \"\")\n summary_lines.append(f\" - {proto_name}: {detail}\")\n\n host_scripts: List[Dict[str, Any]] = []\n\n summary_data = {\n \"mode\": mode,\n \"network\": network,\n \"run_dir\": run_dir,\n \"sources\": sources,\n \"observed_paths\": observed_paths,\n \"rtsp\": rtsp_data,\n \"additional_protocols\": additional_protocols,\n }\n\n if vendor_info:\n summary_data[\"vendor\"] = vendor_info[\"company\"]\n summary_data[\"model\"] = vendor_info.get(\"model\", \"\")\n summary_data[\"cves\"] = vendor_info.get(\"cve_ids\", \"\")\n\n if cred_info:\n summary_data[\"credentials\"] = {\n \"success\": cred_info.get(\"success\", False),\n \"username\": cred_info.get(\"username\", \"\"),\n \"password\": cred_info.get(\"password\", \"\"),\n \"method\": cred_info.get(\"method\", \"\"),\n \"rtsp_url\": cred_info.get(\"rtsp_url\", \"\"),\n \"http_url\": cred_info.get(\"http_url\", \"\"),\n \"thumbnail\": cred_info.get(\"thumbnail\", \"\"),\n }\n\n host_scripts.append(\n {\n \"id\": \"camsniff-summary\",\n \"output\": \"\\n\".join(summary_lines),\n \"camsniff-summary\": summary_data,\n }\n )\n\n if additional_protocols:\n host_scripts.append(\n {\n \"id\": \"camsniff-protocols\",\n \"output\": \"\\n\".join(\n f\" {entry.get('detail', '')}\"\n for entry in additional_protocols\n ),\n \"camsniff-protocols\": additional_protocols,\n }\n )\n\n if rtsp_data.get(\"other_responses\"):\n formatted = []\n for status, urls in sorted(\n rtsp_data[\"other_responses\"].items()\n ):\n for url in urls:\n formatted.append(f\"{status}: {url}\")\n host_scripts.append(\n {\n \"id\": \"camsniff-rtsp-responses\",\n \"output\": \"\\n\".join(formatted),\n \"camsniff-rtsp-responses\": rtsp_data[\n \"other_responses\"\n ],\n }\n )\n\n if vendor_info or cred_info:\n vendor_script_output = []\n vendor_script_data = {}\n\n if vendor_info:\n vendor_script_output.append(\n f\"Company: {vendor_info['company']}\"\n )\n vendor_script_output.append(\n f\"Model: {vendor_info.get('model', 'N/A')}\"\n )\n if vendor_info.get(\"cve_ids\"):\n vendor_script_output.append(\n f\"CVEs: {vendor_info['cve_ids']}\"\n )\n vendor_script_data[\"company\"] = vendor_info[\"company\"]\n vendor_script_data[\"model\"] = vendor_info.get(\n \"model\", \"\"\n )\n vendor_script_data[\"cves\"] = vendor_info.get(\n \"cve_ids\", \"\"\n )\n elif cred_info:\n vendor_script_output.append(\n f\"Company: {cred_info.get('vendor', 'Unknown')}\"\n )\n vendor_script_output.append(\n f\"Model: {cred_info.get('model', 'Unknown')}\"\n )\n vendor_script_data[\"company\"] = cred_info.get(\n \"vendor\", \"Unknown\"\n )\n vendor_script_data[\"model\"] = cred_info.get(\n \"model\", \"Unknown\"\n )\n\n if cred_info and cred_info.get(\"success\"):\n vendor_script_output.append(\"Credentials: SUCCESS\")\n vendor_script_output.append(\n f\" Username: {cred_info['username']}\"\n )\n vendor_script_output.append(\n f\" Password: {cred_info['password']}\"\n )\n vendor_script_output.append(\n f\" Method: {cred_info['method']}\"\n )\n vendor_script_data[\"credentials_found\"] = True\n vendor_script_data[\"username\"] = cred_info[\"username\"]\n vendor_script_data[\"password\"] = cred_info[\"password\"]\n\n if cred_info.get(\"thumbnail\"):\n vendor_script_output.append(\n f\" Thumbnail: {cred_info['thumbnail']}\"\n )\n vendor_script_data[\"thumbnail\"] = cred_info[\n \"thumbnail\"\n ]\n\n host_scripts.append(\n {\n \"id\": \"camsniff-vendor\",\n \"output\": \"\\n\".join(vendor_script_output),\n \"camsniff-vendor\": vendor_script_data,\n }\n )\n\n if host_scripts:\n port_documents.append(\n {\n \"protocol\": \"tcp\",\n \"port\": -1,\n \"state_state\": \"open\",\n \"state_reason\": \"script\",\n \"scripts\": host_scripts,\n }\n )\n\n document: Dict[str, Any] = {\n \"addr\": ip_addr,\n \"state\": \"up\",\n \"schema_version\": xmlnmap.SCHEMA_VERSION,\n \"starttime\": ts_rendered,\n \"endtime\": ts_rendered,\n \"source\": \"CamSniff\",\n \"categories\": [\n \"camsniff\",\n f\"camsniff-mode:{mode.lower()}\",\n ],\n \"ports\": port_documents,\n }\n\n if vendor_info:\n document[\"categories\"].append(\n f\"vendor:{vendor_info['company'].lower().replace(' ', '-')}\"\n )\n elif cred_info:\n vendor_name = cred_info.get(\"vendor\", \"unknown\")\n document[\"categories\"].append(\n f\"vendor:{vendor_name.lower().replace(' ', '-')}\"\n )\n\n if cred_info and cred_info.get(\"success\"):\n document[\"categories\"].append(\"credentials-found\")\n\n if mac_addr:\n document[\"addresses\"] = [\n {\n \"addrtype\": \"mac\",\n \"addr\": str(mac_addr).strip(),\n }\n ]\n\n documents.append(document)\n\n return documents\n\n\ndef main() -> int:\n args = build_parser().parse_args()\n log_path = Path(args.log)\n input_path = Path(args.input)\n\n if not input_path.is_file():\n log_line(log_path, f\"input file not found: {input_path}\")\n return 1\n\n try:\n run_timestamp = dt.datetime.strptime(\n args.timestamp, \"%Y%m%dT%H%M%SZ\"\n ).replace(tzinfo=dt.UTC)\n except ValueError as exc:\n log_line(\n log_path, f\"invalid timestamp '{args.timestamp}': {exc}\"\n )\n return 1\n\n try:\n with input_path.open(\"r\", encoding=\"utf-8\") as handle:\n discovery_data = json.load(handle)\n except (OSError, json.JSONDecodeError) as exc:\n log_line(log_path, f\"failed to read discovery payload: {exc}\")\n return 1\n\n paths_csv_path = Path(args.paths_csv) if args.paths_csv else None\n vendor_db = load_vendor_database(paths_csv_path)\n log_line(\n log_path,\n f\"loaded {len(vendor_db)} vendor entries from paths.csv\",\n )\n\n credentials_path = (\n Path(args.credentials) if args.credentials else None\n )\n creds_db = load_credentials(credentials_path)\n log_line(log_path, f\"loaded {len(creds_db)} credential entries\")\n\n try:\n from ivre.db import db # type: ignore\n except ImportError as exc:\n log_line(log_path, f\"IVRE not available: {exc}\")\n return 2\n\n dbase = getattr(db, \"nmap\", None)\n if dbase is None:\n log_line(log_path, \"IVRE nmap database backend unavailable\")\n return 2\n\n documents = build_host_documents(\n discovery_data,\n mode=args.mode,\n network=args.network,\n run_dir=args.run_dir,\n timestamp=run_timestamp,\n vendor_db=vendor_db,\n creds_db=creds_db,\n )\n\n if not documents:\n log_line(log_path, \"no hosts to sync \u2013 skipping IVRE import\")\n return 0\n\n try:\n ips_to_update = [\n doc[\"addr\"] for doc in documents if doc.get(\"addr\")\n ]\n if ips_to_update:\n removed_count = 0\n for ip_addr in ips_to_update:\n host_filter = dbase.searchhost(ip_addr)\n source_filter = dbase.searchsource(\"CamSniff\")\n combined_filter = dbase.flt_and(\n host_filter, source_filter\n )\n\n existing_scans = list(dbase.get(combined_filter))\n\n for scan in existing_scans:\n dbase.remove(scan)\n removed_count += 1\n\n if removed_count > 0:\n log_line(\n log_path,\n f\"removed {removed_count} hosts before re-ingestion\",\n )\n except Exception as exc:\n log_line(\n log_path, f\"warning: failed to remove old scans: {exc}\"\n )\n\n try:\n stored_count = 0\n for doc in documents:\n dbase.store_host(doc)\n stored_count += 1\n log_line(log_path, f\"synced {stored_count} hosts into IVRE\")\n except Exception as exc:\n log_line(log_path, f\"IVRE ingestion failed: {exc}\")\n return 1\n\n vendor_count = sum(\n 1\n for doc in documents\n if any(\"vendor:\" in cat for cat in doc.get(\"categories\", []))\n )\n creds_count = sum(\n 1\n for doc in documents\n if \"credentials-found\" in doc.get(\"categories\", [])\n )\n log_line(log_path, f\" - {vendor_count} hosts with vendor info\")\n log_line(log_path, f\" - {creds_count} hosts with credentials\")\n\n return 0\n\n\nif __name__ == \"__main__\":\n sys.exit(main())\n"
},
{
"file_name": "http_metadata_parser.py",
"relative_path": "scripts/helpers/http_metadata_parser.py",
"extension": ".py",
"size_bytes": 2872,
"content": "#!/usr/bin/env python3\n#\n# https://github.com/John0n1/CamSniff\n#\n# Copyright (c) 2026 John Hauger Mitander\n# License: MIT License https://opensource.org/license/MIT\n\n\"\"\"Extract structured HTTP metadata from captured headers/body.\"\"\"\nfrom __future__ import annotations\n\nimport argparse\nimport json\nimport re\nfrom pathlib import Path\n\n\ndef parse_args() -> argparse.Namespace:\n parser = argparse.ArgumentParser(\n description=\"Extract HTTP metadata for CamSniff\"\n )\n parser.add_argument(\n \"--headers\", required=True, help=\"Path to raw HTTP headers\"\n )\n parser.add_argument(\n \"--body\", required=True, help=\"Path to HTTP response body\"\n )\n parser.add_argument(\n \"--ip\", required=True, help=\"Target IP address\"\n )\n parser.add_argument(\n \"--port\", type=int, required=True, help=\"Target TCP port\"\n )\n parser.add_argument(\n \"--scheme\", required=True, help=\"URL scheme (http/https)\"\n )\n return parser.parse_args()\n\n\ndef read_text(path: Path, limit: int | None = None) -> str:\n try:\n data = path.read_text(encoding=\"utf-8\", errors=\"ignore\")\n except FileNotFoundError:\n return \"\"\n if limit is not None:\n return data[:limit]\n return data\n\n\ndef extract_metadata(headers: str, body: str) -> dict:\n status_code = None\n server = \"\"\n www_auth = \"\"\n\n header_lines = headers.splitlines()\n if header_lines:\n first_line = header_lines[0]\n if first_line.startswith(\"HTTP/\"):\n parts = first_line.split()\n if len(parts) > 1 and parts[1].isdigit():\n status_code = int(parts[1])\n\n for line in header_lines[1:]:\n lower = line.lower()\n if lower.startswith(\"server:\") and not server:\n server = line.split(\":\", 1)[1].strip()\n elif lower.startswith(\"www-authenticate:\") and not www_auth:\n www_auth = line.split(\":\", 1)[1].strip()\n\n title = \"\"\n match = re.search(\n r\"<title[^>]*>(.*?)</title>\", body, re.IGNORECASE | re.DOTALL\n )\n if match:\n title = re.sub(r\"\\s+\", \" \", match.group(1)).strip()\n\n realm = \"\"\n realm_match = re.search(\n r\"realm=\\\"([^\\\"]+)\\\"\", www_auth, re.IGNORECASE\n )\n if realm_match:\n realm = realm_match.group(1)\n\n return {\n \"status\": status_code,\n \"server\": server,\n \"realm\": realm,\n \"title\": title,\n \"www_authenticate\": www_auth,\n }\n\n\ndef main() -> int:\n args = parse_args()\n\n headers = read_text(Path(args.headers))\n body = read_text(Path(args.body), limit=4096)\n metadata = extract_metadata(headers, body)\n\n payload = {\n \"ip\": args.ip,\n \"port\": args.port,\n \"scheme\": args.scheme,\n **metadata,\n }\n\n print(json.dumps(payload))\n return 0\n\n\nif __name__ == \"__main__\": # pragma: no cover\n raise SystemExit(main())\n"
},
{
"file_name": "confidence_scorer.py",
"relative_path": "scripts/helpers/confidence_scorer.py",
"extension": ".py",
"size_bytes": 10946,
"content": "#!/usr/bin/env python3\n#\n# https://github.com/John0n1/CamSniff\n#\n# Copyright (c) 2026 John Hauger Mitander\n# License: MIT License https://opensource.org/license/MIT\n\n\"\"\"Compute confidence scores for CamSniff discovery results.\"\"\"\nfrom __future__ import annotations\n\nimport argparse\nimport json\nimport re\nfrom pathlib import Path\nfrom typing import Any, Dict, List, Optional\n\nSOURCE_WEIGHTS = {\n \"SSDP\": 25,\n \"Avahi\": 15,\n \"TShark\": 20,\n \"Nmap\": 5,\n \"Masscan\": 4,\n \"CoAP\": 8,\n}\n\nPORT_WEIGHTS = {\n 554: 35,\n 8554: 30,\n 10554: 30,\n 5544: 25,\n 1935: 12,\n 1936: 12,\n 37777: 20,\n 37778: 20,\n 37779: 20,\n 8000: 18,\n 8001: 18,\n 8899: 12,\n 9000: 10,\n 7001: 10,\n 5000: 10,\n 5001: 10,\n}\n\nHTTP_PORTS = {80, 81, 82, 88, 443, 7443, 8000, 8080, 8081, 8088, 8443}\n\nPROTOCOL_WEIGHTS = {\n \"ONVIF\": 30,\n \"RTSP\": 25,\n \"HLS\": 15,\n \"RTMP\": 12,\n \"WebRTC\": 12,\n \"SRT\": 8,\n \"HTTP\": 8,\n \"SSDP\": 10,\n \"CoAP\": 8,\n}\n\nCAMERA_KEYWORDS = [\n \"camera\",\n \"ipcam\",\n \"ip cam\",\n \"webcam\",\n \"mjpeg\",\n \"snapshot\",\n \"onvif\",\n \"rtsp\",\n \"surveillance\",\n \"live view\",\n \"liveview\",\n \"stream\",\n \"cctv\",\n]\n\nVENDOR_KEYWORDS = [\n \"hikvision\",\n \"dahua\",\n \"axis\",\n \"hanwha\",\n \"bosch\",\n \"uniview\",\n \"vivotek\",\n \"amcrest\",\n \"lorex\",\n \"reolink\",\n \"flir\",\n \"mobotix\",\n \"sony\",\n \"panasonic\",\n \"geovision\",\n \"tiandy\",\n \"avigilon\",\n \"ezviz\",\n]\n\nRECORDER_KEYWORDS = [\n \"nvr\",\n \"dvr\",\n \"recorder\",\n \"cms\",\n]\n\nOBSERVED_PATH_HINTS = [\n \"rtsp\",\n \"onvif\",\n \"snapshot\",\n \"mjpeg\",\n \"mjpg\",\n \"stream\",\n \"live\",\n]\n\nPATH_PATTERNS = [\n r\"/Streaming/Channels/\",\n r\"/cam/realmonitor\",\n r\"/live\\.sdp\",\n r\"/live\\.m3u8\",\n r\"/streaming/\",\n r\"/video\\.mjpg\",\n r\"/mjpeg\",\n r\"/mjpg\",\n r\"/snapshot\\.cgi\",\n r\"/cgi-bin/.+snapshot\",\n r\"/onvif/\",\n r\"/ISAPI/\",\n r\"/axis-cgi/\",\n r\"/h264\",\n r\"/video\\.cgi\",\n r\"/image\\.jpg\",\n]\n\nSSDP_LOCATION_HINTS = [\n \"onvif\",\n \"device\",\n \"desc\",\n \"upnp\",\n \"camera\",\n]\n\n\ndef parse_args() -> argparse.Namespace:\n parser = argparse.ArgumentParser(\n description=\"Score CamSniff discovery hosts\"\n )\n parser.add_argument(\n \"--input\",\n required=True,\n help=\"Input discovery JSON path\",\n )\n parser.add_argument(\n \"--output\",\n required=True,\n help=\"Output discovery JSON path\",\n )\n return parser.parse_args()\n\n\ndef load_json(path: Path) -> Dict[str, Any]:\n try:\n with path.open(\"r\", encoding=\"utf-8\") as handle:\n data = json.load(handle)\n if isinstance(data, dict):\n return data\n except (FileNotFoundError, json.JSONDecodeError):\n pass\n return {\"hosts\": []}\n\n\ndef sanitize_text(value: Any) -> str:\n if value is None:\n return \"\"\n if not isinstance(value, str):\n value = str(value)\n return value.strip()\n\n\ndef contains_keyword(text: str, keywords: List[str]) -> bool:\n lowered = text.lower()\n for keyword in keywords:\n if keyword in lowered:\n return True\n return False\n\n\ndef flatten_metadata(host: Dict[str, Any]) -> str:\n parts: List[str] = []\n for entry in host.get(\"http_metadata\") or []:\n if isinstance(entry, dict):\n for key in (\"server\", \"realm\", \"title\", \"www_authenticate\"):\n value = sanitize_text(entry.get(key))\n if value:\n parts.append(value)\n for entry in host.get(\"ssdp\") or []:\n if isinstance(entry, dict):\n for key in (\n \"server\",\n \"st\",\n \"usn\",\n \"location\",\n \"friendly_name\",\n \"manufacturer\",\n \"model\",\n \"model_number\",\n \"device_type\",\n \"serial\",\n ):\n value = sanitize_text(entry.get(key))\n if value:\n parts.append(value)\n for entry in host.get(\"onvif\") or []:\n if isinstance(entry, dict):\n for key in entry.values():\n value = sanitize_text(key)\n if value:\n parts.append(value)\n observed = host.get(\"observed_paths\") or []\n if isinstance(observed, list):\n parts.extend([sanitize_text(item) for item in observed])\n return \" \".join(parts)\n\n\ndef score_host(host: Dict[str, Any]) -> Dict[str, Any]:\n score = 0\n reasons: List[str] = []\n signals = set()\n\n def add(points: int, reason: str, signal: Optional[str] = None) -> None:\n nonlocal score\n score += points\n if reason and reason not in reasons:\n reasons.append(reason)\n if signal:\n signals.add(signal)\n\n sources = host.get(\"sources\") or []\n for source in sources:\n name = sanitize_text(source)\n if name in SOURCE_WEIGHTS:\n add(SOURCE_WEIGHTS[name], f\"{name.lower()} signal\", \"source\")\n\n ports = host.get(\"ports\") or []\n for port in ports:\n if isinstance(port, int) and port in PORT_WEIGHTS:\n add(PORT_WEIGHTS[port], f\"port {port} open\", \"port\")\n if any(isinstance(port, int) and port in HTTP_PORTS for port in ports):\n add(8, \"http port open\", \"port\")\n\n protocols = host.get(\"additional_protocols\") or []\n for entry in protocols:\n if isinstance(entry, dict):\n name = sanitize_text(entry.get(\"protocol\"))\n if name in PROTOCOL_WEIGHTS:\n signal = \"protocol\"\n if name == \"RTSP\":\n signal = \"rtsp\"\n elif name == \"ONVIF\":\n signal = \"onvif\"\n add(PROTOCOL_WEIGHTS[name], f\"{name.lower()} detected\", signal)\n\n rtsp = host.get(\"rtsp_bruteforce\") or {}\n discovered = rtsp.get(\"discovered\") or []\n if isinstance(discovered, list) and discovered:\n add(35, \"rtsp url discovered\", \"rtsp\")\n other = rtsp.get(\"other_responses\") or {}\n if isinstance(other, dict) and other:\n add(10, \"rtsp response observed\", \"rtsp\")\n\n observed_paths = host.get(\"observed_paths\") or []\n observed_blob = \" \".join(\n sanitize_text(item) for item in observed_paths if item\n )\n if observed_blob and contains_keyword(observed_blob, OBSERVED_PATH_HINTS):\n add(18, \"observed stream path\", \"path\")\n if observed_paths:\n path_hits = 0\n for path in observed_paths:\n if not path:\n continue\n for pattern in PATH_PATTERNS:\n if re.search(pattern, str(path), re.IGNORECASE):\n path_hits += 1\n add(12, \"camera path signature\", \"path\")\n break\n if path_hits >= 2:\n add(6, \"multiple camera paths\", \"path\")\n\n profile = host.get(\"profile_match\") or {}\n vendor = sanitize_text(profile.get(\"vendor\"))\n if vendor and vendor.lower() != \"unknown\":\n add(10, \"vendor match\", \"profile\")\n matched_by = sanitize_text(profile.get(\"matched_by\"))\n if matched_by.lower() == \"oui\":\n add(15, \"mac oui match\", \"profile\")\n\n meta_blob = flatten_metadata(host)\n if meta_blob and contains_keyword(meta_blob, CAMERA_KEYWORDS):\n add(20, \"camera keyword in banners\", \"banner\")\n if meta_blob and contains_keyword(meta_blob, VENDOR_KEYWORDS):\n add(12, \"vendor keyword in banners\", \"banner\")\n elif meta_blob:\n add(5, \"banner metadata present\", \"banner\")\n\n onvif_entries = host.get(\"onvif\") or []\n if onvif_entries:\n add(10, \"onvif metadata\", \"onvif\")\n for entry in onvif_entries:\n if not isinstance(entry, dict):\n continue\n manufacturer = sanitize_text(entry.get(\"manufacturer\"))\n model = sanitize_text(entry.get(\"model\"))\n firmware = sanitize_text(entry.get(\"firmware\"))\n serial = sanitize_text(entry.get(\"serial\"))\n if manufacturer or model:\n add(25, \"onvif device info\", \"onvif\")\n if firmware or serial:\n add(8, \"onvif firmware/serial\", \"onvif\")\n\n ssdp_entries = host.get(\"ssdp\") or []\n if ssdp_entries:\n add(10, \"ssdp metadata\", \"ssdp\")\n for entry in ssdp_entries:\n if not isinstance(entry, dict):\n continue\n location = sanitize_text(entry.get(\"location\"))\n if location and contains_keyword(location, SSDP_LOCATION_HINTS):\n add(10, \"ssdp device description\", \"ssdp\")\n manufacturer = sanitize_text(entry.get(\"manufacturer\"))\n model = sanitize_text(entry.get(\"model\"))\n if manufacturer or model:\n add(12, \"ssdp device info\", \"ssdp\")\n\n if host.get(\"mac\"):\n add(3, \"mac address observed\", \"mac\")\n\n if len(signals) >= 3:\n add(10, \"multi-signal confirmation\", \"boost\")\n if \"rtsp\" in signals and \"onvif\" in signals:\n add(10, \"rtsp + onvif alignment\", \"boost\")\n\n if score > 100:\n score = 100\n\n level = \"low\"\n if score >= 70:\n level = \"very_high\"\n elif score >= 40:\n level = \"high\"\n elif score >= 20:\n level = \"medium\"\n\n classification = \"camera\"\n model_hint = sanitize_text(profile.get(\"model\"))\n vendor_hint = vendor\n onvif_hint = \"\"\n if onvif_entries:\n for entry in onvif_entries:\n if isinstance(entry, dict):\n onvif_hint += \" \" + sanitize_text(entry.get(\"manufacturer\"))\n onvif_hint += \" \" + sanitize_text(entry.get(\"model\"))\n recorder_blob = f\"{meta_blob} {model_hint} {vendor_hint} {onvif_hint}\"\n if recorder_blob and contains_keyword(recorder_blob, RECORDER_KEYWORDS):\n classification = \"recorder\"\n else:\n protocol_names = {\n sanitize_text(entry.get(\"protocol\"))\n for entry in protocols\n if isinstance(entry, dict)\n }\n if \"WebRTC\" in protocol_names and \"RTSP\" not in protocol_names:\n classification = \"webrtc-camera\"\n elif \"SRT\" in protocol_names:\n classification = \"streamer\"\n\n return {\n \"score\": score,\n \"level\": level,\n \"classification\": classification,\n \"reasons\": reasons[:6],\n \"signals\": sorted(signals),\n }\n\n\ndef main() -> int:\n args = parse_args()\n input_path = Path(args.input)\n output_path = Path(args.output)\n data = load_json(input_path)\n\n hosts = data.get(\"hosts\") or []\n if not isinstance(hosts, list):\n hosts = []\n\n for host in hosts:\n if isinstance(host, dict):\n host[\"confidence\"] = score_host(host)\n\n output_path.parent.mkdir(parents=True, exist_ok=True)\n with output_path.open(\"w\", encoding=\"utf-8\") as handle:\n json.dump(data, handle, indent=2)\n\n return 0\n\n\nif __name__ == \"__main__\": # pragma: no cover\n raise SystemExit(main())\n"
},
{
"file_name": "profile_resolver.py",
"relative_path": "scripts/helpers/profile_resolver.py",
"extension": ".py",
"size_bytes": 18533,
"content": "#!/usr/bin/env python3\n#\n# https://github.com/John0n1/CamSniff\n#\n# Copyright (c) 2026 John Hauger Mitander\n# License: MIT License https://opensource.org/license/MIT\n\n\"\"\"Resolve camera/profile hints based on discovery artefacts.\"\"\"\nfrom __future__ import annotations\n\nimport argparse\nimport csv\nimport json\nimport re\nimport sys\nfrom dataclasses import dataclass, field\nfrom datetime import datetime, timezone\nfrom pathlib import Path\nfrom typing import Any, Dict, List, Optional, Sequence, Tuple\n\n\n@dataclass\nclass HostContext:\n ip: str\n mac: str = \"\"\n ports: Sequence[int] = field(default_factory=list)\n observed_paths: Sequence[str] = field(default_factory=list)\n http_metadata: Sequence[Dict[str, str]] = field(\n default_factory=list\n )\n\n @property\n def http_banners(self) -> List[str]:\n banners: List[str] = []\n for entry in self.http_metadata:\n for key in (\"server\", \"realm\", \"title\"):\n value = (entry.get(key) or \"\").strip()\n if value:\n banners.append(value)\n return banners\n\n\n@dataclass\nclass CatalogRow:\n raw: Dict[str, str]\n company: str\n model: str\n type: str\n oui_regex: str\n rtsp_url: str\n http_snapshot_url: str\n onvif_profile_path: str\n video_encoding: str\n port: Optional[int]\n streams: List[str]\n channels: List[str]\n username: str\n password: str\n is_digest_auth_supported: str\n cve_ids: List[str]\n user_manual_url: str\n\n\nclass ProfileResolver:\n def __init__(self, catalog: Sequence[CatalogRow]):\n self.catalog = catalog\n\n def resolve(\n self, host: HostContext\n ) -> Optional[Tuple[CatalogRow, str]]:\n matches = self.resolve_many(host, limit=1)\n if not matches:\n return None\n row, matched_by, _score = matches[0]\n return row, matched_by\n\n def resolve_many(\n self, host: HostContext, *, limit: int = 3\n ) -> List[Tuple[CatalogRow, str, int]]:\n ranked: List[Tuple[int, CatalogRow, str]] = []\n for row in self.catalog:\n score, matched_by = self._score_row(row, host)\n if score <= 0:\n continue\n ranked.append((score, row, matched_by))\n\n ranked.sort(key=lambda item: item[0], reverse=True)\n trimmed: List[Tuple[CatalogRow, str, int]] = []\n for score, row, matched_by in ranked[: max(limit, 0)]:\n trimmed.append((row, matched_by, score))\n return trimmed\n\n def _score_row(\n self, row: CatalogRow, host: HostContext\n ) -> Tuple[int, str]:\n score = 0\n matched_by = \"\"\n\n mac = host.mac.upper()\n pattern = row.oui_regex\n if mac and pattern:\n try:\n if re.search(pattern, mac, re.IGNORECASE):\n score += 100\n matched_by = \"oui\"\n except re.error:\n pass\n\n if row.port is not None and row.port in host.ports:\n score += 10\n if not matched_by:\n matched_by = \"port\"\n\n vendor = row.company.lower()\n model = row.model.lower()\n for banner in host.http_banners:\n entry = banner.lower()\n if vendor and vendor in entry:\n score += 5\n if not matched_by:\n matched_by = \"http\"\n break\n if model and model in entry:\n score += 4\n if not matched_by:\n matched_by = \"http\"\n break\n\n template_path = _extract_template_path(row.rtsp_url)\n if template_path:\n for observed in host.observed_paths:\n normalized = observed.lower()\n if template_path in normalized:\n score += 2\n if not matched_by:\n matched_by = \"path\"\n break\n\n return score, matched_by\n\n\ndef _extract_template_path(template: str) -> str:\n if not template:\n return \"\"\n lower = template.lower()\n if \"rtsp://\" in lower:\n stripped = lower.split(\"rtsp://\", 1)[1]\n elif \"http://\" in lower:\n stripped = lower.split(\"http://\", 1)[1]\n elif \"https://\" in lower:\n stripped = lower.split(\"https://\", 1)[1]\n else:\n stripped = lower\n path = stripped.split(\"/\", 1)\n if len(path) == 1:\n return \"\"\n return path[1]\n\n\ndef _parse_list(value: str) -> List[str]:\n if not value:\n return []\n return [part.strip() for part in value.split(\";\") if part.strip()]\n\n\ndef _parse_int(value: Optional[str]) -> Optional[int]:\n if value is None:\n return None\n try:\n return int(str(value).strip())\n except (TypeError, ValueError):\n return None\n\n\ndef _load_catalog(path: Path) -> List[CatalogRow]:\n rows: List[CatalogRow] = []\n if not path.exists():\n return rows\n with path.open(\"r\", encoding=\"utf-8\") as handle:\n reader = csv.DictReader(handle)\n for raw in reader:\n port = _parse_int(raw.get(\"port\"))\n rows.append(\n CatalogRow(\n raw=raw,\n company=(raw.get(\"company\") or \"Unknown\").strip(),\n model=(raw.get(\"model\") or \"\").strip(),\n type=(raw.get(\"type\") or \"\").strip(),\n oui_regex=(raw.get(\"oui_regex\") or \"\").strip(),\n rtsp_url=(raw.get(\"rtsp_url\") or \"\").strip(),\n http_snapshot_url=(\n raw.get(\"http_snapshot_url\") or \"\"\n ).strip(),\n onvif_profile_path=(\n raw.get(\"onvif_profile_path\") or \"\"\n ).strip(),\n video_encoding=(\n raw.get(\"video_encoding\") or \"\"\n ).strip(),\n port=port,\n streams=_parse_list(raw.get(\"streams\") or \"\"),\n channels=_parse_list(raw.get(\"channels\") or \"\"),\n username=(raw.get(\"username\") or \"\").strip(),\n password=(raw.get(\"password\") or \"\").strip(),\n is_digest_auth_supported=(\n raw.get(\"is_digest_auth_supported\") or \"\"\n ).strip(),\n cve_ids=_parse_list(raw.get(\"cve_ids\") or \"\"),\n user_manual_url=(\n raw.get(\"user_manual_url\") or \"\"\n ).strip(),\n )\n )\n return rows\n\n\ndef _parse_ports(value: str) -> List[int]:\n if not value:\n return []\n result: List[int] = []\n for token in value.split():\n try:\n result.append(int(token.strip()))\n except ValueError:\n continue\n return result\n\n\ndef _parse_paths(value: str) -> List[str]:\n if not value:\n return []\n return [item.strip() for item in value.split() if item.strip()]\n\n\ndef _parse_http_json(value: str) -> List[Dict[str, str]]:\n if not value:\n return []\n try:\n data = json.loads(value)\n except json.JSONDecodeError:\n return []\n result: List[Dict[str, str]] = []\n if isinstance(data, list):\n for entry in data:\n if isinstance(entry, dict):\n result.append(entry)\n return result\n\n\ndef _build_profile_payload(\n row: CatalogRow, matched_by: str, score: int = 0\n) -> Dict[str, object]:\n def coerce_bool(flag: str) -> bool:\n lowered = (flag or \"\").strip().lower()\n return lowered in {\"1\", \"true\", \"yes\"}\n\n def build_rtsp_candidates() -> List[Dict[str, object]]:\n template = row.rtsp_url\n if not template:\n return []\n streams = row.streams or [\"0\"]\n channels = row.channels or [\"1\"]\n port = row.port if row.port is not None else 554\n candidates: List[Dict[str, object]] = []\n for channel in channels[:3]:\n for stream in streams[:3]:\n candidates.append(\n {\n \"template\": template,\n \"port\": port,\n \"channel\": channel,\n \"stream\": stream,\n \"transport\": \"tcp\",\n }\n )\n if len(candidates) >= 6:\n return candidates\n return candidates\n\n def build_http_candidates() -> List[Dict[str, object]]:\n template = row.http_snapshot_url\n if not template:\n return []\n streams = row.streams or [\"0\"]\n channels = row.channels or [\"1\"]\n port_guess = (\n row.port\n if row.port is not None\n else (443 if template.lower().startswith(\"https\") else 80)\n )\n return [\n {\n \"template\": template,\n \"port\": port_guess,\n \"channel\": channels[0],\n \"stream\": streams[0],\n }\n ]\n\n return {\n \"vendor\": row.company or \"Unknown\",\n \"model\": row.model or \"Unknown\",\n \"type\": row.type or \"Unknown\",\n \"matched_by\": matched_by,\n \"score\": score,\n \"default_username\": row.username,\n \"default_password\": row.password,\n \"digest_auth\": coerce_bool(row.is_digest_auth_supported),\n \"video_encoding\": row.video_encoding,\n \"rtsp_candidates\": build_rtsp_candidates(),\n \"http_snapshot_candidates\": build_http_candidates(),\n \"onvif_profiles\": (\n row.onvif_profile_path.split(\";\")\n if row.onvif_profile_path\n else []\n ),\n \"cve_ids\": row.cve_ids,\n \"reference\": row.user_manual_url,\n }\n\n\ndef _render_text_profile(ip: str, profile: Dict[str, object]) -> str:\n lines: List[str] = []\n lines.append(\n f\" Profile match: {profile.get('vendor')} {profile.get('model')}\"\n )\n match_flag = profile.get(\"matched_by\")\n if match_flag:\n lines.append(f\" Matched via: {match_flag}\")\n rtsp_candidates = profile.get(\"rtsp_candidates\") or []\n if rtsp_candidates:\n first = rtsp_candidates[0]\n template = first.get(\"template\") or \"\"\n port = first.get(\"port\")\n channel = first.get(\"channel\")\n stream = first.get(\"stream\")\n url = template.replace(\"{{ip_address}}\", ip)\n url = url.replace(\"{{port}}\", str(port or 554))\n url = url.replace(\"{{channel}}\", str(channel or \"1\"))\n url = url.replace(\"{{stream}}\", str(stream or \"0\"))\n url = url.replace(\"{{username}}\", \"<username>\")\n url = url.replace(\"{{password}}\", \"<password>\")\n lines.append(f\" Suggested RTSP: {url}\")\n if profile.get(\"default_username\") or profile.get(\n \"default_password\"\n ):\n username = profile.get(\"default_username\") or \"<custom>\"\n password = profile.get(\"default_password\") or \"<password>\"\n lines.append(f\" Default creds: {username}/{password}\")\n encoding = profile.get(\"video_encoding\")\n if encoding:\n lines.append(f\" Encoding: {encoding}\")\n snapshot = profile.get(\"http_snapshot_candidates\") or []\n if snapshot:\n template = snapshot[0].get(\"template\") or \"\"\n if template:\n lines.append(f\" Snapshot template: {template}\")\n if profile.get(\"digest_auth\"):\n lines.append(\" Digest auth: true\")\n cves = profile.get(\"cve_ids\") or []\n if cves:\n lines.append(f\" CVEs: {', '.join(cves)}\")\n reference = profile.get(\"reference\")\n if reference:\n lines.append(f\" Reference: {reference}\")\n return \"\\n\".join(lines)\n\n\ndef command_match(args: argparse.Namespace) -> int:\n catalog = _load_catalog(Path(args.paths))\n resolver = ProfileResolver(catalog)\n context = HostContext(\n ip=args.ip,\n mac=args.mac or \"\",\n ports=_parse_ports(args.ports or \"\"),\n observed_paths=_parse_paths(args.observed or \"\"),\n http_metadata=_parse_http_json(args.http_json or \"\"),\n )\n matches = resolver.resolve_many(context, limit=args.limit)\n if not matches:\n if args.format == \"json\":\n if args.limit == 1:\n json.dump({}, sys.stdout)\n else:\n json.dump([], sys.stdout)\n return 0\n print(\" No catalog profile matched.\")\n return 0\n\n profiles = [\n _build_profile_payload(row, matched_by, score)\n for row, matched_by, score in matches\n ]\n\n if args.format == \"json\":\n if args.limit == 1:\n json.dump(profiles[0], sys.stdout, indent=2)\n else:\n json.dump(profiles, sys.stdout, indent=2)\n return 0\n\n for idx, profile in enumerate(profiles, start=1):\n if args.limit > 1:\n print(f\" Match {idx} of {len(profiles)}:\")\n print(_render_text_profile(args.ip, profile))\n if args.limit > 1 and idx < len(profiles):\n print(\"\")\n return 0\n\n\ndef command_enrich(args: argparse.Namespace) -> int:\n catalog = _load_catalog(Path(args.paths))\n resolver = ProfileResolver(catalog)\n input_path = Path(args.input)\n output_path = Path(args.output)\n\n try:\n with input_path.open(\"r\", encoding=\"utf-8\") as handle:\n data = json.load(handle)\n except FileNotFoundError:\n data = {\"hosts\": []}\n\n hosts = data.get(\"hosts\") or []\n for host in hosts:\n ports = host.get(\"ports\") or []\n observed = host.get(\"observed_paths\") or []\n http_meta = host.get(\"http_metadata\") or []\n mac = host.get(\"mac\") or \"\"\n context = HostContext(\n ip=host.get(\"ip\") or \"\",\n mac=mac,\n ports=[\n value for value in ports if isinstance(value, int)\n ],\n observed_paths=[\n value for value in observed if isinstance(value, str)\n ],\n http_metadata=[\n value\n for value in http_meta\n if isinstance(value, dict)\n ],\n )\n matches = resolver.resolve_many(context, limit=args.limit)\n if not matches:\n continue\n payloads = [\n _build_profile_payload(row, matched_by, score)\n for row, matched_by, score in matches\n ]\n host[\"profile_matches\"] = payloads\n host[\"profile_match\"] = payloads[0]\n\n with output_path.open(\"w\", encoding=\"utf-8\") as handle:\n json.dump(data, handle, indent=2)\n\n return 0\n\ndef command_catalog(args: argparse.Namespace) -> int:\n catalog = _load_catalog(Path(args.paths))\n generated = datetime.now(timezone.utc).isoformat().replace(\n \"+00:00\", \"Z\"\n )\n entries: List[Dict[str, Any]] = []\n for row in catalog:\n entries.append(\n {\n \"vendor\": row.company,\n \"model\": row.model,\n \"type\": row.type,\n \"oui_regex\": row.oui_regex,\n \"rtsp_url\": row.rtsp_url,\n \"http_snapshot_url\": row.http_snapshot_url,\n \"onvif_profile_path\": row.onvif_profile_path,\n \"video_encoding\": row.video_encoding,\n \"port\": row.port,\n \"streams\": row.streams,\n \"channels\": row.channels,\n \"default_username\": row.username,\n \"default_password\": row.password,\n \"digest_auth\": row.is_digest_auth_supported,\n \"cve_ids\": row.cve_ids,\n \"reference\": row.user_manual_url,\n }\n )\n\n payload = {\n \"generated_at\": generated,\n \"count\": len(entries),\n \"entries\": entries,\n }\n\n output = Path(args.output) if args.output else None\n if output:\n output.parent.mkdir(parents=True, exist_ok=True)\n with output.open(\"w\", encoding=\"utf-8\") as handle:\n json.dump(payload, handle, indent=2)\n else:\n json.dump(payload, sys.stdout, indent=2)\n\n return 0\n\n\ndef build_parser() -> argparse.ArgumentParser:\n parser = argparse.ArgumentParser(\n description=\"Resolve CamSniff profile matches\"\n )\n subparsers = parser.add_subparsers(dest=\"command\", required=True)\n\n match_parser = subparsers.add_parser(\n \"match\", help=\"Resolve a single host profile\"\n )\n match_parser.add_argument(\n \"--paths\", required=True, help=\"Path to paths.csv catalog\"\n )\n match_parser.add_argument(\n \"--ip\", required=True, help=\"Host IP address\"\n )\n match_parser.add_argument(\n \"--mac\", default=\"\", help=\"Host MAC address\"\n )\n match_parser.add_argument(\n \"--ports\", default=\"\", help=\"Whitespace-separated port list\"\n )\n match_parser.add_argument(\n \"--observed\",\n default=\"\",\n help=\"Whitespace-separated observed paths\",\n )\n match_parser.add_argument(\n \"--http-json\", default=\"\", help=\"HTTP metadata JSON array\"\n )\n match_parser.add_argument(\n \"--format\", choices=(\"text\", \"json\"), default=\"text\"\n )\n match_parser.add_argument(\n \"--limit\",\n type=int,\n default=1,\n help=\"Return up to N catalog matches (default: 1)\",\n )\n match_parser.set_defaults(func=command_match)\n\n enrich_parser = subparsers.add_parser(\n \"enrich\", help=\"Enrich discovery.json with profile data\"\n )\n enrich_parser.add_argument(\n \"--paths\", required=True, help=\"Path to paths.csv catalog\"\n )\n enrich_parser.add_argument(\n \"--input\", required=True, help=\"Discovery JSON input path\"\n )\n enrich_parser.add_argument(\n \"--output\", required=True, help=\"Discovery JSON output path\"\n )\n enrich_parser.add_argument(\n \"--limit\",\n type=int,\n default=1,\n help=\"Attach up to N catalog matches per host (default: 1)\",\n )\n enrich_parser.set_defaults(func=command_enrich)\n\n catalog_parser = subparsers.add_parser(\n \"catalog\", help=\"Export the profile catalog as JSON\"\n )\n catalog_parser.add_argument(\n \"--paths\", required=True, help=\"Path to paths.csv catalog\"\n )\n catalog_parser.add_argument(\n \"--output\", help=\"Optional output file (defaults to stdout)\"\n )\n catalog_parser.set_defaults(func=command_catalog)\n\n return parser\n\n\ndef main(argv: Optional[Sequence[str]] = None) -> int:\n parser = build_parser()\n args = parser.parse_args(argv)\n return args.func(args)\n\n\nif __name__ == \"__main__\": # pragma: no cover\n sys.exit(main())\n"
},
{
"file_name": "rtsp_stream_summary.py",
"relative_path": "scripts/helpers/rtsp_stream_summary.py",
"extension": ".py",
"size_bytes": 1797,
"content": "#!/usr/bin/env python3\n#\n# https://github.com/John0n1/CamSniff\n#\n# Copyright (c) 2026 John Hauger Mitander\n# License: MIT License https://opensource.org/license/MIT\n\n\"\"\"Summarise ffprobe output for CamSniff.\"\"\"\nfrom __future__ import annotations\n\nimport argparse\nimport json\nfrom pathlib import Path\n\n\ndef parse_args() -> argparse.Namespace:\n parser = argparse.ArgumentParser(\n description=\"Summarise ffprobe JSON output\"\n )\n parser.add_argument(\n \"--input\", required=True, help=\"Path to ffprobe JSON output\"\n )\n parser.add_argument(\n \"--url\", required=True, help=\"RTSP URL that was probed\"\n )\n return parser.parse_args()\n\n\ndef load_probe(path: Path) -> dict:\n try:\n with path.open(\"r\", encoding=\"utf-8\") as handle:\n return json.load(handle)\n except FileNotFoundError:\n return {}\n except json.JSONDecodeError:\n return {}\n\n\ndef build_summary(data: dict, url: str) -> dict:\n streams = data.get(\"streams\") or []\n codec = \"\"\n width = None\n height = None\n fps = \"\"\n\n for stream in streams:\n codec = stream.get(\"codec_name\") or codec\n width = stream.get(\"width\") or width\n height = stream.get(\"height\") or height\n fps = stream.get(\"avg_frame_rate\") or fps\n if codec and width and height:\n break\n\n resolution = None\n if width and height:\n resolution = f\"{width}x{height}\"\n\n return {\n \"url\": url,\n \"codec\": codec or \"\",\n \"resolution\": resolution,\n \"frame_rate\": fps or \"\",\n }\n\n\ndef main() -> int:\n args = parse_args()\n payload = build_summary(load_probe(Path(args.input)), args.url)\n print(json.dumps(payload))\n return 0\n\n\nif __name__ == \"__main__\": # pragma: no cover\n raise SystemExit(main())\n"
},
{
"file_name": "onvif_device_info.py",
"relative_path": "scripts/probes/onvif_device_info.py",
"extension": ".py",
"size_bytes": 1931,
"content": "#!/usr/bin/env python3\n#\n# https://github.com/John0n1/CamSniff\n#\n# Copyright (c) 2026 John Hauger Mitander\n# License: MIT License https://opensource.org/license/MIT\n# shellcheck disable=SC2317\n\n\"\"\"Parse ONVIF GetDeviceInformation SOAP responses.\"\"\"\nfrom __future__ import annotations\n\nimport argparse\nimport json\nimport re\nfrom pathlib import Path\n\n\ndef parse_args() -> argparse.Namespace:\n parser = argparse.ArgumentParser(\n description=\"Extract ONVIF device information\"\n )\n parser.add_argument(\n \"--input\", required=True, help=\"Path to SOAP response payload\"\n )\n parser.add_argument(\n \"--ip\", required=True, help=\"Target IP address\"\n )\n parser.add_argument(\n \"--port\", type=int, required=True, help=\"Target port\"\n )\n parser.add_argument(\"--scheme\", required=True, help=\"HTTP scheme\")\n return parser.parse_args()\n\n\ndef read_payload(path: Path) -> str:\n try:\n return path.read_text(encoding=\"utf-8\", errors=\"ignore\")\n except FileNotFoundError:\n return \"\"\n\n\ndef extract_field(payload: str, tag: str) -> str:\n pattern = rf\"<tds:{tag}>(.*?)</tds:{tag}>\"\n match = re.search(pattern, payload, re.IGNORECASE | re.DOTALL)\n if match:\n return re.sub(r\"\\s+\", \" \", match.group(1)).strip()\n return \"\"\n\n\ndef main() -> int:\n args = parse_args()\n payload = read_payload(Path(args.input))\n manufacturer = extract_field(payload, \"Manufacturer\")\n model = extract_field(payload, \"Model\")\n firmware = extract_field(payload, \"FirmwareVersion\")\n serial = extract_field(payload, \"SerialNumber\")\n\n result = {\n \"ip\": args.ip,\n \"port\": args.port,\n \"scheme\": args.scheme,\n \"manufacturer\": manufacturer,\n \"model\": model,\n \"firmware\": firmware,\n \"serial\": serial,\n }\n\n print(json.dumps(result))\n return 0\n\n\nif __name__ == \"__main__\": # pragma: no cover\n raise SystemExit(main())\n"
},
{
"file_name": "ssdp_probe.py",
"relative_path": "scripts/probes/ssdp_probe.py",
"extension": ".py",
"size_bytes": 5444,
"content": "#!/usr/bin/env python3\n#\n# https://github.com/John0n1/CamSniff\n#\n# Copyright (c) 2026 John Hauger Mitander\n# License: MIT License https://opensource.org/license/MIT\n\n\"\"\"Perform a multicast SSDP discovery sweep.\"\"\"\nfrom __future__ import annotations\n\nimport argparse\nimport json\nimport socket\nimport time\nimport urllib.request\nimport xml.etree.ElementTree as ET\n\nMCAST_GRP = \"239.255.255.250\"\nMCAST_PORT = 1900\n\n\ndef parse_args() -> argparse.Namespace:\n parser = argparse.ArgumentParser(\n description=\"Send SSDP M-SEARCH and capture responses\"\n )\n parser.add_argument(\n \"--timeout\",\n type=float,\n default=4.0,\n help=\"Listen window in seconds\",\n )\n parser.add_argument(\n \"--mx\", type=int, default=2, help=\"MX header value\"\n )\n parser.add_argument(\n \"--st\", default=\"ssdp:all\", help=\"ST header value\"\n )\n parser.add_argument(\n \"--output\",\n help=\"Optional file path to write newline-delimited JSON\",\n )\n parser.add_argument(\n \"--describe\",\n action=\"store_true\",\n help=\"Fetch and parse device descriptions from SSDP location URLs\",\n )\n parser.add_argument(\n \"--describe-timeout\",\n type=float,\n default=3.0,\n help=\"Timeout in seconds for SSDP description fetch\",\n )\n parser.add_argument(\n \"--max-describe\",\n type=int,\n default=24,\n help=\"Maximum number of SSDP description fetches\",\n )\n return parser.parse_args()\n\n\ndef build_message(st: str, mx: int) -> bytes:\n lines = [\n \"M-SEARCH * HTTP/1.1\",\n f\"HOST: {MCAST_GRP}:{MCAST_PORT}\",\n 'MAN: \"ssdp:discover\"',\n f\"MX: {mx}\",\n f\"ST: {st}\",\n \"\",\n \"\",\n ]\n return \"\\r\\n\".join(lines).encode(\"utf-8\")\n\n\ndef collect_responses(\n timeout: float, message: bytes\n) -> list[dict[str, str]]:\n sock = socket.socket(\n socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP\n )\n sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 2)\n sock.settimeout(max(timeout, 0.1))\n\n try:\n sock.sendto(message, (MCAST_GRP, MCAST_PORT))\n except OSError:\n sock.close()\n return []\n\n responses: list[dict[str, str]] = []\n deadline = time.time() + timeout\n\n while time.time() < deadline:\n remaining = deadline - time.time()\n sock.settimeout(max(remaining, 0.1))\n try:\n data, addr = sock.recvfrom(8192)\n except socket.timeout:\n break\n except OSError:\n break\n if not data:\n continue\n text = data.decode(\"utf-8\", errors=\"ignore\")\n headers = {}\n for line in text.splitlines():\n if \":\" in line:\n key, value = line.split(\":\", 1)\n headers[key.strip().lower()] = value.strip()\n responses.append(\n {\n \"ip\": addr[0],\n \"st\": headers.get(\"st\", \"\"),\n \"usn\": headers.get(\"usn\", \"\"),\n \"server\": headers.get(\"server\", \"\"),\n \"location\": headers.get(\"location\", \"\"),\n }\n )\n\n sock.close()\n return responses\n\n\ndef _strip_ns(tag: str) -> str:\n if \"}\" in tag:\n return tag.split(\"}\", 1)[1]\n return tag\n\n\ndef fetch_description(url: str, timeout: float) -> dict[str, str]:\n if not url:\n return {}\n try:\n with urllib.request.urlopen(url, timeout=timeout) as resp:\n payload = resp.read()\n except Exception:\n return {}\n if not payload:\n return {}\n try:\n root = ET.fromstring(payload)\n except ET.ParseError:\n return {}\n fields = {\n \"friendlyName\": \"friendly_name\",\n \"manufacturer\": \"manufacturer\",\n \"modelName\": \"model\",\n \"modelNumber\": \"model_number\",\n \"deviceType\": \"device_type\",\n \"serialNumber\": \"serial\",\n }\n result: dict[str, str] = {}\n for elem in root.iter():\n tag = _strip_ns(elem.tag)\n if tag in fields and elem.text:\n result[fields[tag]] = elem.text.strip()\n return result\n\n\ndef enrich_with_descriptions(\n responses: list[dict[str, str]],\n timeout: float,\n max_fetches: int,\n) -> list[dict[str, str]]:\n seen_locations: set[str] = set()\n count = 0\n for entry in responses:\n location = entry.get(\"location\", \"\")\n if not location:\n continue\n if location in seen_locations:\n continue\n if count >= max_fetches:\n break\n seen_locations.add(location)\n details = fetch_description(location, timeout)\n if details:\n entry.update(details)\n count += 1\n return responses\n\n\ndef emit(responses: list[dict[str, str]], output: str | None) -> None:\n if output:\n with open(output, \"w\", encoding=\"utf-8\") as handle:\n for entry in responses:\n handle.write(json.dumps(entry) + \"\\n\")\n else:\n for entry in responses:\n print(json.dumps(entry))\n\n\ndef main() -> int:\n args = parse_args()\n message = build_message(args.st, args.mx)\n responses = collect_responses(args.timeout, message)\n if args.describe:\n responses = enrich_with_descriptions(\n responses, args.describe_timeout, args.max_describe\n )\n emit(responses, args.output)\n return 0\n\n\nif __name__ == \"__main__\": # pragma: no cover\n raise SystemExit(main())\n"
},
{
"file_name": "report.py",
"relative_path": "scripts/tools/report.py",
"extension": ".py",
"size_bytes": 16793,
"content": "#!/usr/bin/env python3\n#\n# https://github.com/John0n1/CamSniff\n#\n# Copyright (c) 2026 John Hauger Mitander\n# License: MIT License https://opensource.org/license/MIT\n\n\"\"\"Generate markdown or HTML reports from CamSniff output.\"\"\"\nfrom __future__ import annotations\n\nimport argparse\nimport html\nimport json\nfrom collections import Counter\nfrom datetime import datetime, timezone\nfrom pathlib import Path\nfrom typing import Any, Dict, List, Optional, Tuple\n\n\ndef parse_args() -> argparse.Namespace:\n parser = argparse.ArgumentParser(\n description=\"Generate reports from CamSniff JSON output\"\n )\n parser.add_argument(\n \"--discovery\",\n required=True,\n help=\"Path to discovery.json\",\n )\n parser.add_argument(\n \"--credentials\",\n help=\"Optional path to credentials.json\",\n )\n parser.add_argument(\n \"--format\",\n choices=(\"markdown\", \"html\"),\n required=True,\n help=\"Report format\",\n )\n parser.add_argument(\n \"--output\",\n required=True,\n help=\"Output report file path\",\n )\n parser.add_argument(\n \"--run-dir\",\n default=\"\",\n help=\"Optional run directory for context\",\n )\n parser.add_argument(\n \"--run-label\",\n default=\"\",\n help=\"Optional label for the run\",\n )\n return parser.parse_args()\n\n\ndef load_json(path: Path) -> Optional[Any]:\n try:\n with path.open(\"r\", encoding=\"utf-8\") as handle:\n return json.load(handle)\n except (FileNotFoundError, json.JSONDecodeError):\n return None\n\n\ndef get_metadata(discovery: Dict[str, Any]) -> Dict[str, str]:\n meta = discovery.get(\"metadata\") or {}\n return {\n \"mode\": str(meta.get(\"mode\") or \"\"),\n \"generated_at\": str(meta.get(\"generated_at\") or \"\"),\n \"network\": str(meta.get(\"network\") or \"\"),\n }\n\n\ndef summarize_credentials(\n creds: Optional[List[Dict[str, Any]]],\n) -> Tuple[List[Dict[str, Any]], List[Dict[str, Any]]]:\n if not creds:\n return [], []\n successes: List[Dict[str, Any]] = []\n failures: List[Dict[str, Any]] = []\n for entry in creds:\n if entry.get(\"success\") is False:\n failures.append(entry)\n elif entry.get(\"method\"):\n successes.append(entry)\n return successes, failures\n\n\ndef safe_join(values: List[str]) -> str:\n return \", \".join([value for value in values if value])\n\n\ndef build_host_rows(\n hosts: List[Dict[str, Any]],\n success_ips: set[str],\n) -> List[Dict[str, str]]:\n rows: List[Dict[str, str]] = []\n for host in hosts:\n ip = str(host.get(\"ip\") or \"\")\n profile = host.get(\"profile_match\") or {}\n vendor = str(profile.get(\"vendor\") or \"Unknown\")\n model = str(profile.get(\"model\") or \"Unknown\")\n matched_by = str(profile.get(\"matched_by\") or \"\")\n confidence = host.get(\"confidence\") or {}\n confidence_score = str(confidence.get(\"score\") or \"\")\n confidence_level = str(confidence.get(\"level\") or \"\")\n confidence_class = str(confidence.get(\"classification\") or \"\")\n ports = [\n str(port)\n for port in host.get(\"ports\") or []\n if port is not None\n ]\n protocols = [\n str(entry.get(\"protocol\") or \"\")\n for entry in host.get(\"additional_protocols\") or []\n if isinstance(entry, dict)\n ]\n sources = [\n str(source)\n for source in host.get(\"sources\") or []\n if source\n ]\n rows.append(\n {\n \"ip\": ip,\n \"vendor\": vendor,\n \"model\": model,\n \"confidence_score\": confidence_score,\n \"confidence_level\": confidence_level,\n \"confidence_class\": confidence_class,\n \"matched_by\": matched_by,\n \"ports\": safe_join(ports),\n \"protocols\": safe_join(sorted(set(protocols))),\n \"sources\": safe_join(sorted(set(sources))),\n \"credentials\": \"yes\" if ip in success_ips else \"no\",\n }\n )\n return rows\n\n\ndef build_summary(hosts: List[Dict[str, Any]]) -> Dict[str, Any]:\n vendor_counter = Counter()\n port_counter = Counter()\n protocol_counter = Counter()\n source_counter = Counter()\n\n for host in hosts:\n profile = host.get(\"profile_match\") or {}\n vendor = str(profile.get(\"vendor\") or \"Unknown\")\n vendor_counter[vendor] += 1\n\n for port in host.get(\"ports\") or []:\n if port is not None:\n port_counter[str(port)] += 1\n\n for entry in host.get(\"additional_protocols\") or []:\n if isinstance(entry, dict):\n name = str(entry.get(\"protocol\") or \"\")\n if name:\n protocol_counter[name] += 1\n\n for source in host.get(\"sources\") or []:\n if source:\n source_counter[str(source)] += 1\n\n return {\n \"host_count\": len(hosts),\n \"vendors\": vendor_counter,\n \"ports\": port_counter,\n \"protocols\": protocol_counter,\n \"sources\": source_counter,\n }\n\n\ndef render_markdown(\n metadata: Dict[str, str],\n summary: Dict[str, Any],\n host_rows: List[Dict[str, str]],\n confidence_rows: List[Dict[str, str]],\n successes: List[Dict[str, Any]],\n failures: List[Dict[str, Any]],\n run_dir: str,\n run_label: str,\n) -> str:\n lines: List[str] = []\n lines.append(\"# CamSniff Report\")\n lines.append(\"\")\n now = datetime.now(timezone.utc).strftime(\"%Y-%m-%dT%H:%M:%SZ\")\n lines.append(f\"Generated: {now}\")\n if run_label:\n lines.append(f\"Run: {run_label}\")\n if run_dir:\n lines.append(f\"Run directory: {run_dir}\")\n if metadata.get(\"mode\"):\n lines.append(f\"Mode: {metadata.get('mode')}\")\n if metadata.get(\"network\"):\n lines.append(f\"Network: {metadata.get('network')}\")\n if metadata.get(\"generated_at\"):\n lines.append(f\"Discovery timestamp: {metadata.get('generated_at')}\")\n\n lines.append(\"\")\n lines.append(\"## Summary\")\n lines.append(\"\")\n lines.append(f\"- Hosts: {summary['host_count']}\")\n lines.append(f\"- Vendors: {len(summary['vendors'])}\")\n lines.append(f\"- Protocols: {len(summary['protocols'])}\")\n lines.append(f\"- Credential successes: {len(successes)}\")\n lines.append(f\"- Credential failures: {len(failures)}\")\n\n if summary[\"ports\"]:\n lines.append(\"\")\n lines.append(\"## Top Ports\")\n lines.append(\"\")\n lines.append(\"| Port | Count |\")\n lines.append(\"| --- | --- |\")\n for port, count in summary[\"ports\"].most_common(10):\n lines.append(f\"| {port} | {count} |\")\n\n if summary[\"protocols\"]:\n lines.append(\"\")\n lines.append(\"## Protocol Hits\")\n lines.append(\"\")\n lines.append(\"| Protocol | Count |\")\n lines.append(\"| --- | --- |\")\n for name, count in summary[\"protocols\"].most_common(10):\n lines.append(f\"| {name} | {count} |\")\n\n if confidence_rows:\n lines.append(\"\")\n lines.append(\"## Top Confidence\")\n lines.append(\"\")\n lines.append(\n \"| IP | Score | Level | Class | Reasons |\"\n )\n lines.append(\n \"| --- | --- | --- | --- | --- |\"\n )\n for row in confidence_rows:\n lines.append(\n f\"| {row['ip']} | {row['score']} | {row['level']} | \"\n f\"{row['classification']} | {row['reasons']} |\"\n )\n\n if host_rows:\n lines.append(\"\")\n lines.append(\"## Hosts\")\n lines.append(\"\")\n lines.append(\n \"| IP | Vendor | Model | Confidence | Class | Ports | Protocols | Credentials |\"\n )\n lines.append(\n \"| --- | --- | --- | --- | --- | --- | --- | --- |\"\n )\n for row in host_rows:\n lines.append(\n f\"| {row['ip']} | {row['vendor']} | {row['model']} | \"\n f\"{row['confidence_score']} {row['confidence_level']} | \"\n f\"{row['confidence_class']} | {row['ports']} | \"\n f\"{row['protocols']} | {row['credentials']} |\"\n )\n\n if successes:\n lines.append(\"\")\n lines.append(\"## Credential Successes\")\n lines.append(\"\")\n for entry in successes:\n ip = entry.get(\"ip\") or \"\"\n method = entry.get(\"method\") or \"\"\n user = entry.get(\"credentials\", {}).get(\"username\") or \"\"\n password = entry.get(\"credentials\", {}).get(\"password\") or \"\"\n url = entry.get(\"url\") or \"\"\n lines.append(\n f\"- {ip} ({method}): `{user}` / `{password}` -> {url}\"\n )\n\n return \"\\n\".join(lines) + \"\\n\"\n\n\ndef render_html(\n metadata: Dict[str, str],\n summary: Dict[str, Any],\n host_rows: List[Dict[str, str]],\n confidence_rows: List[Dict[str, str]],\n successes: List[Dict[str, Any]],\n failures: List[Dict[str, Any]],\n run_dir: str,\n run_label: str,\n) -> str:\n def esc(value: str) -> str:\n return html.escape(value or \"\")\n\n now = datetime.now(timezone.utc).strftime(\"%Y-%m-%dT%H:%M:%SZ\")\n head = \"\"\"\n<!doctype html>\n<html lang=\"en\">\n<head>\n <meta charset=\"utf-8\" />\n <title>CamSniff Report</title>\n <style>\n body { font-family: Arial, sans-serif; margin: 32px; color: #1f1f1f; }\n h1 { margin-bottom: 0.2em; }\n .meta { color: #555; font-size: 0.95em; }\n table { border-collapse: collapse; margin: 12px 0 24px; width: 100%; }\n th, td { border: 1px solid #ddd; padding: 8px; text-align: left; }\n th { background: #f3f3f3; }\n .chip { display: inline-block; padding: 2px 8px; border-radius: 12px; background: #eef2f7; }\n .section { margin-top: 24px; }\n code { background: #f6f6f6; padding: 2px 4px; border-radius: 4px; }\n </style>\n</head>\n<body>\n\"\"\"\n meta_lines = [\n f\"<div class='meta'>Generated: {esc(now)}</div>\"\n ]\n if run_label:\n meta_lines.append(\n f\"<div class='meta'>Run: {esc(run_label)}</div>\"\n )\n if run_dir:\n meta_lines.append(\n f\"<div class='meta'>Run directory: {esc(run_dir)}</div>\"\n )\n if metadata.get(\"mode\"):\n meta_lines.append(\n f\"<div class='meta'>Mode: {esc(metadata['mode'])}</div>\"\n )\n if metadata.get(\"network\"):\n meta_lines.append(\n f\"<div class='meta'>Network: {esc(metadata['network'])}</div>\"\n )\n if metadata.get(\"generated_at\"):\n meta_lines.append(\n f\"<div class='meta'>Discovery timestamp: \"\n f\"{esc(metadata['generated_at'])}</div>\"\n )\n\n summary_html = f\"\"\"\n<div class=\"section\">\n <h2>Summary</h2>\n <div class=\"meta\">Hosts: {summary['host_count']}</div>\n <div class=\"meta\">Vendors: {len(summary['vendors'])}</div>\n <div class=\"meta\">Protocols: {len(summary['protocols'])}</div>\n <div class=\"meta\">Credential successes: {len(successes)}</div>\n <div class=\"meta\">Credential failures: {len(failures)}</div>\n</div>\n\"\"\"\n\n def table_from_counter(\n title: str, counter: Counter\n ) -> str:\n if not counter:\n return \"\"\n rows = \"\\n\".join(\n f\"<tr><td>{esc(key)}</td><td>{count}</td></tr>\"\n for key, count in counter.most_common(10)\n )\n return f\"\"\"\n<div class=\"section\">\n <h2>{esc(title)}</h2>\n <table>\n <thead><tr><th>Item</th><th>Count</th></tr></thead>\n <tbody>{rows}</tbody>\n </table>\n</div>\n\"\"\"\n\n hosts_html = \"\"\n if host_rows:\n rows = \"\\n\".join(\n \"<tr>\"\n f\"<td>{esc(row['ip'])}</td>\"\n f\"<td>{esc(row['vendor'])}</td>\"\n f\"<td>{esc(row['model'])}</td>\"\n f\"<td>{esc(row['confidence_score'])} {esc(row['confidence_level'])}</td>\"\n f\"<td>{esc(row['confidence_class'])}</td>\"\n f\"<td>{esc(row['ports'])}</td>\"\n f\"<td>{esc(row['protocols'])}</td>\"\n f\"<td><span class='chip'>{esc(row['credentials'])}</span></td>\"\n \"</tr>\"\n for row in host_rows\n )\n hosts_html = f\"\"\"\n<div class=\"section\">\n <h2>Hosts</h2>\n <table>\n <thead>\n <tr>\n <th>IP</th><th>Vendor</th><th>Model</th><th>Confidence</th>\n <th>Class</th><th>Ports</th><th>Protocols</th><th>Credentials</th>\n </tr>\n </thead>\n <tbody>\n {rows}\n </tbody>\n </table>\n</div>\n\"\"\"\n\n confidence_html = \"\"\n if confidence_rows:\n rows = \"\\n\".join(\n \"<tr>\"\n f\"<td>{esc(row['ip'])}</td>\"\n f\"<td>{esc(row['score'])}</td>\"\n f\"<td>{esc(row['level'])}</td>\"\n f\"<td>{esc(row['classification'])}</td>\"\n f\"<td>{esc(row['reasons'])}</td>\"\n \"</tr>\"\n for row in confidence_rows\n )\n confidence_html = f\"\"\"\n<div class=\"section\">\n <h2>Top Confidence</h2>\n <table>\n <thead>\n <tr>\n <th>IP</th><th>Score</th><th>Level</th>\n <th>Class</th><th>Reasons</th>\n </tr>\n </thead>\n <tbody>\n {rows}\n </tbody>\n </table>\n</div>\n\"\"\"\n\n cred_html = \"\"\n if successes:\n entries = []\n for entry in successes:\n ip = esc(str(entry.get(\"ip\") or \"\"))\n method = esc(str(entry.get(\"method\") or \"\"))\n user = esc(str(entry.get(\"credentials\", {}).get(\"username\") or \"\"))\n password = esc(str(entry.get(\"credentials\", {}).get(\"password\") or \"\"))\n url = esc(str(entry.get(\"url\") or \"\"))\n entries.append(\n f\"<li>{ip} ({method}): \"\n f\"<code>{user}</code> / <code>{password}</code> \"\n f\"-> {url}</li>\"\n )\n cred_html = f\"\"\"\n<div class=\"section\">\n <h2>Credential Successes</h2>\n <ul>\n {''.join(entries)}\n </ul>\n</div>\n\"\"\"\n\n tail = \"</body></html>\"\n\n return (\n head\n + \"<h1>CamSniff Report</h1>\"\n + \"\".join(meta_lines)\n + summary_html\n + table_from_counter(\"Top Ports\", summary[\"ports\"])\n + table_from_counter(\"Protocol Hits\", summary[\"protocols\"])\n + confidence_html\n + hosts_html\n + cred_html\n + tail\n )\n\n\ndef main() -> int:\n args = parse_args()\n discovery_path = Path(args.discovery)\n discovery = load_json(discovery_path) or {}\n if not isinstance(discovery, dict):\n discovery = {}\n hosts = discovery.get(\"hosts\") or []\n if not isinstance(hosts, list):\n hosts = []\n\n creds_data = None\n if args.credentials:\n creds = load_json(Path(args.credentials))\n if isinstance(creds, list):\n creds_data = creds\n\n successes, failures = summarize_credentials(creds_data)\n success_ips = {\n str(entry.get(\"ip\") or \"\")\n for entry in successes\n if entry.get(\"ip\")\n }\n\n metadata = get_metadata(discovery)\n summary = build_summary(hosts)\n host_rows = build_host_rows(hosts, success_ips)\n confidence_rows: List[Dict[str, str]] = []\n for host in hosts:\n if not isinstance(host, dict):\n continue\n conf = host.get(\"confidence\") or {}\n if not isinstance(conf, dict):\n continue\n score = conf.get(\"score\", 0)\n try:\n score_int = int(score)\n except (TypeError, ValueError):\n score_int = 0\n reasons = conf.get(\"reasons\") or []\n if isinstance(reasons, list):\n reasons_text = \", \".join(\n str(item) for item in reasons if item\n )\n else:\n reasons_text = str(reasons)\n confidence_rows.append(\n {\n \"ip\": str(host.get(\"ip\") or \"\"),\n \"score\": str(score_int),\n \"level\": str(conf.get(\"level\") or \"\"),\n \"classification\": str(conf.get(\"classification\") or \"\"),\n \"reasons\": reasons_text,\n }\n )\n confidence_rows.sort(\n key=lambda row: int(row.get(\"score\") or 0), reverse=True\n )\n confidence_rows = confidence_rows[:10]\n\n if args.format == \"markdown\":\n output = render_markdown(\n metadata,\n summary,\n host_rows,\n confidence_rows,\n successes,\n failures,\n args.run_dir,\n args.run_label,\n )\n else:\n output = render_html(\n metadata,\n summary,\n host_rows,\n confidence_rows,\n successes,\n failures,\n args.run_dir,\n args.run_label,\n )\n\n output_path = Path(args.output)\n output_path.parent.mkdir(parents=True, exist_ok=True)\n output_path.write_text(output, encoding=\"utf-8\")\n return 0\n\n\nif __name__ == \"__main__\": # pragma: no cover\n raise SystemExit(main())\n"
}
]