-
Notifications
You must be signed in to change notification settings - Fork 11
/
am-I-anonymous.py
55 lines (46 loc) · 1.71 KB
/
am-I-anonymous.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
from ip2geotools.databases.noncommercial import DbIpCity
import requests
logo = '''
_____
_ |___ |
___ _____ |_| ___ ___ ___ ___ _ _ _____ ___ _ _ ___ | _|
| .'| | | | | .'| | . | | | | | . | | |_ -| |_|
|__,|_|_|_| |_| |__,|_|_|___|_|_|_ |_|_|_|___|___|___| |_|
|___|
code from R3DHULK github page : https://github.com/R3DHULK
'''
print(logo)
ANSI_COLOR_SAFE = '\033[92m'
ANSI_COLOR_NOTSAFE = '\033[91m'
def fetch_public_ip():
fetch_adress = 'https://checkip.amazonaws.com'
return requests.get(fetch_adress).text.strip()
def resolve_city(ip):
response = DbIpCity.get(ip, api_key='free')
return response.city
def resolve_country(ip):
response = DbIpCity.get(ip, api_key='free')
return response.country
def main():
public_ip = fetch_public_ip()
city = resolve_city(public_ip)
country = resolve_country(public_ip)
# Setting font color depending on country
if country != 'DE':
safe = True
print(f'{ANSI_COLOR_SAFE}', end='')
else:
safe = False
print(f'{ANSI_COLOR_NOTSAFE}', end='')
print('///////////////////////////////////////////////')
print('Public IP: {}'.format(public_ip))
print('Location: {}, {}'.format(city, country))
print('\n')
if safe:
print(" [!] It seems, that you're safe!\n")
else:
print(' [!] Hmmm... Check the VPN one more time!\n')
print('///////////////////////////////////////////////')
if __name__ == '__main__':
main()
input(" press close to exit ")