-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogger.py
More file actions
31 lines (21 loc) · 898 Bytes
/
logger.py
File metadata and controls
31 lines (21 loc) · 898 Bytes
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
import csv
import os
LOG_FILE = "fuzz_results.csv"
# CSV Header definieren (nur beim ersten Mal schreiben)
CSV_HEADER = ["Payload", "Category", "StatusCode", "Snippet"]
def log(payload, response, category):
"""
Loggt gefundene Fehler in fuzz_results.csv.
Speichert: Payload, Kategorie, HTTP-Code, Response-Ausschnitt.
"""
if not response:
return
# Prüfen ob Datei existiert → Header schreiben wenn neu
file_exists = os.path.isfile(LOG_FILE)
with open(LOG_FILE, mode='a', newline='', encoding='utf-8') as csvfile:
writer = csv.writer(csvfile)
if not file_exists:
writer.writerow(CSV_HEADER)
snippet = response.text[:100].replace('\n', ' ').replace('\r', ' ')
writer.writerow([payload, category, response.status_code, snippet])
print(f"[LOG] Saved to {LOG_FILE}: {payload} ({response.status_code})")