-
Notifications
You must be signed in to change notification settings - Fork 0
/
ip.py
280 lines (220 loc) · 10.8 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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
import socket #Discover TCP/UDP
import argparse
import whois #Discover information on the internet
import time #Put the time in the script
import requests
import sys #Stop Script
import geocoder #Discover geolocation
import os
import colorama #Color in the script
from colorama import Fore, Style
from urllib.request import urlparse
clear = os.system("clear")
if clear == True:
os.system("cls")
else:
print("")
colorama.init()
print(Fore.RED)
s1 = '''
██████ |
▒██ ▒ | BY: suchsoak
░ ▓██▄ | GitHub: https://github.com/suchsoak
▒ ██▒ | v:1.0.1
▒██████▒▒ |
▒ ▒▓▒ ▒ ░ |
░ ░▒ ░ |
░ ░ ░ |
░ |
'''
print(s1)
print("\n")
parser = argparse.ArgumentParser()
parser.add_argument('-u', '--url', help='url', dest='target')
parser.add_argument('-i', '--ip', help='ip', dest='target2')
args = parser.parse_args()
try: #IP information
if args.target2:
ip_info1 = args.target2
info_ip1 = os.system(f'curl ipinfo.io/{args.target2}')
if info_ip1 != 0:
print("Error getting IP information.")
sys.exit(1)
else:
sys.exit(0)
except KeyboardInterrupt:
print("KeyboardInterrup")
try:
if args.target:
Host = args.target
else:
os.system("python3 ip.py -h")
sys.exit()
except KeyboardInterrupt:
print("KeyboardInterrup")
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print(Style.RESET_ALL)
try:
socket.inet_aton(Host)
url = f'http://{Host}'
except socket.error:
url = f'https://{Host}'
except Exception as b:
print(b)
response = requests.get(url)
if response.status_code != '200':
print('')
else:
print('')
try:
g = geocoder.ip (f'{Host}')
if geocoder.google is not None:
go = geocoder.google (f'{Host}')
except Exception as a:
print(a)
class who():
try:
whois_resul = whois.whois(Host)
ur = urlparse(url)
if socket.gethostname is not None:
ip = socket.gethostbyname(Host)
print('-----------------------------------------------------------------------------------------------------------------------------------')
if ip is not None:
print(Fore.RED)
print("[*] IP:", ip.rjust(70))
print(Style.RESET_ALL)
print("")
print('-----------------------------------------------------------------------------------------------------------------------------------')
if response.status_code is not None:
print("[*] Status Code:", str(response.status_code).rjust(70))
print("")
print('-----------------------------------------------------------------------------------------------------------------------------------')
if response.encoding is not None:
print("[*] Encoding:", str(response.encoding).rjust(75))
print("")
print('-----------------------------------------------------------------------------------------------------------------------------------')
if ur.scheme is not None:
print("[*] Scheme:", str(ur.scheme).rjust(75))
print("")
print('-----------------------------------------------------------------------------------------------------------------------------------')
if response.cookies is not None:
print("[*] Cookies:", str(response.cookies).rjust(75))
print("")
print('-----------------------------------------------------------------------------------------------------------------------------------')
if whois_resul.query is not None:
print("[*] query:", str(whois_resul.query).rjust(75))
print("")
print('-----------------------------------------------------------------------------------------------------------------------------------')
if go.postal is not None:
print("[*] Postcode street:", str(go.postal).rjust(70))
print("")
print('-----------------------------------------------------------------------------------------------------------------------------------')
if go.street is not None:
print("[*] Street:", str(go.street).rjust(70))
print("")
print('-----------------------------------------------------------------------------------------------------------------------------------')
if go.street_long is not None:
print("[*] Stree Long:", str(go.street_long).rjust(70))
print("")
print('-----------------------------------------------------------------------------------------------------------------------------------')
if go.housenumber is not None:
print('[*] house number:', str(go.housenumber).rjust(70))
print("")
print('-----------------------------------------------------------------------------------------------------------------------------------')
if g.city is not None:
print('[*] city:', str(g.city).rjust(70))
print("")
print('-----------------------------------------------------------------------------------------------------------------------------------')
if g.reverse is not None:
print('[*] Reverse:', str(g.reverse).rjust(70))
print("")
print('-----------------------------------------------------------------------------------------------------------------------------------')
if whois_resul.admin_contact is not None:
print("[*] Admin contact:", str(whois_resul.admin_contact).rjust(70))
print("")
print('-----------------------------------------------------------------------------------------------------------------------------------')
if whois_resul.tech_contact is not None:
print("[*] tech contact:", str(whois_resul.tech_contact).rjust(70))
print("")
print('-----------------------------------------------------------------------------------------------------------------------------------')
if g.country is not None:
print('[*] country:', str(g.country).rjust(70))
print("")
print('-----------------------------------------------------------------------------------------------------------------------------------')
if g.lat is not None:
print("[*] lat:", str(g.lat).rjust(70))
print("")
print('-----------------------------------------------------------------------------------------------------------------------------------')
if g.lng is not None:
print("[*] lng:", str(g.lng).rjust(70))
print("")
print('-----------------------------------------------------------------------------------------------------------------------------------')
if whois_resul.domain_name is not None:
print("[*] Domain name:", str(whois_resul.domain_name).rjust(70))
print("")
print('-----------------------------------------------------------------------------------------------------------------------------------')
if whois_resul.updated_date is not None:
print("[*] Updated date:", str(whois_resul.updated_date).rjust(70))
print("")
print('-----------------------------------------------------------------------------------------------------------------------------------')
if whois_resul.registrant is not None:
print("[*] Registrant:", str(whois_resul.registrant).rjust(70))
print("")
print('-----------------------------------------------------------------------------------------------------------------------------------')
if whois_resul.creation_date is not None:
print("[*] Creation date:", str(whois_resul.creation_date).rjust(70))
print("")
print('-----------------------------------------------------------------------------------------------------------------------------------')
if whois_resul.name_servers is not None:
print("[*] Name servers:", str(whois_resul.name_servers).rjust(70))
print("")
print('-----------------------------------------------------------------------------------------------------------------------------------')
if whois_resul.expiration_date is not None:
print("[*] Expiration date:", str(whois_resul.expiration_date).rjust(70))
print("")
print('-----------------------------------------------------------------------------------------------------------------------------------')
if response.headers is not None:
print("[*] Headers:", str(response.headers).rjust(70))
print("")
print('-----------------------------------------------------------------------------------------------------------------------------------')
if whois_resul.date is not None:
print("[*] Date:", str(whois_resul.date).rjust(70))
print("")
print('-----------------------------------------------------------------------------------------------------------------------------------')
if whois_resul.status is not None:
print("[*] Status:", str(whois_resul.status).rjust(70))
print("")
print('-----------------------------------------------------------------------------------------------------------------------------------')
except KeyboardInterrupt:
print('program stopped')
except Exception as erro:
print('An error has occurred')
s.settimeout(1)
print('\n')
print("Getting ports...\n")
service = socket.getservbyport
s.settimeout(1)
no = True
#ports = [21, 22, 23, 25, 53, 80, 8080, 53, 110, 135, 139, 143, 70, 443, 445, 993, 995]
ports = range(1, 65535)
sleep = time.sleep
sleep(2)
class Ports:
try:
for port in ports:
resultado = s.connect_ex((Host, port))
sleep(2)
if resultado == 0:
print('\t\n')
print('[*] Open: ',(port), (service(port)).rjust(70))
print('\t\n')
no = False
else:
pass
if no:
print("No ports found.")
except KeyboardInterrupt:
print('program stopped')
except Exception as err:
print(err)