3

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!

gamarga
  • 105
  • 2
  • 7
  • 1.Use beautful soup to get all those ips in that page.Once you got all ips check this for lookup.http://stackoverflow.com/questions/2575760/python-lookup-hostname-from-ip-with-1-second-timeout – Ajay Apr 06 '15 at 18:24
  • Thanks but I already have a lookup tool to get all the info from IP. The problem is ASN's contact a large number of IP ranges and if the domain controller has not done their house keeping the company name can vary per IP. I now just need a tool just for ASN lookups. I will try using beautiful soup as a quick fix.... – gamarga Apr 06 '15 at 18:34

3 Answers3

2

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('==============')
Andre Hofmeister
  • 3,185
  • 11
  • 51
  • 74
Al Pha
  • 21
  • 2
1

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

A-y
  • 793
  • 5
  • 16
  • that is a good answer. but could we also get historical mappings as well? say the mapping a few years ago – ℕʘʘḆḽḘ Jun 28 '18 at 12:15
  • Historical Data is more tricky. Nothing stops you from getting the CIDR report daily to start building your own historical database, but I'm not aware of any free service that offers this. – A-y Aug 09 '18 at 13:11
0

A slightly updated version of @Al-Pha answer:

Multi lookup:

from cymruwhois import Client
import socket

c = Client()
ip = socket.gethostbyname('globalresearch.ca')
for r in c.lookupmany([ip, "213.73.91.35"]):
    print(r.__dict__)
    # print(r.asn)

Single lookup:

c = Client()
r = c.lookup("213.73.91.35")
print(r.asn)
Pedro Lobito
  • 94,083
  • 31
  • 258
  • 268