-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhttp _fuzzer.py
40 lines (40 loc) · 1.92 KB
/
http _fuzzer.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
import os
import argparse
import subprocess
import requests
import time
parser = argparse.ArgumentParser(description='Network Http Fuzzer made by Akshat Parikh (Please install Radamsa and use linux)')
parser.add_argument('-P', '--process', help = "Specify http server process id", required=True)
parser.add_argument('-N', '--number', help = "Number of times you want to use fuzzer", required=True)
parser.add_argument('-H', '--host', help = "Host", required=True)
parser.add_argument('-M', '--port', help = "Host Port", required=True)
parser.add_argument('-I', '--input', help = "Input Directory", required=True)
parser.add_argument('-O', '--output', help = "Output directory", required=True)
args = parser.parse_args()
counter = 0
files = os.listdir(args.input)
crash = 0
while counter < int(args.number):
if crash == 0:
for x in range(len(files)):
pslist = subprocess.check_output("ps -A -o pid", shell=True)
if (str(args.process) in str(pslist)) == True:
print("active")
time.sleep(1)
testcase = os.popen("cat "+ args.input+files[x] + " | radamsa > "+args.output+"testcase"+str(x)).read()
print(counter)
try:
request = subprocess.check_output("nc "+ args.host+" "+args.port+" < "+args.output+"testcase"+str(x),stderr=subprocess.STDOUT, timeout=5, shell=True)
except subprocess.TimeoutExpired:
t = time.localtime()
current_time = time.strftime("%H:%M:%S", t)
os.system("cp "+args.output+"testcase"+str(x)+" "+args.output+current_time+"Hang")
print("Interesting Case/Hang Detected")
print(request)
else:
print("crash detected check timestamp in logs")
crash = 1
break
counter += 1
else:
break