Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inserted a parse for headers (header_to_json) #82

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions API/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
Expand All @@ -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"
Expand All @@ -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)

Expand Down Expand Up @@ -282,4 +293,4 @@ def main():
def robots():
return send_from_directory(app.static_folder, "robots.txt")

main()
main()