-
Notifications
You must be signed in to change notification settings - Fork 280
/
run_ingram.py
executable file
·66 lines (53 loc) · 1.86 KB
/
run_ingram.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#! /usr/bin/env python3
# coding : utf-8
# @Author : Jor<[email protected]>
# @Date : Wed Apr 20 00:17:30 HKT 2022
# @Desc : Webcam vulnerability scanning tool
#=================== 需放置于最开头 ====================
import warnings; warnings.filterwarnings("ignore")
from gevent import monkey; monkey.patch_all(thread=False)
#======================================================
import os
import sys
from multiprocessing import Process
from loguru import logger
from Ingram import get_config
from Ingram import Core
from Ingram.utils import color
from Ingram.utils import common
from Ingram.utils import get_parse
from Ingram.utils import log
from Ingram.utils import logo
def run():
try:
# logo
for icon, font in zip(*logo):
print(f"{color.yellow(icon, 'bright')} {color.magenta(font, 'bright')}")
# config
config = get_config(get_parse())
if not os.path.isdir(config.out_dir):
os.mkdir(config.out_dir)
os.mkdir(os.path.join(config.out_dir, config.snapshots))
if not os.path.isfile(config.in_file):
print(f"{color.red('the input file')} {color.yellow(config.in_file)} {color.red('does not exists!')}")
sys.exit()
# log 配置
log.config_logger(os.path.join(config.out_dir, config.log), config.debug)
# 任务进程
p = Process(target=Core(config).run)
if common.os_check() == 'windows':
p.run()
else:
p.start()
p.join()
except KeyboardInterrupt:
logger.warning('Ctrl + c was pressed')
p.kill()
sys.exit()
except Exception as e:
logger.error(e)
print(f"{color.red('error occurred, see the')} {color.yellow(config.log)} "
f"{color.red('for more information.')}")
sys.exit()
if __name__ == '__main__':
run()