Does anyone know of a Python module or a solution for how I could lookup company info (Name preferably) via the ASN (autonomous system number) number?
There are lots of IP to ASN tools but that is not what I require.
ASN needs to be the input - company name output.
This website has the sort of info I need:
http://bgp.potaroo.net/cgi-bin/as-report?as=AS5607&view=2.0
Any ideas are appreciated!
whois.ra.net might contain what you are looking for. It is a whois-server that can be queried by both AS number as ip address.
Most python modules do not appear to allow you to set the whois server to be queried. You might have to implement a whois client yourself, it is pretty simple:
Try:
import socket
def whois(server, query):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((server, 43))
sock.send(query + '\r\n')
response = ''
while True:
d = sock.recv(4096)
response += d
if d == '':
break
sock.close()
return response
print whois('whois.ra.net', 'AS15169')
That information is available publicly on the CIDR-Report website.
This url has all the info you need and is updated daily. Big file, it might take a while to load :
http://www.cidr-report.org/as2.0/autnums.html
Try this, it's maybe what you need
from cymruwhois import Client
import ipresolved
domain='facebook.com'
ips=ipresolved.getipresolvedfromdomain(domain)
c=Client()
for i in ips.json()['resolutions']:
ip=i['ip_address']
print('ip : '+ip)
r=c.lookup(ip)
print('asn number: ',r.asn)
print('asn owener : ',r.owner)
print('==============')