-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathburp_py.py
More file actions
44 lines (40 loc) · 1.47 KB
/
burp_py.py
File metadata and controls
44 lines (40 loc) · 1.47 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
import requests
from pprint import pprint
import os
import json
def parse_request(file_name):
line = ""
headers = {}
post_data = ""
header_collection_done = False
file_object = open(file_name, "r")
file_object.seek(0)
file_object.readline()
for line in file_object.readlines():
if header_collection_done is False:
if line.startswith("\n"):
header_collection_done = True
else:
headers.update(
{line[0:line.find(":")].strip(): line[line.find(":")+1:].strip()})
else:
post_data = post_data + line
file_object.close()
return (headers, post_data)
directory = "input_files"
for filename in os.scandir(directory):
if filename.is_file():
print("Reading File - ", filename.path)
header, post_data = parse_request(filename.path)
# json_header = json.dumps(header, indent=4)
# json_header = json.loads(json_header)
json_post_data = json.dumps(post_data, indent=4)
json_post_data = json.loads(json_post_data)
dict = json.loads(json_post_data)
# pprint(json_header)
print(dict)
print()
# with open("output_files/"+filename.name+"_headers.json", "w") as outfile:
# json.dump(json_header, outfile)
# with open("output_files/"+filename.name+"_data.json", "w") as outfile:
# json.dump(json_post_data, outfile)