Update wpa-sec.py

Part 2 of closing https://github.com/evilsocket/pwnagotchi/issues/347.
This commit is contained in:
friedphish 2019-10-21 09:53:32 +02:00 committed by GitHub
parent 020be7185c
commit 4a2091e688
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -25,19 +25,23 @@ def on_loaded():
logging.error("WPA_SEC: API-KEY isn't set. Can't upload to wpa-sec.stanev.org") logging.error("WPA_SEC: API-KEY isn't set. Can't upload to wpa-sec.stanev.org")
return return
if 'api_url' not in OPTIONS or ('api_url' in OPTIONS and OPTIONS['api_url'] is None):
logging.error("WPA_SEC: API-URL isn't set. Can't upload, no endpoint configured.")
return
READY = True READY = True
def _upload_to_wpasec(path, timeout=30): def _upload_to_wpasec(path, timeout=30):
""" """
Uploads the file to wpa-sec.stanev.org Uploads the file to https://wpa-sec.stanev.org, or another endpoint.
""" """
with open(path, 'rb') as file_to_upload: with open(path, 'rb') as file_to_upload:
cookie = {'key': OPTIONS['api_key']} cookie = {'key': OPTIONS['api_key']}
payload = {'file': file_to_upload} payload = {'file': file_to_upload}
try: try:
result = requests.post('https://wpa-sec.stanev.org', result = requests.post(OPTIONS['api_url'],
cookies=cookie, cookies=cookie,
files=payload, files=payload,
timeout=timeout) timeout=timeout)