# s0ulle33/asleep_scanner architecture

> Architecture diagram of the GitHub repository s0ulle33/asleep_scanner, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/s0ulle33/asleep_scanner
- Repository: https://github.com/s0ulle33/asleep_scanner

## Overview

Asleep Scanner is a command-line Dahua DVR discovery and credential-testing tool. Its documented workflow takes IP ranges or supplied hosts, optionally uses Masscan to find devices, tries configured credential combinations against Dahua’s port protocol, and can capture snapshots and export results. Country-based range selection, SMART PSS XML, dead-camera output, and Telegram posting are additional capabilities. The source index and excerpts support the main module relationships; some orchestration details and optional integrations are documented but not fully shown.

Main entry points: [`asleep.py`](https://github.com/s0ulle33/asleep_scanner/blob/master/asleep.py) (CLI workflow), [`brute.py`](https://github.com/s0ulle33/asleep_scanner/blob/master/brute.py) (Brute workers), [`snapshot.py`](https://github.com/s0ulle33/asleep_scanner/blob/master/snapshot.py) (Snapshot workers), [`bot.py`](https://github.com/s0ulle33/asleep_scanner/blob/master/bot.py) (Telegram posting)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_discovery["Target Discovery"]
  node_cli["CLI workflow<br/>[asleep.py]"]
  node_geo["Country ranges<br/>[geolocation.py]"]
  node_masscan["Masscan"]
  node_hostparse["Host parsing<br/>[utils.py]"]
end

subgraph group_auth["Device Access"]
  node_brute["Brute workers<br/>[brute.py]"]
  node_protocol["Dahua protocol<br/>[dahua.py]"]
end

subgraph group_outputs["Results and Media"]
  node_snapshots["Snapshot workers<br/>[snapshot.py]"]
  node_imagefilter["Image filtering<br/>[snapshot.py]"]
  node_reports["CSV and dead-camera output<br/>[export.py]"]
  node_xml["SMART PSS XML<br/>[export.py]"]
  node_telegram["Telegram posting<br/>[bot.py]"]
end

subgraph group_support["Configuration"]
  node_credentials["Credential setup<br/>[utils.py]"]
  node_config["Runtime configuration<br/>[config.py]"]
  node_color["Terminal styling<br/>[paint.py]"]
end

node_operator(("Operator"))
node_telegramservice["Telegram"]

node_operator -->|"runs"| node_cli
node_cli -->|"selects ranges"| node_geo
node_cli -->|"starts scan"| node_masscan
node_masscan -->|"provides results"| node_cli
node_cli -->|"parses hosts"| node_hostparse
node_cli -->|"loads credentials"| node_credentials
node_cli -->|"dispatches hosts"| node_brute
node_brute -->|"authenticates"| node_protocol
node_brute -->|"queues devices"| node_snapshots
node_snapshots -->|"requests images"| node_protocol
node_snapshots -->|"filters images"| node_imagefilter
node_imagefilter -->|"formats status"| node_color
node_cli -.->|"exports results"| node_reports
node_cli -.->|"exports XML"| node_xml
node_cli -.->|"may start poster"| node_telegram
node_telegram -->|"sends photos"| node_telegramservice
node_cli -->|"configures runtime"| node_config
node_brute -->|"reads credentials"| node_config

click node_cli "https://github.com/s0ulle33/asleep_scanner/blob/master/asleep.py"
click node_geo "https://github.com/s0ulle33/asleep_scanner/blob/master/geolocation.py"
click node_hostparse "https://github.com/s0ulle33/asleep_scanner/blob/master/utils.py"
click node_credentials "https://github.com/s0ulle33/asleep_scanner/blob/master/utils.py"
click node_config "https://github.com/s0ulle33/asleep_scanner/blob/master/config.py"
click node_brute "https://github.com/s0ulle33/asleep_scanner/blob/master/brute.py"
click node_protocol "https://github.com/s0ulle33/asleep_scanner/blob/master/dahua.py"
click node_snapshots "https://github.com/s0ulle33/asleep_scanner/blob/master/snapshot.py"
click node_imagefilter "https://github.com/s0ulle33/asleep_scanner/blob/master/snapshot.py"
click node_reports "https://github.com/s0ulle33/asleep_scanner/blob/master/export.py"
click node_xml "https://github.com/s0ulle33/asleep_scanner/blob/master/export.py"
click node_telegram "https://github.com/s0ulle33/asleep_scanner/blob/master/bot.py"
click node_color "https://github.com/s0ulle33/asleep_scanner/blob/master/paint.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_geo,node_masscan,node_hostparse toneBlue
class node_brute,node_protocol toneAmber
class node_snapshots,node_imagefilter,node_reports,node_xml,node_telegram toneMint
class node_credentials,node_config,node_color toneRose
class node_operator,node_telegramservice toneIndigo
```

## Components

### Target Discovery

- [CLI workflow](https://github.com/s0ulle33/asleep_scanner/blob/master/asleep.py): `asleep.py`
- [Country ranges](https://github.com/s0ulle33/asleep_scanner/blob/master/geolocation.py): `geolocation.py`
- **Masscan**
- [Host parsing](https://github.com/s0ulle33/asleep_scanner/blob/master/utils.py): `utils.py`

### Device Access

- [Brute workers](https://github.com/s0ulle33/asleep_scanner/blob/master/brute.py): `brute.py`
- [Dahua protocol](https://github.com/s0ulle33/asleep_scanner/blob/master/dahua.py): `dahua.py`

### Results and Media

- [Snapshot workers](https://github.com/s0ulle33/asleep_scanner/blob/master/snapshot.py): `snapshot.py`
- [Image filtering](https://github.com/s0ulle33/asleep_scanner/blob/master/snapshot.py): `snapshot.py`
- [CSV and dead-camera output](https://github.com/s0ulle33/asleep_scanner/blob/master/export.py): `export.py`
- [SMART PSS XML](https://github.com/s0ulle33/asleep_scanner/blob/master/export.py): `export.py`
- [Telegram posting](https://github.com/s0ulle33/asleep_scanner/blob/master/bot.py): `bot.py`

### Configuration

- [Credential setup](https://github.com/s0ulle33/asleep_scanner/blob/master/utils.py): `utils.py`
- [Runtime configuration](https://github.com/s0ulle33/asleep_scanner/blob/master/config.py): `config.py`
- [Terminal styling](https://github.com/s0ulle33/asleep_scanner/blob/master/paint.py): `paint.py`

### Other components

- **Operator**
- **Telegram**

## Connections

- Operator → CLI workflow: runs (evidence: `README.md`)
- CLI workflow → Country ranges: selects ranges (evidence: `asleep.py`)
- CLI workflow → Masscan: starts scan (evidence: `README.md`)
- Masscan → CLI workflow: provides results (evidence: `README.md`)
- CLI workflow → Host parsing: parses hosts (evidence: `asleep.py`)
- CLI workflow → Credential setup: loads credentials (evidence: `asleep.py`)
- CLI workflow → Brute workers: dispatches hosts (evidence: `asleep.py`)
- Brute workers → Dahua protocol: authenticates (evidence: `brute.py`)
- Brute workers → Snapshot workers: queues devices (evidence: `brute.py`)
- Snapshot workers → Dahua protocol: requests images (evidence: `snapshot.py`)
- Snapshot workers → Image filtering: filters images (evidence: `snapshot.py`)
- Image filtering → Terminal styling: formats status (evidence: `snapshot.py`)
- CLI workflow → CSV and dead-camera output: exports results (evidence: `asleep.py`)
- CLI workflow → SMART PSS XML: exports XML (evidence: `asleep.py`)
- CLI workflow → Telegram posting: may start poster (evidence: `asleep.py`)
- Telegram posting → Telegram: sends photos (evidence: `bot.py`)
- CLI workflow → Runtime configuration: configures runtime (evidence: `asleep.py`)
- Brute workers → Runtime configuration: reads credentials (evidence: `brute.py`)
