import socket
import whois
import asyncio
async def enumerate_asn(target: str) -> dict:
"""
Enumerate ASN and IP info
"""
try:
# Resolve IP
ip = socket.gethostbyname(target)
# Whois
# Running synchronous whois in thread
loop = asyncio.get_event_loop()
w = await loop.run_in_executor(None, lambda: whois.whois(target))
return {
"ip": ip,
"asn": w.get("org", "Unknown"),
"registrar": w.get("registrar", "Unknown"),
"country": w.get("country", "Unknown"),
"full_record": str(w)
}
except Exception as e:
return {"error": str(e)}