From a7ea499fac82731ef3f28556f689a6799247160a Mon Sep 17 00:00:00 2001 From: dadav <33197631+dadav@users.noreply.github.com> Date: Mon, 25 Nov 2019 19:47:23 +0100 Subject: [PATCH 1/2] Should fail before write --- pwnagotchi/plugins/default/webcfg.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pwnagotchi/plugins/default/webcfg.py b/pwnagotchi/plugins/default/webcfg.py index 52532f2..0570833 100644 --- a/pwnagotchi/plugins/default/webcfg.py +++ b/pwnagotchi/plugins/default/webcfg.py @@ -500,8 +500,9 @@ class WebConfig(plugins.Plugin): elif request.method == "POST": if path == "save-config": try: + parsed_yaml = yaml.safe_load(request.get_json()) with open('/etc/pwnagotchi/config.yml', 'w') as config_file: - yaml.safe_dump(request.get_json(), config_file, encoding='utf-8', + yaml.safe_dump(parsed_yaml, config_file, encoding='utf-8', allow_unicode=True, default_flow_style=False) _thread.start_new_thread(restart, (self.mode,)) From a03443986bc3047681bd0955560ba9bcf8cfec26 Mon Sep 17 00:00:00 2001 From: dadav <33197631+dadav@users.noreply.github.com> Date: Mon, 25 Nov 2019 20:08:20 +0100 Subject: [PATCH 2/2] Parse to str --- pwnagotchi/plugins/default/webcfg.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pwnagotchi/plugins/default/webcfg.py b/pwnagotchi/plugins/default/webcfg.py index 0570833..40f7477 100644 --- a/pwnagotchi/plugins/default/webcfg.py +++ b/pwnagotchi/plugins/default/webcfg.py @@ -500,7 +500,7 @@ class WebConfig(plugins.Plugin): elif request.method == "POST": if path == "save-config": try: - parsed_yaml = yaml.safe_load(request.get_json()) + parsed_yaml = yaml.safe_load(str(request.get_json())) with open('/etc/pwnagotchi/config.yml', 'w') as config_file: yaml.safe_dump(parsed_yaml, config_file, encoding='utf-8', allow_unicode=True, default_flow_style=False)