-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
35 lines (25 loc) · 1021 Bytes
/
main.py
File metadata and controls
35 lines (25 loc) · 1021 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
32
33
34
35
from mitmproxy import http
import requests
SUSPICIOUS_SITES_FILE = "suspicious_sites.txt"
suspicious_sites = set()
def fetch_suspicious_sites(url="https://urlhaus.abuse.ch/downloads/text/"):
global suspicious_sites
try:
response = requests.get(url, proxies={"http": None, "https": None})
response.raise_for_status()
for line in response.text.splitlines():
if not line.startswith("#") and line.strip():
suspicious_sites.add(line.strip())
print("[*] Successfully fetched suspicious sites.")
except requests.RequestException as e:
print(f"[!] Error fetching suspicious sites: {e}")
fetch_suspicious_sites()
def save_suspicious_url(url):
with open(SUSPICIOUS_SITES_FILE, "a") as f:
f.write(url + "\n")
def request(flow: http.HTTPFlow):
url = flow.request.url
print(f"Captured URL: {url}")
if url in suspicious_sites:
print(f"[ALERT] Suspicious URL detected: {url}")
save_suspicious_url(url)