0

I'm trying to submit a file (test.exe) to a website using a POST request, but instead of a normal 302 response, it keeps responding with 500. I don't know what I could change in my request: maybe in the headers or in the files format, or maybe I need to somehow pass the data parameter?

I would appreciate any advice on this!

import requests


url = "https://cuckoo.cert.ee/submit/api/presubmit"
files = {"test.exe": open("test.exe", "rb")}
headers = {
    "Accept": "*/*",
    "Accept-Encoding": "gzip, deflate, br",
    "Accept-Language": "en-US,en;q=0.9",
    "Connection": "keep-alive",
    "Content-Length": "199",
    "Content-Type": "multipart/form-data; boundary=----WebKitFormBoundarymoUA16cLBrh9JNGC",
    "Cookie": "csrftoken=O9tFpNhZuZrj7DsEnBAcj0wmV00z8qE3; theme=cyborg; csrftoken=O9tFpNhZuZrj7DsEnBAcj0wmV00z8qE3",
    "Host": "cuckoo.cert.ee",
    "Origin": "https://cuckoo.cert.ee",
    "Referer": "https://cuckoo.cert.ee/submit/",
    "sec-ch-ua-mobile": "?0",
    "sec-ch-ua-platform": "Windows",
    "Sec-Fetch-Dest": "empty",
    "Sec-Fetch-Mode": "cors",
    "Sec-Fetch-Site": "same-origin",
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36",
    "X-CSRFToken": "O9tFpNhZuZrj7DsEnBAcj0wmV00z8qE3"
}

response = requests.post(url, headers=headers, files=files, verify=False)
print(response)

  • 500 is an [internal server error](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#5xx_server_errors). Check the server's logs for details. – Robert Aug 25 '22 at 15:10

1 Answers1

0

Possibly try changing content type to application/octet-stream. 500 Error indicates that the website may not be able to handle the file that you are trying to upload. It could simply be that the website is malfunctioning or having a temporary failure. If you have access to the back-end logs, I would recommend looking at that, or contacting the website to see if they have any suggestions.

EDIT: Verify that your content matches the length that you are declaring as well, it looks like you have a content-length parameter declared in your request. Try taking that out to see if that helps.

zack
  • 146
  • 1
  • 6
  • Thank you for the suggestion! Unfortunately, the problem must be something else. I checked the correctness of the file length, and then tried to remove it as well, but neither of these worked. Changing the content type also didn't change the response. I also cannot access or contact the back-end side of the website, so I'm only left to work with my requests. – HollidayHolly Aug 25 '22 at 13:20
  • Sorry that I wasn't able to help! I would check to make sure that the service actually works outside of the script. I usually use something like Postman, which allows for testing API calls – zack Aug 25 '22 at 15:53