Nc simulates browser request http
The 6.5.1 Detection of non-Standard Ports in the complete beginner's Guide to Penetration testing uses nc to manually send http commands to obtain the contents of web. It is possible to execute successfully according to this example, but not to apache to initiate a request according to the method of this example. As follows:
Nc 172.28.128.35 80GET / HTTP/1.1HTTP/1.1 400 Bad RequestDate: Fri, 27 Dec 2019 03:08:49 GMTServer: Apache/2.4.6 (CentOS) Content-Length: 226Connection: closeContent-Type: text/html; charset=iso-8859-1400 Bad RequestBad Request
Your browser sent a request that this server could not understand.
According to the reference link, you need to use the following command to request success
Printf "GET / HTTP/1.1\ r\ nHOST:z\ r\ n\ r\ n\ n" | nc 172.28.128.35 80HTTP/1.1 200 OKDate: Fri, 27 Dec 2019 03:21:21 GMTServer: Apache/2.4.6 (CentOS) Last-Modified: Fri, 27 Dec 2019 02:59:06 GMTETag: "8-59aa6ad5747ae" Accept-Ranges: bytesContent-Length: 8Content-Type: text/html; charset=UTF-8dfafdas
Refer to the documentation in the link to explain why such a command is needed.
You can also redirect to nc by saving the http command in a text file. From the print command, each line ends with\ r\ n, so the saved text document needs to be in windows format.
Create the file cat b.txt GET / HTTP/1.1Host: 172.28.128.34Accept: * / * convert to windows format unix2dos b.txtfile b.txt b.txt: ASCII text, with CRLF line terminators execute ncnc 172.28.128.3580 < b.txt HTTP/1.1 200OKDate: Fri, 27 Dec 2019 03:28:08 GMTServer: Apache/2.4.6 (CentOS) Last-Modified: Fri 27 Dec 2019 02:59:06 GMTETag: "8-59aa6ad5747ae" Accept-Ranges: bytesContent-Length: 8Content-Type: text/html Charset=UTF-8dfafdas reference link:
Https://osric.com/chris/accidental-developer/2018/01/using-nc-netcat-to-make-an-http-request/