forked from PBearson/FUME-Fuzzing-MQTT-Brokers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfuzz.py
74 lines (59 loc) · 1.87 KB
/
fuzz.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
74
import sys
import random
import math
sys.path.append('generators')
sys.path.append('helper_functions')
sys.path.append('fume')
sys.path.append('parsers')
from generators.auth import Auth
import helper_functions.validate_fuzzing_params as vfp
import helper_functions.parse_config_file as pcf
import helper_functions.print_configuration as pc
import helper_functions.crash_logging as cl
import globals as g
import fume.markov_model as mm
import fume.fuzzing_engine as fe
import fume.run_target as rt
# Calculate X1 from the construction intensity
def calculate_X1():
g.X1 = 1 / g.CONSTRUCTION_INTENSITY
# Calculate X2 from the fuzzing intensity
def calculate_X2():
g.X2 = 1 - g.FUZZING_INTENSITY
# Calculate X3 from the fuzzing intensity
def calculate_X3():
g.X3 = 1 - (2 * math.log(1 + g.FUZZING_INTENSITY, 10))
def main():
# Try to parse the supplied config file.
# If one is not supplied, use the default values.
try:
config_f = open(sys.argv[1], 'r')
config = config_f.readlines()
pcf.parse_config_file(config)
config_f.close()
except FileNotFoundError:
print("Could not find the supplied file: %s" % sys.argv[1])
exit(-1)
except IndexError:
pass
# Calculate X1, X2, and X3 only if the user did not supply those values
if g.user_supplied_X[0] == 0:
calculate_X1()
if g.user_supplied_X[1] == 0:
calculate_X2()
if g.user_supplied_X[2] == 0:
calculate_X3()
# Validate all parameters
vfp.validate_all()
# Create crash directory if needed
cl.create_crash_directory()
# Print fuzzing configuration
pc.print_configuration()
# Initialize Markov Model
markov_model = mm.initialize_markov_model()
# Start the target
rt.run_target()
# Run the fuzzing loop
fe.run_fuzzing_engine(markov_model)
if __name__ == "__main__":
main()