Skip to content

Commit

Permalink
Update Get_TOR_IOCs.py
Browse files Browse the repository at this point in the history
  • Loading branch information
mthcht authored Jun 25, 2024
1 parent 6c0e1cb commit 0337533
Showing 1 changed file with 33 additions and 2 deletions.
35 changes: 33 additions & 2 deletions Lists/TOR/Get_TOR_IOCs.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
@: @ @. @ @ @=*++++-*%
@: @ @# @+ % @=*++++-*%
@@ @ % . #* :: @.@=*++++-%#
@ :# % % @ -*@%+*++=--@%
@ :# % % @ -*@%+*+--=@%
@@- @%* @ @ @ @++*+--=@#
@@ .+@ % + .@@=+=-:@@
@@@. . + . @@*---#@%%
Expand Down Expand Up @@ -71,6 +71,10 @@ def process_address(address):
# Prepare a dictionary to hold the best entries for each IP
entries_by_ip = {}

# Lists to hold exit node and guard node IPs
exit_node_ips = []
guard_node_ips = []

# Determine the "dest_role" based on probabilities
def determine_dest_role(entry):
probabilities = {
Expand Down Expand Up @@ -109,6 +113,13 @@ def determine_dest_role(entry):
if not any(key.startswith(f"{ip}:") for key in entries_by_ip):
entries_by_ip[ip] = entry_data

# Collect exit node IPs
if entry_data['metadata_dest_role'] == 'exit':
exit_node_ips.append(ip)

# Collect guard node IPs
if entry_data['metadata_dest_role'] == 'guard':
guard_node_ips.append(ip)

csv_file_path = 'TOR_nodes_list.csv'

Expand All @@ -119,4 +130,24 @@ def determine_dest_role(entry):
for entry in entries_by_ip.values():
writer.writerow(entry)

print(f"Transformed data written to {csv_file_path}")
print(f"All TOR nodes written to {csv_file_path}")

# Write the exit node IPs to a separate CSV file
exit_ips_file_path = 'only_tor_exit_nodes_IP_list.csv'
with open(exit_ips_file_path, mode='w', newline='', encoding='utf-8') as csv_file:
writer = csv.writer(csv_file)
writer.writerow(['dest_ip'])
for ip in exit_node_ips:
writer.writerow([ip])

print(f"Exit node IPs written to {exit_ips_file_path}")

# Write the guard node IPs to a separate CSV file
guard_ips_file_path = 'only_tor_guard_nodes_IP_list.csv'
with open(guard_ips_file_path, mode='w', newline='', encoding='utf-8') as csv_file:
writer = csv.writer(csv_file)
writer.writerow(['dest_ip'])
for ip in guard_node_ips:
writer.writerow([ip])

print(f"Guard node IPs written to {guard_ips_file_path}")

0 comments on commit 0337533

Please sign in to comment.