-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathip.py
136 lines (107 loc) · 4.69 KB
/
ip.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
import sys
import requests
import json
import textwrap
answer = True
while answer:
head = """
_ _ _ _ ___ ____ ____ _ _ _ ___
|\\ | \\/ | | __ |___ |\\ | __ | |__]
| \\| _/\\_ | |__] |___ | \\| | |
[1] My ip
[2] Ip query
[3] Check for update
[4] Contact the developer
[5] Exit.
"""
head_text ="\033[2;34m".join(textwrap.dedent(head))
print(f'{head_text}\033[2;0m')
answer = input("SELECT AN OPTION:")
if answer == "1":
def my_ip():
response = requests.get('https://api64.ipify.org?format=json').json()
ur_ip = response["ip"]
return f'Your ip address : {ur_ip}'
print(my_ip())
elif answer == "2":
the_ip = input("INPUT THE IP ADDRESS HERE:")
if len(the_ip.split('.')) >= 3:
file_type = 'json'
lookup = 'https://ipapi.co'
def locate_data():
response = requests.get(f'{lookup}/{the_ip}/{file_type}/').json()
location_data={
"ip": the_ip,
"org": response.get("org"),
"latitude": response.get("latitude"),
"longitude": response.get("longitude"),
"hostname": response.get("hostname"),
"version": response.get("version"),
"city": response.get("city"),
"country": response.get("country"),
"country_code": response.get("country_code"),
"country_name": response.get("country_name"),
"country_code_iso3": response.get("country_code_iso3"),
"country_capital": response.get("country_capital"),
"country_tld": response.get("country_tld"),
"country_area": response.get("country_area"),
"country_population": response.get("country_population"),
"region": response.get("region"),
"region_code": response.get("region_code"),
"continent_code": response.get("continent_code"),
"in_europe": response.get("in_eu"),
"postal": response.get("postal"),
"timezone": response.get("timezone"),
"utc_offset": response.get("utc_offset"),
"country_calling_code": response.get("country_calling_code"),
"currency": response.get("currency"),
"currency_name": response.get("currency_name"),
"languages": response.get("languages"),
}
return location_data
print(json.dumps(locate_data(), indent=4))
file = open('results.txt', 'w')
file.write(json.dumps(locate_data(), indent=4))
file.close()
info = list(locate_data().values())
if isinstance(info[2], (int,float)):
gen = True
while gen:
gen = input("\033[2;34mTo generate a google map link with coordinates input 'Y' if not 'N':\033[2;0m")
if gen =='Y' or 'y':
latitude = info[2]
longitude = info[3]
google_lnk = 'https://www.google.com/maps/search/'
print(f'\033[2;35m{google_lnk}@{latitude},{longitude},3z\033[2;0m\n')
break
elif gen == 'N' or 'n':
break
elif gen!='':
print("\033[2;31mCommand not recognised\033[2;0m")
else:
print('\033[2;31mThat wasn\'t an ip address\033[2;0m')
elif answer == '3':
import subprocess
import os
def fetch_update():
try:
handler = subprocess.run(['git', 'pull', 'origin', 'main'], capture_output = True, text = True)
if handler.stdout:
return f'\033[2;35m{handler.stdout.strip()}\nRestart the program if necessary\033[2;0m'
return f'\033[2;31m{handler.stderr.strip()}\033[2;0m'
except Exception as error:
return f'Error encountered {str(error)}'
print(fetch_update())
elif answer == "4":
contact ="""
FACEBOOK PAGE : https://facebook.com/harkerbyte
GROUP CHAT : https://facebook.com/group/shade234sherif
MAIN ACC : https://facebook.com/shade234sherif
BE SURE TO FOLLOW ON GITHUB @harkerbyte
"""
clear_text = "\033[2;33m".join(textwrap.dedent(contact))
print(clear_text)
elif answer == "5":
sys.exit()
elif answer != "":
print("""INVALID OPTION KINDLY RETRY """)