Sending a file via POST using raw HTTP (Putty)

↘锁芯ラ 提交于 2019-11-28 19:53:37

You have to use multipart content-type and encode the file data into hex/binary

Try the following in telnet:

POST /the_url HTTP/1.1
User-Agent: Mozilla
Host: www.example.com
Content-Length: xxxx
Content-Type: multipart/form-data; boundary=--------------------31063722920652
------------------------------31063722920652
Content-Disposition: form-data; name="a"

value_for_a
------------------------------31063722920652
Content-Disposition: form-data; name="b"

value_for_b
------------------------------31063722920652
Content-Disposition: form-data; name="c"; filename="myfile.txt"
Content-Type: text/plain

            This is a test 
            and more

-----------------------------31063722920652
Content-Disposition: form-data; name="submit"

Submit
-----------------------------31063722920652--

Remember that an extra newline is necessary between field name and its data. Also, update the Content-Length value.

Open a port with netcat and save the incoming request:

nc -l -p 1090 > income-http.txt

Then modify your form to send the data to the netcat:

<form action="http://localhost:1090/upload_file.php" 
    method="post" enctype="multipart/form-data">

Submit the form from your browser. You can find the full raw request with the contents of the file in the income-http.txt file.

Saving the income-http.txt is an one-time activity. Later you can send the saved request out any times. Please note that you should edit the Host: header in the saved txt.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!