-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
115 lines (95 loc) · 4.46 KB
/
main.py
File metadata and controls
115 lines (95 loc) · 4.46 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
"""
Copyright (c) 2020 Diego Moraes. MIT license, see LICENSE file.
"""
import argparse
from logic.fuzzer import Fuzzer
from logic.fuzzer import TIMEOUT, WORKERS
from logic.settings import END_DEFAULT
def main():
"""Main --> Fuzzer"""
# Arguments #
parser = argparse.ArgumentParser(description='Fuzzer parameters')
required = parser.add_argument_group(title='Basic arguments')
performance = parser.add_argument_group(title='Performance options')
connection = parser.add_argument_group(title='Connection options')
log_options = parser.add_argument_group(title='Log options')
other = parser.add_argument_group(title='Other options')
required.add_argument('-u', '--url', help='Base url', required=True)
required.add_argument('-d', '--dir', help='dictionary wordlist path', required=True)
performance.add_argument('-w', '--workers', type=int, help='Numbers of workers', default=WORKERS)
performance.add_argument('-s', '--start', type=int, help='Start in n dictionary', default=0)
performance.add_argument('-e', '--end', type=int, help='End in n dictionary', default=END_DEFAULT)
performance.add_argument('-i', '--interval', type=int, help='Execution interval', default=0)
performance.add_argument('-t', '--timeout', type=float, help='Timeout for each request (Default=3)', default=TIMEOUT)
connection.add_argument('--tor', help='Perform requests over the Tor network', action='store_true')
connection.add_argument('--proxy', type=str, help='Custom proxy url')
connection.add_argument('--check-ssl',
type=int, help='0 = Default, 1 = Force check, 2 = Disable',
choices=[0, 1, 2], dest='checkssl', default=0)
log_options.add_argument('--exceptions', help='Show exception and error messages', action='store_true')
log_options.add_argument('--log-status', help='Show response http status code messages', action='store_true', dest='rstatus')
log_options.add_argument('--no-info', help='Do not show info messages',
dest='noinfo', action='store_false')
log_options.add_argument('--debug', help='Show debug messages', action='store_true')
log_options.add_argument('--log-all', help='Log everything', action='store_true', dest='logall')
log_options.add_argument('--log-file', help='Log Output to app.log', action='store_true', dest='logfile')
log_options.add_argument('--no-colors', help='Disable colored logs', action='store_false', dest='nocolors')
other.add_argument('-g', '--save', help='Save results to csv file', action='store_true')
args = parser.parse_args()
# Check arguments #
if args.end != END_DEFAULT:
if args.start >= args.end:
parser.error("--end must be greater than --start")
if args.interval > args.end - args.start:
parser.error(
"--interval must not be greater than the difference bethween --start and --end")
if args.timeout < 1:
parser.error("--timeout must be greater than 0")
if args.workers < 1:
parser.error("--workers must be greater than 0")
if args.tor and args.proxy:
parser.error("Cannot use a Proxy and Tor at the same time")
if args.checkssl == 0:
ssl = None
elif args.checkssl == 1:
ssl = True
elif args.checkssl == 2:
ssl = False
else:
parser.error("Invalid value for checkSSL")
# Log Config #
if args.logall:
log_config = {
"info": True,
"status": True,
"exceptions": True,
"debug": True
}
else:
log_config = {
"info": args.noinfo,
"status": args.rstatus,
"exceptions": args.exceptions,
"debug": args.debug,
}
log_config["file"] = args.logfile
log_config["colors"] = args.nocolors
# Fuzzer setup #
fuzzer = Fuzzer(args.save, log_config, True)
main_logger = fuzzer.logger
# Url building #
try:
fuzzer.set_target(args.dir, args.url, args.start, args.end)
fuzzer.build_urls(ask=True)
except FileNotFoundError:
main_logger.lcritical(f"{args.dir} Not found")
main_logger.linfo(f"Number of urls to test: {len(fuzzer.urls)}")
fuzzer.tor = args.tor
fuzzer.proxy = args.proxy
fuzzer.timeout = args.timeout
fuzzer.workers = args.workers
# Start execution #
fuzzer.run(args.interval, ssl)
fuzzer.print_stats()
main_logger.linfo("***********END***********")
main()