Test connections to live malware distribution URLs using the URLhaus real-time threat intelligence database
The known_dist() function tests your network’s ability to detect and block connections to active malware distribution sites. It uses the URLhaus API from abuse.ch, which tracks live malware distribution URLs in real-time.
This module uses the URLhaus API to fetch live malware distribution URLs:
URLhaus API - https://urlhaus-api.abuse.ch/v1/urls/recent/limit/200/
This test connects to LIVE malware distribution sites. URLhaus is maintained by abuse.ch and provides real-time tracking of malware distribution URLs used by threat actors.
Filters the API response to include only URLs with “online” status, ensuring tests target active malware infrastructure.
for _ in json_response["urls"]: status = json_response["urls"][counter]["url_status"] if status == "online": liveURL = json_response["urls"][counter]["url"] urlsIndex.append(liveURL) counter = counter + 1
3
Random Sampling
Randomly selects 20 URLs from the active malware distribution sites.
for _ in range(20): randomSample = random.choice(urlsIndex) randomUrlsIndex.append(randomSample)
4
HTTP Connection Testing
Attempts HTTP GET requests to each malware distribution URL with a 5-second timeout.
for x in randomUrlsIndex: try: downloader = requests.get(x, timeout=5) if downloader.status_code == 200: # Log successful connection except Exception as e: continue
5
Results Logging
Logs all connection attempts with timestamps to Malware_Results.txt.
Results are saved to Malware_Results.txt with the following format:
Timestamp:14:35:20 URL:http://malware-site.com/payload.exe test SUCCESFULLTimestamp:14:35:25 URL:http://c2-server.xyz/download test FAILEDTimestamp:14:35:30 URL:https://compromised-site.org/malware test SUCCESFULL
def known_dist(): print('Testing LIVE malware distribution URL, THANKS TO ABUSE.CH!!!') urlsIndex = [] randomUrlsIndex = [] baseURL = "https://urlhaus-api.abuse.ch/v1/urls/recent/limit/200/" response = requests.get(baseURL) json_response = response.json() counter = 0 for _ in tqdm(json_response["urls"], desc="Getting samples list"): status = json_response["urls"][counter]["url_status"] if status == "online": liveURL = json_response["urls"][counter]["url"] urlsIndex.append(liveURL) counter = counter + 1 for _ in range(20): randomSample = random.choice(urlsIndex) randomUrlsIndex.append(randomSample) myFile = open("Malware_Results.txt", mode="a+") for x in tqdm(randomUrlsIndex, desc="Testing samples, Results saved at Malware_Results.txt"): try: downloader = requests.get(x, timeout=5) if downloader.status_code == 200: current_time = time.strftime("%X") result = f"Timestamp:{str(current_time)} URL:{str(x)}" + " test SUCCESFULL\n" else: current_time = time.strftime("%X") result = f"Timestamp:{str(current_time)} URL:{str(x)}" + " test FAILED\n" myFile.write(result) except Exception as e: current_time = time.strftime("%X") result = f"Timestamp:{str(current_time)} URL:{str(x)}" + " test FAILED\n" myFile.write(result) continue
# Run Somnium and select option 4python main.py# Choose: #4 Test connection to live Malware distribution Urls# Review resultscat Malware_Results.txt# Check your security logs# - Web proxy block logs# - DNS security logs# - Firewall threat prevention logs# - Endpoint protection alerts
SUCCESSFUL connections indicate a critical security gap. Your network security controls should block all connections to known malware distribution sites.These are LIVE malware URLs that could deliver actual malicious payloads. Ensure this test runs in a controlled environment.
Web Application Firewalls (WAF) - Block malware download attempts
Secure Web Gateways (SWG) - Categorize malware URLs and prevent access
DNS Filtering - Block DNS resolution of malware domains
Threat Intelligence Platforms - Correlate URLhaus data with other threat feeds
SIEM Systems - Generate alerts for malware distribution attempts
Sandbox Solutions - Detonate suspicious URLs in isolated environments
This test attempts connections to 20 random malware distribution URLs from the live feed. Some URLs may be taken offline or blocked at the infrastructure level, resulting in FAILED connections.