Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send a POST request through telnet

I want to know how to send a POST request to a server (e.g. Google Search). I already know how to send a GET request,

For example:

GET http://www.google.com/

I tried doing it like this:

POST /wikipedia

or

POST wikipedia

or

POST
/wikipedia

or

POST Search: wikipedia

Anyone know how to send a POST request through telnet/cmd/batch?

like image 554
Justin F. Avatar asked Dec 14 '16 16:12

Justin F.


2 Answers

Of course you can, don't listen to npocmaka! Telnet just opens a TCP connection to a port in a server and does nothing else. So, if you send the right commands (in this case HTTP request commands) the server will respond OK.

An example of what you have to write is:

POST /path/script.cgi HTTP/1.0
From: [email protected]
User-Agent: HTTPTool/1.0
Content-Type: application/x-www-form-urlencoded
Content-Length: 32

home=Cosby&favorite+flavor=flies
<PRESS ENTER KEY>

I think that you have to end with a new line for the command to get send.

like image 93
Matias Avatar answered Sep 20 '22 20:09

Matias


telnet httpbin.org 80

POST /post HTTP/1.1
Host: httpbin.org
Connection: close
Content-type: application/json
Content-length: 11

{"test":true}
like image 31
xitong Avatar answered Sep 17 '22 20:09

xitong