Skip to content

Commit

Permalink
Update ThreatFoxQuery.py
Browse files Browse the repository at this point in the history
changed file.hash.256 to file.hash.sha256
  • Loading branch information
Spacechrist authored Jan 9, 2025
1 parent 2927fbd commit 0f19484
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ThreatFoxQuery.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

# Process the IOCs and store the result by IOC type
formatted_iocs = {
"file.hash.256": [],
"file.hash.sha256": [],
"file.hash.md5": [],
"destination.ip": [], # Changed to destination.ip to match desired output
"url.domain": [],
Expand All @@ -60,7 +60,7 @@

# Append the IOC values to the appropriate list based on the IOC type
if ioc_type == "sha256_hash":
formatted_iocs["file.hash.256"].append(f'"{ioc_value}"')
formatted_iocs["file.hash.sha256"].append(f'"{ioc_value}"')
elif ioc_type == "md5_hash":
formatted_iocs["file.hash.md5"].append(f'"{ioc_value}"')
elif ioc_type == "ip:port":
Expand Down Expand Up @@ -95,15 +95,15 @@
writer = csv.writer(csvfile)

# Write headers for the CSV file
writer.writerow(['file.hash.256', 'file.hash.md5', 'destination.ip', 'url.domain', 'url.original'])
writer.writerow(['file.hash.sha256', 'file.hash.md5', 'destination.ip', 'url.domain', 'url.original'])

# Determine the maximum length of any IOC type list to ensure we loop through all rows
max_length = max(len(values) for values in formatted_iocs.values())

# Write each row of IOCs, padding with empty strings if necessary
for i in range(max_length):
row = [
formatted_iocs["file.hash.256"][i] if i < len(formatted_iocs["file.hash.256"]) else '',
formatted_iocs["file.hash.sha256"][i] if i < len(formatted_iocs["file.hash.sha256"]) else '',
formatted_iocs["file.hash.md5"][i] if i < len(formatted_iocs["file.hash.md5"]) else '',
formatted_iocs["destination.ip"][i] if i < len(formatted_iocs["destination.ip"]) else '', # Updated to destination.ip
formatted_iocs["url.domain"][i] if i < len(formatted_iocs["url.domain"]) else '',
Expand Down

0 comments on commit 0f19484

Please sign in to comment.