Skip to content

Commit f893a4b

Browse files
committed
pr
1 parent 947ea73 commit f893a4b

File tree

8 files changed

+92
-132
lines changed

8 files changed

+92
-132
lines changed

.gitignore

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
.git
2-
.DS_store
3-
__pycache__/
4-
/out/
5-
/test*
1+
.git
2+
.DS_store
3+
__pycache__/
4+
/out/
5+
/test*

Ingram/core/main.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class Core:
5353

5454
def __init__(self):
5555
self.data = Data(config['IN'], config['OUT'])
56-
self.workshop = Workshop(os.path.join(config['OUT'], 'snapshot'), config['TH'] // 4)
56+
self.workshop = Workshop(os.path.join(config['OUT'], 'snapshots'), config['TH'] // 4)
5757
self.scan = Scan(self.data, self.workshop, config['PORT'])
5858
self.status = Thread(target=status, args=(self, ))
5959
self.consumer = Thread(target=consumer, args=(self, ))

Ingram/core/workshop.py

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ def __init__(self, output, th_num=8):
2020
def preprocess(self):
2121
if os.path.exists(self.output):
2222
self.done = len(os.listdir(self.output))
23+
else:
24+
os.mkdir(self.output)
2325

2426
def put(self, msg):
2527
with self.var_lock:

Ingram/middleware/shop.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ def _snapshot_by_url(url, file_name, workshop, auth=None):
2828

2929
def snapshot(camera_info, workshop):
3030
"""select diff func to save snapshot"""
31-
path = os.path.join(config['OUT'], 'snapshot')
32-
if not os.path.exists(path):
33-
os.mkdir(path)
31+
path = workshop.output
3432
snapshot_by_url = partial(_snapshot_by_url, workshop=workshop)
3533

3634
ip, port, device, user, passwd, vul = camera_info[:6]

Ingram/utils/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
from Ingram.utils.logo import logo
77
from Ingram.utils.color import color
88
from Ingram.utils.config import config
9+
from Ingram.utils.wechat import wx_send
910
from Ingram.utils.argparse import get_parse
1011
from Ingram.utils.log import logger, config_logger

Ingram/utils/wechat.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
from Ingram.utils import config
44

55

6-
def send_msg(content: str = "default weechat msg") -> dict:
7-
return WxPusher.send_message(uids=config['UIDS'], token=config['TOKEN'], content=f'{content}')
6+
def wx_send(content: str = "default weechat msg") -> dict:
7+
return WxPusher.send_message(uids=[config['UIDS'], ], token=config['TOKEN'], content=f'{content}')

README.md

+74-121
Original file line numberDiff line numberDiff line change
@@ -1,192 +1,145 @@
11
<div align=center>
2-
<img alt="Ingram" src="https://github.com/jorhelp/Ingram/blob/master/statics/imgs/logo.png">
2+
<img alt="Ingram" src="https://github.com/jorhelp/Ingram/blob/master/Ingram/static/imgs/logo.png">
33
</div>
44

55

6-
+ new features: support windows, reconstructure, async, msg-queue, not masscan
7-
8-
96
<!-- icons -->
107
<div align=center>
8+
<img alt="Platform" src="https://img.shields.io/badge/platform-Linux%20|%20Mac-lightgrey.svg">
9+
<img alt="Python Version" src="https://img.shields.io/badge/python-3.7|3.8-yellow.svg">
1110
<img alt="GitHub" src="https://img.shields.io/github/license/jorhelp/Ingram">
12-
<img alt="GitHub issues" src="https://img.shields.io/github/issues/jorhelp/Ingram">
13-
<img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/jorhelp/Ingram">
14-
<img alt="GitHub last commit (branch)" src="https://img.shields.io/github/last-commit/jorhelp/Ingram/master">
11+
<img alt="Languages Count" src="https://img.shields.io/github/languages/count/jorhelp/Ingram?style=social">
12+
<img alt="Github Checks" src="https://img.shields.io/github/checks-status/jorhelp/Ingram/master">
13+
<img alt="GitHub Issues" src="https://img.shields.io/github/issues/jorhelp/Ingram">
14+
<img alt="GitHub Last Commit (master)" src="https://img.shields.io/github/last-commit/jorhelp/Ingram/master">
1515
</div>
1616

1717

18-
English | [简体中文](https://github.com/jorhelp/Ingram/blob/master/README_CN.md)
19-
20-
21-
## Introduction
18+
## 简介
2219

20+
主要针对网络摄像头的漏洞扫描框架,目前已集成海康、大华、宇视等常见设备。后期会加入更多摄像头设备和路由器设备。
2321
![](statics/imgs/run_time.gif)
2422

25-
Schools, hospitals, shopping malls, restaurants, and other places where equipment is not well maintained, there will always be vulnerabilities, either because they are not patched in time or because weak passwords are used to save trouble.
26-
27-
This tool can use multiple threads to batch detect whether there are vulnerabilities in the cameras on the local or public network, so as to repair them in time and improve device security.
23+
## 安装
2824

29-
**Only successfully tested on Mac and Linux, but not on Windows!**
25+
**Windows 仍有部分bug,Linux 与 Mac可以正常使用。请确保安装了3.7及以上版本的Python,推荐3.8**
3026

31-
32-
## Installation
33-
34-
+ Clone this repository by:
27+
+ 克隆该仓库:
3528
```bash
3629
git clone https://github.com/jorhelp/Ingram.git
3730
```
3831

39-
+ **Make sure the Python version you use is >= 3.7**, and install packages by:
32+
+ 进入项目目录安装依赖:
4033
```bash
4134
cd Ingram
4235
pip install git+https://github.com/arthaud/python3-pwntools.git
4336
pip install -r requirements.txt
4437
```
4538

39+
至此安装完毕!
4640

47-
## Preparation
4841

49-
+ You should prepare a target file, which contains the ip addresses will be scanned. The following formats are allowed:
42+
## 运行
43+
44+
+ 你需要准备一个目标文件,比如 target.txt,里面保存着你要扫描的 IP 地址,每行一个目标,具体格式如下:
5045
```
51-
# Use '#' to comment (must have a single line!!)
52-
# Single ip
46+
# 你可以使用井号(#)来进行注释
47+
# 单个的 IP 地址
5348
192.168.0.1
54-
# IP segment with '/'
49+
# IP 地址以及要扫描的端口
50+
192.168.0.2:80
51+
# 带 '/' 的IP段
5552
192.168.0.0/16
56-
# IP segment with '-'
53+
# '-' 的IP段
5754
192.168.0.0-192.168.255.255
5855
```
5956

60-
+ The `utils/config.py` file already specifies some usernames and passwords to support weak password scanning. You can expand or decrease it:
61-
```python
62-
# camera
63-
USERS = ['admin']
64-
PASSWORDS = ['admin', 'admin12345', 'asdf1234', '12345admin', '12345abc']
65-
```
66-
67-
+ (**Optional**) If you use wechat app, and want to get a reminder on your phone. You need to follow [wxpusher](https://wxpusher.zjiecode.com/docs/) instructions to get your *UID* and *APP_TOKEN*, and write them to `utils/config.py`:
68-
```python
69-
# wechat
70-
UIDS = ['This is your UID', 'This is another UID if you have', ...]
71-
TOKEN = 'This is your APP_TOKEN'
72-
```
73-
74-
+ (**Optional**) Email is not supported yet...
75-
76-
77-
## Run
78-
79-
```shell
80-
optional arguments:
81-
-h, --help show this help message and exit
82-
--in_file IN_FILE the targets will be scan
83-
--out_path OUT_PATH the path where results saved
84-
--send_msg send finished msg to you (by wechat or email)
85-
--all scan all the modules of [hik_weak, dahua_weak, cve_...]
86-
--hik_weak
87-
--dahua_weak
88-
--cctv_weak
89-
--hb_weak
90-
--cve_2021_36260
91-
--cve_2021_33044
92-
--cve_2021_33045
93-
--cve_2017_7921
94-
--cve_2020_25078
95-
--th_num TH_NUM the processes num
96-
--nosnap do not capture snapshot
97-
--masscan run masscan sanner
98-
--port PORT same as masscan port
99-
--rate RATE same as masscan rate
100-
```
101-
102-
+ Scan with all modules (**TARGET** is your ip file, **OUT_DIR** is the path where results will be saved):
57+
+ 之后运行:
10358
```bash
104-
# th_num number of threads needs to be adjusted by yourself to state of your network
105-
./run_ingram.py --in TARGET --out OUT_DIR --all --th_num 80
106-
107-
# If you use wechat, then the --send_msg should be provided:
108-
./run_ingram.py --in TARGET --out OUT_DIR --all --th_num 80 --send_msg
59+
python run_ingram.py -i 你要扫描的文件 -o 输出文件夹
10960
```
11061

111-
+ Snapshots (Snapshoting is supported by default, but you can disable it with --nosnap if you think it's too slow)
112-
```bash
113-
./run_ingram.py --in TARGET --out OUT_DIR --all --th_num 80 --nosnap
114-
```
115-
116-
+ There are some *IP FILE* in `statics/iplist/data/` that you can use, for example:
117-
```bash
118-
./run_ingram.py --in statics/iplist/data/country/JP.txt --out OUT_DIR --all --th_num 80
62+
+ 其他参数:
11963
```
120-
121-
+ All modules can be combined arbitrarily to scan, for example, if you want to scan Hikvision, then:
122-
```bash
123-
./run_ingram.py --in TARGET --out OUT_DIR --hik_weak --cve_2017_7921 --cve_2021_36260 --th_num 80
64+
optional arguments:
65+
-h, --help 打印参数信息
66+
-i IN_FILE, --in_file IN_FILE
67+
要扫描的文件
68+
-o OUT_DIR, --out_dir OUT_DIR
69+
扫描结果输出路径
70+
-p PORT [PORT ...], --port PORT [PORT ...]
71+
要扫描的端口,默认为80,可以指定多个端口,比如 -p 80 81 82
72+
-t TH_NUM, --th_num TH_NUM
73+
并发数目,默认为64,视网络状况自行调整
74+
-T TIME_OUT, --time_out TIME_OUT
75+
超时
76+
--debug 调试模式
12477
```
12578

126-
+ Direct scanning can be slow. You can use the Masscan to speed up. The Masscan needs to be installed in advance. For example, we find hosts whose port 80 and 8000 to 8008 opened and scan them:
127-
```shell
128-
./run_ingram.py --in TARGET --out OUT_DIR --masscan --port 80,8000-8008 --rate 5000
129-
./run_ingram.py --in OUT_DIR/masscan_res --out OUT_DIR --all --th_num 80
79+
+ (**可选**) 扫描时间可能会很长,如果你想让程序扫描结束的时候通过微信发送一条提醒的话,你需要按照 [wxpusher](https://wxpusher.zjiecode.com/docs/) 的指示来获取你的专属 *UID**APP_TOKEN*,并将其写入 `run_ingram.py`:
80+
```python
81+
# wechat
82+
config.set_val('WXUID', '这里写uid')
83+
config.set_val('WXTOKEN', '这里写token')
13084
```
13185

132-
+ If your program breaks due to network or other reasons, you can continue the previous process by simply running the command that ran last time. For example, the last command you executed was `./run_ingram.py --in ip.txt --out output --all --th_num 80`, to resume, simply continue `./run_ingram.py --in ip.txt --out output --all --th_num 80`, also for the masscan.
86+
+ 支持中断恢复,不过由于每5分钟记录一次运行状态,所以并不能准确恢复到上次的运行状态。
13387

13488

135-
## Results
89+
## 结果
13690

13791
```bash
13892
.
13993
├── not_vulnerable.csv
140-
├── results_all.csv
141-
├── results_simple.csv
142-
└── snapshots
94+
├── results.csv
95+
├── snapshots
96+
└── log.txt
14397
```
14498

145-
+ The comprehensive results are saved in the `OUT_DIR/results_all.csv` file, and each line is `ip,port,user,passwd,device,vulnerability`:
146-
![](statics/imgs/results.png)
147-
148-
+ The `OUT_DIR/results_simple.csv` file contains only the target with the password, in the format of `IP,port,user,passwd`
99+
+ `results.csv` 里保存了完整的结果, 格式为: `ip,端口,设备类型,用户名,密码,漏洞条目`:
100+
![](Ingram/static/imgs/results.png)
149101

150-
+ `OUT_DIR/not_vulnerable.csv` file is stored in the target without vulnerability exposure
102+
+ `not_vulnerable.csv` 中保存的是没有暴露的设备
151103

152-
+ Some camera's snapshots can be found in `OUT_DIR/snapshots/`:
153-
![](statics/imgs/snapshots.png)
104+
+ `snapshots` 中保存了部分设备的快照:
105+
![](Ingram/static/imgs/snapshots.png)
154106

155107

156-
## The Live
108+
## 实时预览 (由于部分原因已移除)
157109

158-
+ You can log in directly from the browser to see the live screen.
110+
+ ~~可以直接通过浏览器登录来预览~~
159111

160-
+ If you want to view the live screen in batch, we provided a script: `show/show_rtsp/show_all.py`, though it has some flaws:
161-
```shell
162-
python3 -Bu show/show_rtsp/show_all.py OUT_DIR/results_all.csv
163-
```
164-
165-
![](statics/imgs/show_rtsp.png)
112+
+ ~~如果想批量查看,我们提供了一个脚本 `show/show_rtsp/show_all.py`,不过它还有一些问题:~~
113+
![](Ingram/static/imgs/show_rtsp.png)
166114

167115

168-
## Change Logs
116+
## 更新日志
169117

170-
+ [2022-06-11] **Optimized running speed; Supportted storage of the not vulnerable targets**
118+
+ [2022-06-11] **优化运行速度,支持存储非暴露设备,支持中断恢复**
171119

172-
+ [2022-06-11] **Resume supported!!!**
120+
+ [2022-07-23] **可以通过 CVE-2021-33044(Dahua) 来获取用户名与密码了!修改了摄像头快照逻辑(将rtsp替换为了http),优化了运行速度**
121+
- **由于新版本加入了一些依赖包,需要重新配置环境!!!**
173122

174-
+ [2022-07-23] **You can obtain the user and password through CVE-2021-33044(Dahua)!!! Updated snapshot logic (change rtsp to http), optimized running speed.**
175-
- **Since the new version adds some dependency packages, the environment needs to be reconfigured!**
123+
+ [2022-08-05] **增加了 CVE-2021-33045(Dahua NVR),不过由于NVR设备的账号密码与真正的摄像头的账号密码可能不一致,所以快照功能并不总是有效**
176124

177-
+ [2022-08-05] **Added CVE-2021-33045 (Dahua NVR), but the snapshot function is not always available because the NVR device's account&password may be different from the real camera**
125+
+ [2022-08-06] **增加了 宇视 设备的密码暴露模块,暂不支持快照**
178126

179-
+ [2022-08-06] **Added password disclosure module for Uniview camera, does not support snapshot yet**
127+
+ [2022-08-17] **比较大的一次更新,我们重构了所有代码 (需要重新配置环境),具体如下:**
128+
- 重构了代码结构,便于以后集成更多漏洞,移除部分依赖包,减少了超参数
129+
- 将多线程替换为协程,速度较之前有明显提升
130+
- 解决了子进程无法自动关闭的bug
131+
- 去掉了对masscan的支持,因为新版本会自动探测端口,当然你还可以把masscan的结果ip提取出来作为Ingram的输入
132+
- 去掉了若干与设备相关的超参数,新版本会自动探测设备
133+
- 不再内置iplist,因为其太占空间且不便于维护,需要的可以自己去网上找
180134

181135

182-
## Disclaimer
136+
## 免责声明
183137

184-
This tool is only for learning and safety testing, do not fucking use it for illegal purpose, all legal consequences caused by this tool will be borne by the user!!!
138+
本工具仅供安全测试,严禁用于非法用途,后果与本团队无关
185139

186140

187-
## Acknowledgements & References
141+
## 鸣谢 & 引用
188142

189143
Thanks to [Aiminsun](https://github.com/Aiminsun/CVE-2021-36260) for CVE-2021-36260
190144
Thanks to [chrisjd20](https://github.com/chrisjd20/hikvision_CVE-2017-7921_auth_bypass_config_decryptor) for hidvision config file decryptor
191-
Thanks to [metowolf](https://github.com/metowolf/iplist) for ip list
192145
Thanks to [mcw0](https://github.com/mcw0/DahuaConsole) for DahuaConsole

run_ingram.py

+6
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from Ingram.utils import config
1010
from Ingram.utils import logo
1111
from Ingram.utils import color
12+
from Ingram.utils import wx_send
1213
from Ingram.utils import get_parse
1314
from Ingram.utils import logger, config_logger
1415
from Ingram.utils import get_user_agent
@@ -45,6 +46,11 @@ def assemble_config(args):
4546
core = Core() # get ingram core
4647
core() # run
4748
logger.info('Ingram done!')
49+
if config['WXUID'] and config['WXTOKEN']:
50+
try:
51+
wx_send('Ingram done!')
52+
except Exception as e:
53+
logger.error(e)
4854
except KeyboardInterrupt as e:
4955
exit(0)
5056
except Exception as e:

0 commit comments

Comments
 (0)