Lotsa stuff
This commit is contained in:
parent
7a10ba2c3d
commit
40c3fa5c9d
9
iplist.txt
Normal file
9
iplist.txt
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
1 10.10.9.238
|
||||||
|
1 101.177.142.143
|
||||||
|
1 101.178.247.210
|
||||||
|
1 101.187.62.184
|
||||||
|
1 10.2.0.243
|
||||||
|
1 103.94.50.245
|
||||||
|
1 106.120.173.89
|
||||||
|
1 107.161.8.230
|
||||||
|
|
||||||
44
main.py
44
main.py
@ -3,10 +3,50 @@ from ipwhois.net import Net
|
|||||||
from ipwhois.asn import IPASN
|
from ipwhois.asn import IPASN
|
||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
|
|
||||||
net = Net('110.232.142.184')
|
tmpips = [] #NOTE Need to reset this variable between runs
|
||||||
|
ips = []
|
||||||
|
|
||||||
|
def openFile(filename):
|
||||||
|
try:
|
||||||
|
ipList = open(filename)
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
print("Please create an iplist.txt file")
|
||||||
|
return ipList
|
||||||
|
def splitLine(fileline):
|
||||||
|
tmpline = fileline.split('\n')
|
||||||
|
retval = []
|
||||||
|
return tmpline
|
||||||
|
|
||||||
|
ipListFile = openFile("iplist.txt")
|
||||||
|
ipList = ipListFile.read()
|
||||||
|
test = splitLine(ipList)
|
||||||
|
print test
|
||||||
|
for a in test:
|
||||||
|
b = a.split(' ')
|
||||||
|
tmpips.append(b)
|
||||||
|
for x in tmpips:
|
||||||
|
for y in x:
|
||||||
|
if y != '':
|
||||||
|
ips.append(y)
|
||||||
|
for value in ips:
|
||||||
|
if "." in value:
|
||||||
|
lookup(value)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# if x != "''":
|
||||||
|
# print(x)
|
||||||
|
#print(test)
|
||||||
|
#print ipList
|
||||||
|
#for a in ipList:
|
||||||
|
# print(a)
|
||||||
|
|
||||||
|
def lookup(ip):
|
||||||
|
net = Net(ip)
|
||||||
obj = IPASN(net)
|
obj = IPASN(net)
|
||||||
results = obj.lookup()
|
results = obj.lookup()
|
||||||
#pprint(results)
|
pprint(results)
|
||||||
for key,value in results.iteritems():
|
for key,value in results.iteritems():
|
||||||
if key == "asn_country_code":
|
if key == "asn_country_code":
|
||||||
print(value)
|
print(value)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user