Reputation: 617
I am trying to upload data to a webserver using curl. I have analyzed the data sent to the server, from a browser, using wireshark, shown below:
POST /cgi-bin/upload.cgi HTTP/1.1
Host: 192.168.1.22
Connection: keep-alive
Content-Length: 2637
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Origin: http://192.168.1.22
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/30.0.1599.101 Safari/537.36
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryn1sckmiVOVfCwUMQ
Referer: http://192.168.1.22/upload.html
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
I looked at the webpage the browser accesses to upload the information, shown below:
<form method="POST" enctype="multipart/form-data" action="http://192.168.1.22/cgi-bin/upload.cgi">
File to upload:
<input type="file" name="theupload"><br>
Should it be updated?<input type="checkbox" name="configuration"><br>
<input type="submit" value="Press"> to upload the file!
</form>
I attempted to use:
curl --referer http://192.168.1.22/upload.html -F [email protected] -F config=on http://192.168.1.22:80/cgi-bin/upload.cgi
My output was
POST /cgi-bin/upload.cgi HTTP/1.1
User-Agent: curl/7.33.0
Host: 192.168.1.22
Accept: */*
Referer: http://192.168.1.22/upload.html
Content-Length: 2650
Expect: 100-continue
Content-Type: multipart/form-data; boundary=------------------------fd126312049d1f47
The server returns HTTP/1.1 417 Expectation Failed. I am just learning curl, and I am unsure of what to do. Do i need to emulate the header of the browser command as closely as possible? or is the boundary what is probably throwing it off? Thanks for you help.
Upvotes: 0
Views: 331