The method of nc simulating browser to request http
NC6 is a new series of NC products and a world-class high-end management software for group enterprises. at present, based on the strength of 8000 group enterprise customers, NC has reached the first market share of similar products in the Asia-Pacific region. Facing the information needs of large enterprise groups and growing group enterprises, Yuyou NC6's products are located in large-scale enterprise management and e-commerce platform.
"6.5.1 detect non-standard ports" 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