From fc0c72f7df765c9cca6ac3333affcda952389653 Mon Sep 17 00:00:00 2001 From: Jeroen Oudshoorn Date: Wed, 1 Jan 2025 14:54:26 +0100 Subject: [PATCH] Set a custom user-agent to hopefully help with uploading. Signed-off-by: Jeroen Oudshoorn --- pwnagotchi/plugins/default/wigle.py | 9 +++++---- pwnagotchi/plugins/default/wpa-sec.py | 9 ++++++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/pwnagotchi/plugins/default/wigle.py b/pwnagotchi/plugins/default/wigle.py index 353660ea..3f387795 100644 --- a/pwnagotchi/plugins/default/wigle.py +++ b/pwnagotchi/plugins/default/wigle.py @@ -86,10 +86,11 @@ def _send_to_wigle(lines, api_key, donate=True, timeout=30): dummy.seek(0) - headers = {'Authorization': f"Basic {api_key}", - 'Accept': 'application/json'} - data = {'donate': 'on' if donate else 'false'} - payload = {'file': (pwnagotchi.name() + ".csv", dummy, 'multipart/form-data', {'Expires': '0'})} + headers = {"Authorization": f"Basic {api_key}", + "Accept": "application/json", + "HTTP_USER_AGENT": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:15.0) Gecko/20100101 Firefox/15.0.1"} + data = {"donate": "on" if donate else "false"} + payload = {"file": (pwnagotchi.name() + ".csv", dummy, "multipart/form-data", {"Expires": "0"})} try: res = requests.post('https://api.wigle.net/api/v2/file/upload', data=data, diff --git a/pwnagotchi/plugins/default/wpa-sec.py b/pwnagotchi/plugins/default/wpa-sec.py index 0d2f20c1..ff1a0fbd 100644 --- a/pwnagotchi/plugins/default/wpa-sec.py +++ b/pwnagotchi/plugins/default/wpa-sec.py @@ -35,12 +35,15 @@ class WpaSec(plugins.Plugin): Uploads the file to https://wpa-sec.stanev.org, or another endpoint. """ with open(path, 'rb') as file_to_upload: - cookie = {'key': self.options['api_key']} - payload = {'file': file_to_upload} + cookie = {"key": self.options['api_key']} + payload = {"file": file_to_upload, + "multipart/form-data": {"Expires": "0"}} + headers = {"HTTP_USER_AGENT": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:15.0) Gecko/20100101 Firefox/15.0.1"} try: result = requests.post(self.options['api_url'], cookies=cookie, files=payload, + headers=headers, timeout=timeout) if result.status_code == 200: if ' already submitted' in result.text: @@ -97,7 +100,7 @@ class WpaSec(plugins.Plugin): def on_internet_available(self, agent): """ - Called in manual mode when there's internet connectivity + Called when there's internet connectivity """ if not self.ready or self.lock.locked(): return