Set a custom user-agent to hopefully help with uploading.

Signed-off-by: Jeroen Oudshoorn <oudshoorn.jeroen@gmail.com>
This commit is contained in:
Jeroen Oudshoorn
2025-01-01 14:54:26 +01:00
parent b13243466b
commit fc0c72f7df
2 changed files with 11 additions and 7 deletions

View File

@ -86,10 +86,11 @@ def _send_to_wigle(lines, api_key, donate=True, timeout=30):
dummy.seek(0) dummy.seek(0)
headers = {'Authorization': f"Basic {api_key}", headers = {"Authorization": f"Basic {api_key}",
'Accept': 'application/json'} "Accept": "application/json",
data = {'donate': 'on' if donate else 'false'} "HTTP_USER_AGENT": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:15.0) Gecko/20100101 Firefox/15.0.1"}
payload = {'file': (pwnagotchi.name() + ".csv", dummy, 'multipart/form-data', {'Expires': '0'})} data = {"donate": "on" if donate else "false"}
payload = {"file": (pwnagotchi.name() + ".csv", dummy, "multipart/form-data", {"Expires": "0"})}
try: try:
res = requests.post('https://api.wigle.net/api/v2/file/upload', res = requests.post('https://api.wigle.net/api/v2/file/upload',
data=data, data=data,

View File

@ -35,12 +35,15 @@ class WpaSec(plugins.Plugin):
Uploads the file to https://wpa-sec.stanev.org, or another endpoint. 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': self.options['api_key']} cookie = {"key": self.options['api_key']}
payload = {'file': file_to_upload} 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: try:
result = requests.post(self.options['api_url'], result = requests.post(self.options['api_url'],
cookies=cookie, cookies=cookie,
files=payload, files=payload,
headers=headers,
timeout=timeout) timeout=timeout)
if result.status_code == 200: if result.status_code == 200:
if ' already submitted' in result.text: if ' already submitted' in result.text:
@ -97,7 +100,7 @@ class WpaSec(plugins.Plugin):
def on_internet_available(self, agent): 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(): if not self.ready or self.lock.locked():
return return