From 434e38db64d1eda18150fd8b96648fbf6e8a40a7 Mon Sep 17 00:00:00 2001 From: mh4x0f Date: Mon, 15 Jun 2020 20:52:29 -0300 Subject: [PATCH] added option on captiveflask to force redirect sucessful template --- CHANGELOG.md | 1 + bin/captiveflask | 27 +++++++++++++++++-- config/app/captive-portal.ini | 3 +++ .../core/servers/proxy/captiveflask.py | 9 +++++++ wifipumpkin3/extensions/info.py | 20 +++++++++++++- 5 files changed, 57 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e8328dc..1dafffa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ All notable changes to this project will be documented in this file. - added many improvements into system modules - added improves module for running in background - added command kill: terminate a module in background by id +- added option on captiveflask to force redirect sucessful template ### Changed - moved command info to extensions directory diff --git a/bin/captiveflask b/bin/captiveflask index 6dc9b48..7c18232 100644 --- a/bin/captiveflask +++ b/bin/captiveflask @@ -34,9 +34,12 @@ def login(): } ) ) + global FORCE_REDIRECT sys.stdout.flush() login_user(request.remote_addr) - if "orig_url" in request.args and len(request.args["orig_url"]) > 0: + if FORCE_REDIRECT: + return render_template("templates/login_successful.html") + elif "orig_url" in request.args and len(request.args["orig_url"]) > 0: return redirect(unquote(request.args["orig_url"])) else: return render_template("templates/login_successful.html") @@ -61,7 +64,18 @@ def catch_all(path): ) -_version = "1.0.1" +#https://stackoverflow.com/questions/15008758/parsing-boolean-values-with-argparse +def str2bool(v): + if isinstance(v, bool): + return v + if v.lower() in ('yes', 'true', 't', 'y', '1'): + return True + elif v.lower() in ('no', 'false', 'f', 'n', '0'): + return False + else: + raise argparse.ArgumentTypeError('Boolean value expected.') + +_version = "1.0.2" if __name__ == "__main__": print("[*] CaptiveFlask v{} - subtool from wifipumpkin3".format(_version)) @@ -81,9 +95,18 @@ if __name__ == "__main__": dest="redirect", help="IpAddress from gataway captive portal", ) + parser.add_argument( + "-f", + "--force-login_successful-template", + dest="force_redirect", + default=False, + type=str2bool, + help="force redirect to login_successful.html template", + ) parser.add_argument("-v", "--version", dest="version", help="show version the tool") args = parser.parse_args() REDIRECT = args.redirect + FORCE_REDIRECT = args.force_redirect app.static_url_path = "\{}".format(args.static) app.static_folder = "{}".format(args.static) diff --git a/config/app/captive-portal.ini b/config/app/captive-portal.ini index c83863f..1cac16f 100644 --- a/config/app/captive-portal.ini +++ b/config/app/captive-portal.ini @@ -8,3 +8,6 @@ DarkLogin=true Default=true En=false ptBr=false + +[settings] +force_redirect_sucessful_template=false diff --git a/wifipumpkin3/core/servers/proxy/captiveflask.py b/wifipumpkin3/core/servers/proxy/captiveflask.py index 859ce7c..2e69d70 100644 --- a/wifipumpkin3/core/servers/proxy/captiveflask.py +++ b/wifipumpkin3/core/servers/proxy/captiveflask.py @@ -84,6 +84,8 @@ class CaptivePortal(ProxyMode): self.conf.get("dhcp", "router"), "-s", self.tamplate.StaticPath, + "-f", + self.config.get("settings", "force_redirect_sucessful_template"), ] return self._cmd_array @@ -131,6 +133,11 @@ class CaptivePortal(ProxyMode): list_commands.append(self.ID + "." + command) for sub_plugin in self.config.get_all_childname("set_{}".format(command)): list_commands.append("{}.{}.{}".format(self.ID, command, sub_plugin)) + # load all settings extra plugin + settings = self.config.get_all_childname("settings") + for config in settings: + list_commands.append("{}.{}".format(self.ID, config)) + return list_commands def LogOutput(self, data): @@ -166,6 +173,8 @@ class CaptivePortal(ProxyMode): ) if key_plugin in self.config.get_all_childname("plugins"): self.setPluginActivated(key_plugin, status) + elif key_plugin in self.config.get_all_childname("settings"): + self.config.set("settings", key_plugin, status) else: print( display_messages( diff --git a/wifipumpkin3/extensions/info.py b/wifipumpkin3/extensions/info.py index 3b03794..ebd4ca3 100644 --- a/wifipumpkin3/extensions/info.py +++ b/wifipumpkin3/extensions/info.py @@ -104,7 +104,25 @@ class Info(ExtensionUI): ) if output_table != []: print(display_messages("Plugins:", info=True, sublime=True)) - return display_tabulate(headers_table, output_table) + display_tabulate(headers_table, output_table) + + settings = proxies["Config"].get_all_childname("settings") + if not settings: + return + headers_settings, output_settings = ["Setting", "Value"], [] + # search extra settings plugin + + for command in settings: + output_settings.append( + [ + setcolor("{}".format(command), color="blue",), + proxies["Config"].get("settings", command), + ] + ) + if output_settings != []: + print(display_messages("Settings:", info=True, sublime=True)) + return display_tabulate(headers_settings, output_settings) + except AttributeError: pass