added option on captiveflask to force redirect sucessful template

This commit is contained in:
mh4x0f 2020-06-15 20:52:29 -03:00
parent 342261d1ae
commit 434e38db64
5 changed files with 57 additions and 3 deletions

View File

@ -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

View File

@ -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)

View File

@ -8,3 +8,6 @@ DarkLogin=true
Default=true
En=false
ptBr=false
[settings]
force_redirect_sucessful_template=false

View File

@ -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(

View File

@ -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