-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTool-06-JSON-to-Excel-Exporter.py
77 lines (67 loc) · 2.25 KB
/
Tool-06-JSON-to-Excel-Exporter.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import openpyxl
import json
from datetime import datetime
from urllib.parse import urlparse
def log(message):
timestamp = datetime.now().strftime("[%Y-%m-%d %H:%M:%S]")
print(f"{timestamp} {message}")
def json_to_excel():
# Load the JSON data
log("Loading JSON data...")
try:
with open(
"../Database-Files/Edit-Database/Compromised-Discord-Accounts.json", "r", encoding="utf-8"
) as file:
data = json.load(file)
except FileNotFoundError:
log("Error: JSON file not found.")
return
# Create a new workbook
workbook = openpyxl.Workbook()
worksheet = workbook.active
# Set the header row
headers = [
"NOUMBER",
"FOUND_ON",
"FOUND_ON_SERVER",
"DISCORD_ID",
"USERNAME",
"BEHAVIOUR",
"TYPE",
"METHOD",
"TARGET",
"PLATFORM",
"SURFACE_URL",
"REGION",
"STATUS",
]
worksheet.append(headers)
# Iterate through the JSON data and populate the worksheet
log("Converting JSON to Excel...")
for account_key, account_data in data.items():
row = [
account_data.get("CASE_NUMBER", ""),
datetime.fromisoformat(account_data.get("FOUND_ON", ""))
if account_data.get("FOUND_ON")
and account_data.get("FOUND_ON") != "Unknown"
else "",
account_data.get("FOUND_ON_SERVER", ""),
account_data.get("DISCORD_ID", ""),
account_data.get("USERNAME", ""),
account_data.get("BEHAVIOUR", ""),
account_data.get("ATTACK_METHOD", ""),
account_data.get("ATTACK_VECTOR", ""),
account_data.get("ATTACK_GOAL", ""),
account_data.get("ATTACK_SURFACE", ""),
account_data.get("SURFACE_URL", ""),
account_data.get("SUSPECTED_REGION_OF_ORIGIN", ""),
account_data.get("SURFACE_URL_STATUS", ""),
]
worksheet.append(row)
# Save the workbook
output_path = "../Database-Files/Excel-Import-Export/ExporterSheet_Converted.xlsx"
workbook.save(output_path)
log(f"Excel file saved to {output_path}")
log(f"Total accounts converted: {len(data)}")
if __name__ == "__main__":
json_to_excel()