Skip to content

Commit ca4f105

Browse files
committed
sample programs added
1 parent 6caf821 commit ca4f105

4 files changed

Lines changed: 116 additions & 1 deletion

File tree

example_1.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
def get_initial_corpus():
2+
return ["fuzz"]
3+
4+
i = 0
5+
6+
def entrypoint(s):
7+
global i
8+
i += 1
9+
print(f'trial {i}')
10+
11+
j = 0
12+
k = 1
13+
14+
while j < 5:
15+
a = 0 ## placeholder to simulate presence of some code
16+
b = 0 ## placeholder to simulate presence of some code
17+
if len(s) > j * 5 + 2:
18+
a = 1 ## placeholder to simulate presence of some code
19+
b = 1 ## placeholder to simulate presence of some code
20+
while k < 10:
21+
if (k > 5):
22+
if len(s) > k * 2:
23+
if s[k+1] == 'f':
24+
if s[k*2 - 1] == 's':
25+
print(f'bug found after {i} trials')
26+
exit(219)
27+
k += 1
28+
j += 1
29+
30+
if __name__ == "__main__":
31+
for p in range(0, 110):
32+
entrypoint(get_initial_corpus()[0])

example_2.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
def get_initial_corpus():
2+
return ["fuzz"]
3+
4+
i = 0
5+
6+
def entrypoint(s):
7+
global i
8+
i += 1
9+
print(f'trial {i}')
10+
11+
j = 0
12+
k = 1
13+
14+
while j < 5:
15+
a = 0 ## placeholder to simulate presence of some code
16+
b = 0 ## placeholder to simulate presence of some code
17+
if len(s) > j * 5 + 2:
18+
a = 1 ## placeholder to simulate presence of some code
19+
b = 1 ## placeholder to simulate presence of some code
20+
while k < 10:
21+
if (k > 5):
22+
if len(s) > k * 2:
23+
if s[k+1] == 'f':
24+
if s[k*2 - 1] == 's':
25+
print(f'bug found after {i} trials')
26+
exit(219)
27+
k += 1
28+
else:
29+
if len(s) > 2:
30+
if len(s) < 10:
31+
if s[-1] == 'b':
32+
print(f'bug found in else branch after {i} trials')
33+
exit(219)
34+
j += 1
35+
36+
if __name__ == "__main__":
37+
for p in range(0, 110):
38+
entrypoint(get_initial_corpus()[0])

example_3.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
def get_initial_corpus():
2+
return ["fuzz"]
3+
4+
i = 0
5+
6+
def entrypoint(s):
7+
global i
8+
i += 1
9+
print(f'trial {i}')
10+
11+
j = 0
12+
k = 1
13+
14+
while j < 5:
15+
a = 0 ## placeholder to simulate presence of some code
16+
b = 0 ## placeholder to simulate presence of some code
17+
if len(s) > j * 5 + 2:
18+
a = 1 ## placeholder to simulate presence of some code
19+
b = 1 ## placeholder to simulate presence of some code
20+
while k < 10:
21+
if (k > 5):
22+
if len(s) > k * 2:
23+
if s[k+1] == 'f':
24+
if s[k*2 - 1] == 's':
25+
print(f'bug found after {i} trials')
26+
exit(219)
27+
k += 1
28+
else:
29+
if len(s) > 2:
30+
if len(s) > 20:
31+
if s[-1] == 'b':
32+
a = 0
33+
while a < 5:
34+
a += 1
35+
if a == 3:
36+
print(f'bug found in else branch after {i} trials')
37+
exit(219)
38+
j += 1
39+
40+
if __name__ == "__main__":
41+
for p in range(0, 110):
42+
entrypoint(get_initial_corpus()[0])

student_fuzzer.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,7 @@ def coverage(self):
8383
# line_runner = mf.FunctionCoverageRunner(entrypoint)
8484

8585
fast_fuzzer = gbf.CountingGreyboxFuzzer(seed_inputs, gbf.Mutator(), fast_schedule)
86-
fast_fuzzer.runs(line_runner, trials=999999999)
86+
n = 99999999
87+
start = time.time()
88+
fast_fuzzer.runs(line_runner, trials=n)
89+
end = time.time()

0 commit comments

Comments
 (0)