generated from marciopocebon/zoomIP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathip_or_url_locate.py
105 lines (91 loc) · 2.62 KB
/
ip_or_url_locate.py
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/python3
# import pyfiglet module
import argparse
import requests
import sys
import os
print()
def clear():
command = 'clear'
if os.name in ('nt', 'dos'): #Windows
command = 'cls'
os.system(command)
def locate():
data = requests.get(
f"http://ip-api.com/json/{ip}?fields=status,message,continent,country,region,regionName,city,district,zip,lat,lon,timezone,currency,isp,org,as,asname,reverse,mobile,proxy"
)
resp = data.json()
print("Status: " + resp["status"])
if resp["status"] == "fail":
print("Error: " + resp["message"])
sys.exit()
lat = str(resp["lat"])
lon = str(resp["lon"])
if args.gmap:
print("\nIP/Url = "+ ip)
print(f"http://www.google.com/maps/place/{lat},{lon}")
elif args.json:
print(resp)
else:
continent = resp["continent"]
print(f"Continent : {continent}")
country = resp["country"]
print(f"Country : {country}")
region = resp["region"]
print(f"Region: {region}")
regionname = resp["regionName"]
print(f"Region Name : {regionname}")
city = resp["city"]
print(f"City : {city}")
district = resp["district"]
print(f"District : {district}")
zip = resp["zip"]
print(f"Zip : {zip}")
print(f"Latitude : {lat}")
print(f"Longitude : {lon}")
print(f"http://www.google.com/maps/place/{lat},{lon}")
timezone = resp["timezone"]
print(f"Timezone : {timezone}")
currency = resp["currency"]
print(f"Currency : {currency}")
isp = resp["isp"]
print(f"ISP : {isp}")
org = resp["org"]
print(f"ORG : {org}")
asp = resp["as"]
print(f"AS : {asp}")
aspname = resp["asname"]
print(f"AS Name : {aspname}")
reverse_lookup = resp["reverse"]
print(f"Reverse : {reverse_lookup}")
mobile = str(resp["mobile"])
print(f"Mobile : {mobile}")
proxy_used = str(resp["proxy"])
print(f"Proxy : {proxy_used}")
#argparse start
parser = argparse.ArgumentParser()
g = parser.add_mutually_exclusive_group()
parser.add_argument(
'-ip','-url',dest='target',action='store',help='specify the target to use CLI'
)
g.add_argument(
'-txt',dest='txt',
action='store_true',
help='output as text',
)
g.add_argument(
'-json', dest='json',
action='store_true',
help='output as json',
)
g.add_argument(
'-maps','-m',dest='gmap',action='store_true',help='only shows the Google maps url'
)
args = parser.parse_args()
#argparse stop
clear()
if not args.target:
ip = input("\nIP/Url = ")
if args.target:
ip = args.target
locate() #lets run it :D