-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfuzz_logger.py
More file actions
40 lines (34 loc) · 1.49 KB
/
Copy pathfuzz_logger.py
File metadata and controls
40 lines (34 loc) · 1.49 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
import json
import os
from datetime import datetime
# ファジングした結果をJSONファイルに保存するための関数
class FuzzLogger:
def __init__(self, filename= "output/fuzz_results.json", overwrite=True):
self.filename = filename
self.results = []
self.overwrite = overwrite
# ディレクトリ作成(なければ作る)
os.makedirs(os.path.dirname(filename), exist_ok=True)
if not overwrite and os.path.exists(filename):
with open(filename, "r", encoding="utf-8") as f:
try:
self.results = json.load(f)
except json.JSONDecodeError:
self.results = []
#attack_typeも実装予定
def log_result(self, target_url, payload, response_code, response_body, injection_type ,injection_detected, fuzzing_results=None, error_contents=None):
result = {
"timestamp": datetime.now().isoformat(),
"target_url": target_url,
"payload": payload,
"response_code": response_code,
"response_body": response_body,
"injection_type": injection_type,
"injection_detected": injection_detected,
"fuzzing_results": fuzzing_results,
"error_contents": error_contents,
}
self.results.append(result)
def save(self):
with open(self.filename, "w", encoding="utf-8") as f:
json.dump(self.results, f, ensure_ascii=False, indent=2)