From 751e60ff9a8c6623f0170d78c7945c6eb98d2235 Mon Sep 17 00:00:00 2001 From: Benjamyn Date: Mon, 5 Feb 2018 16:49:42 -0500 Subject: [PATCH] Grabbed new test data; Added mass IPlookup; Created dictionary with IP, CountryCode; Sorted dictionary by country code; --- iplist.old | 9 +++ iplist.txt | 189 +++++++++++++++++++++++++++++++++++++++++++++++++++-- main.py | 18 +++-- 3 files changed, 204 insertions(+), 12 deletions(-) create mode 100644 iplist.old diff --git a/iplist.old b/iplist.old new file mode 100644 index 0000000..0d1fd34 --- /dev/null +++ b/iplist.old @@ -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 + diff --git a/iplist.txt b/iplist.txt index 0d1fd34..8e37de9 100644 --- a/iplist.txt +++ b/iplist.txt @@ -1,9 +1,184 @@ - 1 10.10.9.238 - 1 101.177.142.143 - 1 101.178.247.210 - 1 101.187.62.184 + 1 101.166.225.40 + 1 101.187.223.112 1 10.2.0.243 - 1 103.94.50.245 - 1 106.120.173.89 - 1 107.161.8.230 + 1 103.10.99.234 + 1 103.227.21.224 + 1 104.154.198.228 + 1 104.47.117.68 + 1 109.123.101.103 + 1 110.249.143.106 + 1 111.38.216.5 + 1 111.67.31.6 + 1 1.121.101.134 + 1 1.126.108.83 + 1 112.91.108.190 + 1 1.132.107.219 + 1 1.136.108.33 + 1 1.136.108.5 + 1 115.84.112.138 + 1 120.148.65.182 + 1 120.150.221.35 + 1 120.209.233.191 + 1 121.221.69.135 + 1 122.106.224.146 + 1 124.185.119.95 + 1 124.193.199.202 + 1 127.0.0.1 + 1 132.3.9.79 + 1 132.3.9.80 + 1 137.147.147.70 + 1 139.130.182.134 + 1 151.231.79.195 + 1 162.158.255.83 + 1 162.158.78.101 + 1 162.158.78.113 + 1 162.158.78.143 + 1 162.158.78.155 + 1 162.158.78.5 + 1 162.158.78.83 + 1 162.158.79.108 + 1 162.158.79.132 + 1 162.158.79.144 + 1 162.158.79.168 + 1 162.158.79.48 + 1 162.158.79.66 + 1 172.68.211.227 + 1 172.68.65.211 + 1 172.68.65.217 + 1 172.68.65.223 + 1 172.68.65.241 + 1 172.68.65.37 + 1 172.69.22.213 + 1 172.69.33.192 + 1 172.69.62.11 + 1 172.69.62.131 + 1 172.69.62.143 + 1 172.69.62.149 + 1 172.69.62.185 + 1 172.69.62.53 + 1 172.69.62.65 + 1 173.245.54.26 + 1 173.245.54.44 + 1 173.252.98.201 + 1 175.36.210.207 + 1 176.10.125.27 + 1 178.140.233.218 + 1 178.234.35.42 + 1 185.30.176.187 + 1 185.30.177.73 + 1 185.86.149.131 + 1 192.0.101.226 + 1 192.88.134.14 + 1 199.101.132.161 + 1 202.153.70.141 + 1 202.9.16.14 + 1 204.11.32.249 + 1 207.46.13.0 + 1 207.46.13.132 + 1 207.46.13.174 + 1 207.46.13.61 + 1 208.64.39.184 + 1 208.79.209.58 + 1 211.118.26.122 + 1 218.22.206.178 + 1 218.66.84.85 + 1 219.88.246.28 + 1 220.171.28.146 + 1 220.174.209.154 + 1 2400 + 1 27.151.116.18 + 1 35.185.103.191 + 1 35.185.113.230 + 1 35.227.63.41 + 1 37.9.113.95 + 1 43.248.55.247 + 1 45.126.47.164 + 1 49.195.118.215 + 1 49.195.204.239 + 1 5.41.10.110 + 1 5.45.207.18 + 1 58.108.204.108 + 1 58.111.149.182 + 1 60.166.52.51 + 1 60.215.144.50 + 1 63.143.42.250 + 1 66.249.69.126 + 1 66.249.79.144 + 1 66.249.79.158 + 1 66.249.79.27 + 1 66.249.79.61 + 1 66.249.79.7 + 1 66.249.79.90 + 1 69.171.225.86 + 1 69.175.3.11 + 1 73.248.226.154 + 1 77.101.195.157 + 1 77.75.78.170 + 1 98.101.54.102 + 2 10.10.9.238 + 2 101.178.3.124 + 2 103.75.205.28 + 2 110.141.40.11 + 2 1.132.111.146 + 2 118.209.106.244 + 2 120.203.25.58 + 2 120.22.58.32 + 2 124.149.207.123 + 2 124.183.205.152 + 2 1.255.70.114 + 2 13.69.78.34 + 2 13.84.48.123 + 2 13.89.226.135 + 2 13.89.234.94 + 2 13.89.236.228 + 2 144.139.70.151 + 2 162.158.79.228 + 2 168.62.184.200 + 2 180.95.27.37 + 2 185.29.10.31 + 2 185.93.231.14 + 2 194.187.248.52 + 2 203.196.37.229 + 2 210.10.173.195 + 2 213.44.246.57 + 2 23.101.146.22 + 2 40.123.42.42 + 2 40.123.46.104 + 2 40.123.47.194 + 2 40.69.140.47 + 2 40.69.171.237 + 2 40.76.12.12 + 2 40.76.1.22 + 2 50.4.140.177 + 2 52.165.154.70 + 2 52.165.158.40 + 2 58.106.133.27 + 2 66.249.79.3 + 2 89.40.123.219 + 2 90.94.38.162 + 3 103.217.166.29 + 3 114.198.9.220 + 3 66.249.79.159 + 4 101.183.140.224 + 4 103.224.160.194 + 4 138.217.43.170 + 4 13.89.233.10 + 4 203.173.31.104 + 4 203.220.162.117 + 6 103.42.110.4 + 6 120.150.133.75 + 6 203.5.82.2 + 6 58.111.132.93 + 6 60.241.198.14 + 7 121.218.164.246 + 8 1.129.107.203 + 8 194.6.231.240 + 11 12.216.166.60 + 11 165.228.5.225 + 12 153.107.192.207 + 13 120.154.177.224 + 21 203.206.172.110 + 42 + 53 0.0.0.0 + 56 39.42.184.251 diff --git a/main.py b/main.py index 4bfde3c..687cbc7 100644 --- a/main.py +++ b/main.py @@ -5,6 +5,8 @@ from pprint import pprint tmpips = [] #NOTE Need to reset this variable between runs ips = [] +ipdict = {} + def openFile(filename): try: @@ -19,23 +21,24 @@ def splitLine(fileline): return tmpline def lookup(ip): + global ipdict try: net = Net(ip) obj = IPASN(net) results = obj.lookup() - pprint(results) + #pprint(results) for key,value in results.iteritems(): if key == "asn_country_code": - print(value) - if key == "asn_cidr": - print(value) + #print(value) + ipdict[ip] = value except Exception as e: print(e) + ipListFile = openFile("iplist.txt") ipList = ipListFile.read() test = splitLine(ipList) -print test +#print test for a in test: b = a.split(' ') tmpips.append(b) @@ -47,7 +50,12 @@ for value in ips: if "." in value: lookup(value) +#pprint(ipdict) +for key, value in sorted(ipdict.iteritems(), key=lambda (k,v): (v,k)): + if "AU" not in value: + if "NZ" not in value: + print key + '\t' + '\t' + value # if x != "''": # print(x)