From fe911fe7587bd2adae405d2531da1b1285551e3a Mon Sep 17 00:00:00 2001 From: VitorDominguesR <18357011+VitorDominguesR@users.noreply.github.com> Date: Thu, 6 Dec 2018 09:48:48 -0200 Subject: [PATCH] Inserted a parse for headers (header_to_json) You can paste the headers directly --- API/api.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/API/api.py b/API/api.py index 592e2d1..160af36 100644 --- a/API/api.py +++ b/API/api.py @@ -72,6 +72,17 @@ def xss_filter(data): pass return filterd_data +# parser headers +def headers_to_json(header_text): + to_json = {} + try: + for line in header_text.strip().split("\n"): + print(line) + to_json[line.split(":")[0]] = ":".join(line.split(":")[1:]) if len(line.split(":")) > 2 else line.split(":")[1] + + return json.dumps(to_json) + except: + return header_text # Start the scan and returns the message @app.route('/scan/', methods = ['POST']) @@ -81,7 +92,7 @@ def start_scan(): try: name = content['appname'] url = str(content['url']) - headers = str(content['headers']) + headers = headers_to_json(str(content['headers'])) body = str(content['body']) method = content['method'] api = "Y" @@ -94,10 +105,10 @@ def start_scan(): except: print "Failed to update DB" else: - msg = {"status" : "Failed"} - - except: - msg = {"status" : "Failed"} + msg = {"status" : "Failed aaaa"} + + except Exception as e: + msg = {"status" : "Failed"} return jsonify(msg) @@ -282,4 +293,4 @@ def main(): def robots(): return send_from_directory(app.static_folder, "robots.txt") -main() \ No newline at end of file +main()