Saturday 5 March 2022

Organization information of list of IP address in text file - With Threading

 import threading

from ipwhois import IPWhois

iplist1=open("iplist1.txt","r")

iplistlines1=iplist1.readlines()

iplist2=open("iplist2.txt","r")

iplistlines2=iplist2.readlines()

def list1():

    for ip1 in iplistlines1:

        ip1=ip1.strip()

        try:

            domaindetails=IPWhois(ip1)

            fulldetails=domaindetails.lookup_whois()

            org=fulldetails.get('asn_description')

            org=str(org)

            print(ip1+" "+org)

        except:

            print("Error Getting details of "+ip1)

  

def list2():

    for ip2 in iplistlines2:

        ip2=ip2.strip()

        try:

            domaindetails=IPWhois(ip2)

            fulldetails=domaindetails.lookup_whois()

            org=fulldetails.get('asn_description')

            org=str(org)

            print(ip2+" "+org)

        except:

            print("Error Getting details of "+ip2)

t1 = threading.Thread(target=list1)

t2 = threading.Thread(target=list2)

t1.start()

t2.start()

Friday 4 March 2022

Simple script to find Organization information of list of IP address in text file

"""Copy IP addresses to iplist.txt. Output will print IP addresses and ASN description which will be useful to find organization.

or we can use other key values as per our requirement"""


from ipwhois import IPWhois

iplist=open("iplist.txt","r")

iplistlines=iplist.readlines()

for ip in iplistlines:

    ip=ip.strip()

    try:

        domaindetails=IPWhois(ip)

        fulldetails=domaindetails.lookup_whois()

        org=fulldetails.get('asn_description')

        org=str(org)

        print(ip+" "+org)

    except:

        print("Error Getting details of "+ip)