-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathk_checkIP.py
More file actions
75 lines (51 loc) · 3.25 KB
/
k_checkIP.py
File metadata and controls
75 lines (51 loc) · 3.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/python
#
#This script search the BIN files for the given IP
#
import kalchas_headers
import os
import IP2Location
import IP2Proxy
#Initialize the main functions
Location2BIN = "IP2LOCATION-LITE-DB11.IPV6.BIN"
Proxy2BIN = "IP2PROXY-LITE-PX4.BIN"
proxy = IP2Proxy.IP2Proxy()
location = IP2Location.IP2Location()
#Get the real path which the bin files are saved
location.open(os.path.realpath(Location2BIN))
proxy.open(os.path.realpath(Proxy2BIN))
def check_ip(ip):
#Get all results for the given IP from IP2Proxy Lite
proxyResults = proxy.get_all(ip)
#GEt all results for the given IP from IP2Location Lite
locationResults = location.get_all(ip)
proxyConfirmation = str(proxy.is_proxy(ip))
#Check if there are no values in Proxy DB
if proxyResults['isp'] == "-":
proxyResults['isp'] = "-"
# if proxyResults['country_log'] == "-":
# proxyResults['country_log'] = "-"
if proxyResults['region'] == "-":
proxyResults['region'] ="-"
if proxyResults['city'] == "-":
proxyResults['city'] = "-"
if proxyConfirmation == "0":
#The ip is not in Proxy database, and probable is real ip
kalchas_headers.location_headers()
print (locationResults.country_long.decode('ascii').ljust(10), locationResults.region.decode('ascii').ljust(10), locationResults.city.decode('ascii').ljust(10), locationResults.zipcode.decode('ascii').ljust(10), str(locationResults.longitude).ljust(10), str(locationResults.latitude).ljust(10))
#The IP is on Proxy Database
if proxyConfirmation == "1":
#Check the proxy type
if proxyResults['proxy_type'] == "PUB":
kalchas_headers.proxy_headers()
print (proxyResults['proxy_type'].ljust(10), proxyResults['country_long'].ljust(10), proxyResults['region'].ljust(10), proxyResults['city'].ljust(10), proxyResults['isp'].ljust(10), str(locationResults.longitude).ljust(10), str(locationResults.latitude).ljust(10))
if proxyResults['proxy_type'] == "TOR":
kalchas_headers.misc_headers()
print (proxyResults['proxy_type'].ljust(10), locationResults.country_long.decode('ascii').ljust(10), locationResults.region.decode('ascii').ljust(10), locationResults.city.decode('ascii').ljust(10), locationResults.zipcode.decode('ascii').ljust(10), str(locationResults.longitude).ljust(10), str(locationResults.latitude).ljust(10))
if proxyResults['proxy_type'] == "VPN":
kalchas_headers.misc_headers()
print (proxyResults['proxy_type'].ljust(10), locationResults.country_long.decode('ascii').ljust(10), locationResults.region.decode('ascii').ljust(10), locationResults.city.decode('ascii').ljust(10), locationResults.zipcode.decode('ascii').ljust(10), str(locationResults.longitude).ljust(10), str(locationResults.latitude).ljust(10))
#The IP is DHC
if proxyConfirmation == "2":
kalchas_headers.misc_headers()
print (proxyResults['proxy_type'].ljust(10), locationResults.country_long.decode('ascii').ljust(10), locationResults.region.decode('ascii').ljust(10), locationResults.city.decode('ascii').ljust(10), locationResults.zipcode.decode('ascii').ljust(10), str(locationResults.longitude).ljust(10), str(locationResults.latitude).ljust(10))