-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathip.py
187 lines (152 loc) · 7.34 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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# ###############################
# import requests
# from bs4 import BeautifulSoup
# print(f"""
# \033[34m
# ██╗░░░██╗██████╗░░█████╗░███╗░░██╗██╗██╗░░░██╗███╗░░░███╗
# ██║░░░██║██╔══██╗██╔══██╗████╗░██║██║██║░░░██║████╗░████║
# ██║░░░██║██████╔╝███████║██╔██╗██║██║██║░░░██║██╔████╔██║
# ██║░░░██║██╔══██╗██╔══██║██║╚████║██║██║░░░██║██║╚██╔╝██║
# ╚██████╔╝██║░░██║██║░░██║██║░╚███║██║╚██████╔╝██║░╚═╝░██║
# ░╚═════╝░╚═╝░░╚═╝╚═╝░░╚═╝╚═╝░░╚══╝╚═╝░╚═════╝░╚═╝░░░░░╚═╝
# Dev : DevUranium.t.me
# GitHUB :
# """)
# def get_csrf_token():
# url = "https://check-host.net/ip-info"
# response = requests.get(url)
# response.raise_for_status()
# soup = BeautifulSoup(response.text, 'html.parser')
# csrf_token_input = soup.find('input', {'name': 'csrf_token'})
# if csrf_token_input:
# csrf_token = csrf_token_input['value']
# return csrf_token
# else:
# print("CSRF token not found.")
# return None
# def send_request(ip_address):
# csrf_token = get_csrf_token()
# if csrf_token is not None:
# url = f"https://check-host.net/ip-info?host={ip_address}&csrf_token={csrf_token}"
# response = requests.get(url)
# response.raise_for_status()
# soup = BeautifulSoup(response.text, 'html.parser')
# table = soup.find('table', class_='ipinfo-table')
# data = {}
# for row in table.find_all('tr'):
# columns = row.find_all('td')
# if len(columns) == 2:
# key = columns[0].get_text(strip=True)
# value = columns[1].get_text(strip=True)
# data[key] = value
# for key, value in data.items():
# print(f"{key} : {value}")
# else:
# print("Cannot send request without CSRF token.")
# ip = input("\033[32mIP Enter : \033[0m")
# send_request(ip)
# ###############################
import requests
from bs4 import BeautifulSoup
def print_banner():
print(f"""
\033[34m
██╗░░░██╗██████╗░░█████╗░███╗░░██╗██╗██╗░░░██╗███╗░░░███╗
██║░░░██║██╔══██╗██╔══██╗████╗░██║██║██║░░░██║████╗░████║
██║░░░██║██████╔╝███████║██╔██╗██║██║██║░░░██║██╔████╔██║
██║░░░██║██╔══██╗██╔══██║██║╚████║██║██║░░░██║██║╚██╔╝██║
╚██████╔╝██║░░██║██║░░██║██║░╚███║██║╚██████╔╝██║░╚═╝░██║
░╚═════╝░╚═╝░░╚═╝╚═╝░░╚═╝╚═╝░░╚══╝╚═╝░╚═════╝░╚═╝░░░░░╚═╝\033[0m
""")
def get_csrf_token():
url = "https://check-host.net/ip-info"
response = requests.get(url)
response.raise_for_status()
soup = BeautifulSoup(response.text, 'html.parser')
csrf_token_input = soup.find('input', {'name': 'csrf_token'})
if csrf_token_input:
csrf_token = csrf_token_input['value']
return csrf_token
else:
print("CSRF token not found.")
return None
def get_ip_info(ip_address):
csrf_token = get_csrf_token()
if csrf_token is not None:
url = f"https://check-host.net/ip-info?host={ip_address}&csrf_token={csrf_token}"
response = requests.get(url)
response.raise_for_status()
soup = BeautifulSoup(response.text, 'html.parser')
table = soup.find('table', class_='ipinfo-table')
data = {}
for row in table.find_all('tr'):
columns = row.find_all('td')
if len(columns) == 2:
key = columns[0].get_text(strip=True)
value = columns[1].get_text(strip=True)
data[key] = value
for key, value in data.items():
print(f"\033[36m{key} : \033[33m{value}")
else:
print("Cannot send request without CSRF token.")
def check_ip_residential(ip_address):
url = f'https://proxycheck.io/v2/{ip_address}?vpn=1&asn=1'
response = requests.get(url)
data = response.json()
try:
status = data.get('status', "")
ip_data = data.get(ip_address, {})
asn = ip_data.get('asn', "")
provider = ip_data.get('provider', "")
organisation = ip_data.get('organisation', "")
continent = ip_data.get('continent', "")
country = ip_data.get('country', "")
isocode = ip_data.get('isocode', "")
region = ip_data.get('region', "")
regioncode = ip_data.get('regioncode', "")
timezone = ip_data.get('timezone', "")
city = ip_data.get('city', "")
postcode = ip_data.get('postcode', "")
latitude = ip_data.get('latitude', "")
longitude = ip_data.get('longitude', "")
currency = ip_data.get('currency', {}).get('code', "")
symbol = ip_data.get('currency', {}).get('symbol', "")
proxy = ip_data.get('proxy', "")
IPtype = ip_data.get('type', "")
print(f"IP: {ip_address}")
print(f"Status: {status}")
print(f"ASN: {asn}")
print(f"Provider: {provider}")
print(f"Organisation: {organisation}")
print(f"Continent: {continent}")
print(f"Country: {country}")
print(f"ISO code: {isocode}")
print(f"Region: {region}")
print(f"Region code: {regioncode}")
print(f"Timezone: {timezone}")
print(f"City: {city}")
print(f"Postcode: {postcode}")
print(f"Latitude: {latitude}")
print(f"Longitude: {longitude}")
print(f"Currency: {currency}")
print(f"Currency symbol: {symbol}")
print(f"Proxy: {proxy}")
print(f"IP type: {IPtype}")
except Exception as e:
print(f'Error: {str(e)}')
def main():
print_banner()
print("Choose an option:")
print("1. IP Info")
print("2. IP Check Residential")
choice = input("Enter number: ")
if choice not in ['1', '2']:
print("\033[31mInvalid choice.\033[0m")
return
ip = input("Enter IP address: ")
if choice == '1':
get_ip_info(ip)
elif choice == '2':
check_ip_residential(ip)
if __name__ == "__main__":
main()