-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathURLscan_hunter.py
71 lines (58 loc) · 2.62 KB
/
URLscan_hunter.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
import requests
import time
# User-agent string to mimic a Google Chrome browser on Windows
USER_AGENT = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) Chrome/90.0.4430.212'
# URLScan.io API details
API_KEY = 'your_urlscan_api_key'
HEADERS = {
'API-Key': API_KEY,
'Content-Type': 'application/json'
}
SUBMIT_URL = 'https://urlscan.io/api/v1/scan/'
RESULT_URL = 'https://urlscan.io/api/v1/result/'
def read_lines_from_file(filename):
with open(filename, 'r') as file:
return [line.strip() for line in file if line.strip()]
def log_to_file(file_path, text):
with open(file_path, 'a') as file:
file.write(text + "\n")
def submit_to_urlscan(url):
response = requests.post(SUBMIT_URL, headers=HEADERS, json={'url': url})
if response.status_code == 200:
return response.json()['uuid']
else:
print(f"Error submitting {url} to URLScan: {response.content}")
return None
def retrieve_scan_results(scan_id):
time.sleep(30) # URLScan.io may require a delay before results are ready
results_response = requests.get(f"{RESULT_URL}/{scan_id}", headers=HEADERS)
if results_response.status_code == 200:
return results_response.json()
else:
print(f"Error retrieving results for scan {scan_id}: {results_response.content}")
return None
def monitor_domains(domains, output_file, phishing_file):
for domain in domains:
scan_id = submit_to_urlscan(domain)
if scan_id:
results = retrieve_scan_results(scan_id)
if results:
# Process the results
# Check if the domain is up and if there are any phishing indicators
# For simplicity, we're just printing the results here
print(f"Results for {domain}: {results}")
log_to_file(output_file, f"Results for {domain}: {results}")
# If you have specific indicators to check in the results, do it here
# If phishing is detected:
phishing_message = f'Phishing indicator detected on the domain: {domain}'
print(phishing_message)
log_to_file(phishing_file, phishing_message)
# Sleep to avoid hitting URLScan.io rate limits
time.sleep(15)
entities = read_lines_from_file('entities.txt')
domain_formats = read_lines_from_file('domains_formats.txt')
specific_indicators = read_lines_from_file('indicators.txt')
domains = [format.replace('*', entity) for entity in entities for format in domain_formats]
output_file = 'output.txt'
phishing_file = 'phishing_kit_hosted.txt'
monitor_domains(domains, output_file, phishing_file)