From ffe0fb2150a92b1a1843a89003b1dcc3dc24ecde Mon Sep 17 00:00:00 2001 From: drakylar Date: Thu, 30 Dec 2021 01:32:56 +0300 Subject: [PATCH] Added ngrok integration. --- .gitignore | 3 ++- app.py | 21 ++++++++++++++++++--- configuration/settings.ini | 3 +++ requirements.txt | 1 + requirements_unix.txt | 1 + requirements_windows.txt | 1 + 6 files changed, 26 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index bc02fb2..75c18bc 100644 --- a/.gitignore +++ b/.gitignore @@ -18,4 +18,5 @@ **/__pychache__/ /backups/db/*.sqlite3 /venv/ -*.log \ No newline at end of file +*.log +ngrok_url.txt \ No newline at end of file diff --git a/app.py b/app.py index 93e6ce0..d403e7c 100644 --- a/app.py +++ b/app.py @@ -14,6 +14,7 @@ import glob import secure from functools import wraps +from pyngrok import ngrok from system.db import Database @@ -57,11 +58,9 @@ app.config['SECRET_KEY'] = config['main']['secret'] app.config['WTF_CSRF_TIME_LIMIT'] = 60 * 60 * int(config['security']['csrf_lifetime']) - # enable jsonify pretty output app.config['JSONIFY_PRETTYPRINT_REGULAR'] = True - app.register_blueprint(api_bp) app.register_blueprint(main_routes) @@ -287,6 +286,22 @@ def inject_stage_and_region(): if __name__ == '__main__': + if config['network']['ngrok'] == '1': + if not config['network']['ngrok_token']: + print('Need NGROK token to use it!') + ngrok_ip = config['network']['host'] if config['network']['host'] != '0.0.0.0' else '127.0.0.1' + ngrok_tunnel = ngrok.connect(ngrok_ip + ':' + config['network']['port'], + proto="http") + ngrok.set_auth_token(config['network']['ngrok_token']) + ngrok_url = ngrok_tunnel.public_url + print('#' * (len(ngrok_url) + 11)) + print('# Ngrok: {} #'.format(ngrok_url)) + print('#' * (len(ngrok_url) + 11)) + print('All data duplicated') + f = open(config['network']['ngrok_url_file'], 'w') + f.write(ngrok_url) + f.close() + if config['ssl']['ssl'] == '1': import ssl @@ -306,4 +321,4 @@ def inject_stage_and_region(): debug=(config['main']['debug'] == '1'), threaded=True) else: - application = app \ No newline at end of file + application = app diff --git a/configuration/settings.ini b/configuration/settings.ini index c550565..5e627d1 100644 --- a/configuration/settings.ini +++ b/configuration/settings.ini @@ -63,6 +63,9 @@ cert = ./configuration/server.crt [network] host = 0.0.0.0 port = 5000 +ngrok = 0 +ngrok_token = +ngrok_url_file = ngrok_url.txt [bruteforce] top10k = ./static/files/wordlists/10-million-password-list-top-10000.txt diff --git a/requirements.txt b/requirements.txt index 58a6293..db00eb6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -32,6 +32,7 @@ git+https://gitlab.com/invuls/pentest-projects/pcf_tools/qmarkpg_fork Flask-Caching==1.10.1 secure==0.3.0 markdownify==0.10.1 +pyngrok==5.1.0 #tools python-libnmap==0.7.2 diff --git a/requirements_unix.txt b/requirements_unix.txt index 6ef11dd..aca397c 100644 --- a/requirements_unix.txt +++ b/requirements_unix.txt @@ -25,6 +25,7 @@ git+https://gitlab.com/invuls/pentest-projects/pcf_tools/qmarkpg_fork Flask-Caching==1.10.1 secure==0.3.0 markdownify==0.10.1 +pyngrok==5.1.0 #tools python-libnmap==0.7.2 diff --git a/requirements_windows.txt b/requirements_windows.txt index f7c6f5e..effa852 100644 --- a/requirements_windows.txt +++ b/requirements_windows.txt @@ -23,6 +23,7 @@ qmarkpg==0.2 Flask-Caching==1.10.1 secure==0.3.0 markdownify==0.10.1 +pyngrok==5.1.0 #tools python-libnmap==0.7.2