From 31472c8a7bc7b8d24c659d5b6d4321b658da7aaa Mon Sep 17 00:00:00 2001 From: XtramCZ Date: Fri, 30 Jun 2023 23:19:07 +0200 Subject: [PATCH 1/4] fixed crashes on one-line scripts, auto .dd --- webapp.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/webapp.py b/webapp.py index a87c78a..10bc8c9 100644 --- a/webapp.py +++ b/webapp.py @@ -193,12 +193,14 @@ def write_new_script(request): form_data[key] = value #print(form_data) filename = form_data['scriptName'] + if ".dd" not in filename: + filename = filename + ".dd" textbuffer = form_data['scriptData'] textbuffer = cleanup_text(textbuffer) storage.remount("/",readonly=False) f = open(filename,"w",encoding='utf-8') - for line in textbuffer: - f.write(line) + for line in textbuffer.splitlines(): + f.write(line + '\n') f.close() storage.remount("/",readonly=True) response = response_html.format("Wrote script " + filename) From 40bc2022787d0593753ba8a26506d77533266c72 Mon Sep 17 00:00:00 2001 From: XtramCZ Date: Fri, 30 Jun 2023 23:30:10 +0200 Subject: [PATCH 2/4] Delete button --- webapp.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/webapp.py b/webapp.py index 10bc8c9..f579647 100644 --- a/webapp.py +++ b/webapp.py @@ -73,7 +73,7 @@ """ -newrow_html = "{}Edit / Run" +newrow_html = "{}Edit / Delete / Run" def setPayload(payload_number): if(payload_number == 1): @@ -94,7 +94,7 @@ def ducky_main(request): for f in files: if ('.dd' in f) == True: payloads.append(f) - newrow = newrow_html.format(f,f,f) + newrow = newrow_html.format(f,f,f,f) #print(newrow) rows = rows + newrow @@ -206,6 +206,14 @@ def write_new_script(request): response = response_html.format("Wrote script " + filename) return("200 OK",[('Content-Type', 'text/html')], response) +@web_app.route("/delete/") +def delete(request, filename): + print("Deleting ", filename) + os.remove(filename) + response = response_html.format("Deleted script " + filename) + + return("200 OK",[('Content-Type', 'text/html')], response) + @web_app.route("/run/") def run_script(request, filename): print("run_script ", filename) From 8fa47cad000f77f1d6380dcd5033c31f34b5ce49 Mon Sep 17 00:00:00 2001 From: XtramCZ Date: Fri, 30 Jun 2023 23:44:21 +0200 Subject: [PATCH 3/4] Additional crash fix --- webapp.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webapp.py b/webapp.py index f579647..fe61317 100644 --- a/webapp.py +++ b/webapp.py @@ -172,8 +172,8 @@ def write_script(request, filename): textbuffer = form_data['scriptData'] textbuffer = cleanup_text(textbuffer) #print(textbuffer) - for line in textbuffer: - f.write(line) + for line in textbuffer.splitlines(): + f.write(line + '\n') f.close() storage.remount("/",readonly=True) response = response_html.format("Wrote script " + filename) From f429dbfb5c471cad6e86b68c24b3a9261506ab36 Mon Sep 17 00:00:00 2001 From: XtramCZ Date: Fri, 30 Jun 2023 23:50:48 +0200 Subject: [PATCH 4/4] Disable read-only --- webapp.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/webapp.py b/webapp.py index fe61317..c24aec4 100644 --- a/webapp.py +++ b/webapp.py @@ -209,9 +209,10 @@ def write_new_script(request): @web_app.route("/delete/") def delete(request, filename): print("Deleting ", filename) + storage.remount("/",readonly=False) os.remove(filename) response = response_html.format("Deleted script " + filename) - + storage.remount("/",readonly=True) return("200 OK",[('Content-Type', 'text/html')], response) @web_app.route("/run/")