hsmoying 2e766ce234 fix dahua snapshot
fix(dahua): restore independent requests for DigestAuth snapshot

Ingram-master 新版引入 self.session 持久会话以复用 keep-alive,
但 Dahua 设备 HTTP Server 存在奇葩行为:有 cookie 时忽略
Authorization header。

根因:
  verify() 用 self.session.post(RPC2_Login) → session 内部残留 cookie
  exploit() 用同一 self.session.get(snapshot, auth=DigestAuth)
  → 大华设备优先看无效 cookie → 忽略 Digest Auth → 401 无快照

修复:
  1. 3 个 Dahua RPC2_Login POC 的 verify() 回退为独立 requests.post
  2. base._snapshot() 有 auth 时用独立 requests.get,无 auth 保留 session

fix(dahua): restore independent requests for DigestAuth snapshot

Ingram-master introduced self.session to reuse TCP connections via
keep-alive, but Dahua HTTP servers ignore Authorization headers
when a cookie is present.

Root cause:
  verify() posts RPC2_Login via self.session → cookie leaks into session
  exploit() reuses same session for DigestAuth snapshot request
  → server sees stale cookie → ignores Digest Auth → returns 401

Fix:
  1. 3 Dahua RPC2_Login POCs use independent requests.post for verify()
  2. base._snapshot() uses independent requests.get when auth is present,
     keeps self.session for auth-less requests (preserves keep-alive)
2026-10-13 05:22:54 +08:00
2026-10-13 05:22:54 +08:00
pr
2022-08-17 18:49:38 +08:00
2022-08-17 14:36:05 +08:00
2023-09-19 22:12:24 +08:00
2026-05-20 18:06:29 +08:00

Ingram
Platform Python Version GitHub Github Checks GitHub Last Commit (master) Languages Count

English | 简体中文

Intro

This is a web camera device vulnerability scanning tool, which already supports Hikvision, Dahua and other devices

run

Installation

Please run it under Linux or Mac. Please make sure you have installed Python >= 3.8, but 3.11 is not recommended.

  • Firstly, clone this repo:
git clone https://github.com/jorhelp/Ingram.git
  • Then, go to the repo dir, create a virtual environment and activate it:
cd Ingram
pip3 install virtualenv
python3 -m virtualenv venv
source venv/bin/activate
  • After that, install dependencies:
pip3 install -r requirements.txt

So far, it has been installed!

Run

  • Since it is configured in a virtual environment, pls activate the virtual environment before each running

  • You need to prepare an target file, let's name it input, which contains the targets that will be scanned. The content of input file can be:

# use '#' to comment

# single ip
192.168.0.1

# ip with a port
192.168.0.2:80

# ip segment ('/')
192.168.0.0/16

# ip segment ('-')
192.168.0.0-192.168.255.255
  • With the input file, let's start scanning:
python3 run_ingram.py -i input -o output
  • If you specified the port like: x.x.x.x:80, then the port 80 will be scanned, otherwise common ports will be scanned(defined in Ingram/config.py). And you can also override it with the -p argument such as:
python3 run_ingram.py -i input -o output -p 80 81 8000
  • The number of coroutines can be controlled by the -t argument:
python3 run_ingram.py -i input -o output -t 500
  • all arguments:
optional arguments:
  -h, --help            show this help message and exit
  -i IN_FILE, --in_file IN_FILE
                        the targets will be scan
  -o OUT_DIR, --out_dir OUT_DIR
                        the dir where results will be saved
  -p PORTS [PORTS ...], --ports PORTS [PORTS ...]
                        the port(s) to detect
  -t TH_NUM, --th_num TH_NUM
                        the processes num
  -T TIMEOUT, --timeout TIMEOUT
                        requests timeout
  -D, --disable_snapshot
                        disable snapshot
  --debug

Port scanner

  • We can use powerful port scanner to obtain active hosts, thereby reducing the scanning range of Ingram and improving the running speed. The specific method is to organize the result file of the port scanner into the format of ip:port and use it as the input file of Ingram

  • Here is a brief demonstration of masscan as an example (the detailed usage of masscan will not be repeated here).

  • First, use masscan to scan the surviving host on port 80 or 8000-8008 (you sure can change the port anything else if you want): masscan -p80,8000-8008 -iL INPUT -oL OUTPUT --rate 8000

  • After masscan is done, sort out the result file: grep 'open' OUTPUT | awk '{printf"%s:%s\n", $4, $3}' > input

  • Then: python run_ingram.py -i input -o output

Output

.
├── not_vulnerable.csv
├── results.csv
├── snapshots
└── log.txt
  • results.csv contains the vulnerable devices: ip,port,device-type,user,password,vul:
Ingram
  • not_vulnerable.csv contains the not vulnerable devices

  • snapshots contains some snapshots of a part of devices (not all device can have a snapshot!!!):

Ingram

Warning

This tool is for security testing only, it is strictly prohibited to use it for illegal purposes, and the consequences have nothing to do with this team.

Thanks & Reference

Thanks to Aiminsun for CVE-2021-36260
Thanks to chrisjd20 for hidvision config file decryptor
Thanks to mcw0 for DahuaConsole

S
Description
网络摄像头漏洞扫描工具 | Webcam vulnerability scanning tool
Readme GPL-3.0 19 MiB
Languages
Python 100%