-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
73 lines (52 loc) · 2.22 KB
/
main.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
67
68
69
70
71
72
73
import logging
from argparse import ArgumentParser
from configparser import ConfigParser
from dotenv import load_dotenv
from scanners.task import ShodanTask, CheckTask, NmapTask
__version__ = '0.1.0'
from wordlists.proxy_downloader import ProxyDownloader
load_dotenv()
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s %(levelname)s %(message)s',
handlers=[
logging.FileHandler("./logs/rtsp_scanner.log"),
logging.StreamHandler()
]
)
def parse_args():
parser = ArgumentParser(description='Camera Scanner')
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument('--start_search', action='store_true', help='Start searching for cameras on Shodan')
group.add_argument('--start_check', action='store_true', help='Start testing cameras on DB')
group.add_argument('--start_nmap', action='store_true', help='Start nmap scan')
parser.add_argument('--config', action='store', help='Path to the configuration file', default='config.ini')
parser.add_argument('--proxy-file', action='store', help='Proxy file path', default='https://raw.githubusercontent.com/MatrixTM/MHDDoS/main/config.json')
parser.add_argument('-v', '--verbose', action='store_true', help='Verbose mode', default=False)
return parser.parse_args()
def load_config(config_file):
config = ConfigParser()
config.read(config_file)
return config
def main():
args = parse_args()
proxy_downloader = ProxyDownloader(args.proxy_file)
if args.verbose:
logging.getLogger().setLevel(logging.DEBUG)
logging.info('Verbose mode enabled')
config = load_config(args.config)
settings = {**config, **vars(args)}
if args.start_search:
shodan_config = settings.get('shodan_config')
shodan_searcher = ShodanTask(shodan_config, proxy_downloader)
shodan_searcher.run()
if args.start_check:
checkers_config = settings.get('checkers_config')
checker = CheckTask(checkers_config, proxy_downloader)
checker.run()
if args.start_nmap:
nmap_config = settings.get('nmap_config')
nmap_searcher = NmapTask(nmap_config, proxy_downloader)
nmap_searcher.run()
if __name__ == '__main__':
main()