linux下nc提交web報文問題


1、用wireshark截取訪問百度首頁拿到的請求數據包:

GET /index.php?tn=newbdie_bd_dg&bar=1012 HTTP/1.1
Host: www.baidu.com
Connection: keep-alive
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.43 BIDUBrowser/6.x Safari/537.31
Accept-Encoding: gzip,deflate
Accept-Language: zh-CN,zh;q=0.8
Accept-Charset: iso-8859-1,*,utf-8
Cookie: (自己的cookie)

2、新建test.txt添加以上內容,補兩個回車。保存到已知目錄/lj

3、在終端下輸入nc -v www.baidu.com 80 </lj/test.txt

     回車。如下:

mylinux@ubuntu:~$ nc -v www.baidu.com 80 </lj/test.txt
Warning: inverse host lookup failed for 14.215.177.37: Unknown host
Warning: inverse host lookup failed for 14.215.177.38: Unknown host
www.a.shifen.com [14.215.177.37] 80 (http) open
HTTP/1.1 302 Moved Temporarily
Date: Fri, 24 Feb 2017 08:26:08 GMT
Content-Type: text/html
Content-Length: 215
Connection: Keep-Alive
Set-Cookie: BDRCVFR[jRGLbB9A7k_]=aeXf-1x8UdYcs; path=/; domain=.baidu.com
Set-Cookie: BD_LAST_QID=9863113372713615470; path=/; Max-Age=1
P3P: CP=" OTI DSP COR IVA OUR IND COM "
Location: https://www.baidu.com/index.php?tn=newbdie_bd_dg&bar=1012&dsp=baidubrowser
Server: BWS/1.1
X-UA-Compatible: IE=Edge,chrome=1

<html>
<head><title>302 Found</title></head>
<body bgcolor="white">
<center><h1>302 Found</h1></center>
<hr><center>pr-nginx_1-0-329_BRANCH Branch
Time : Thu Feb 16 11:05:49 CST 2017</center>
</body>
</html>

host沒找到,重定向百度最近的域名服務器了吧?

 

我的問題如下:!!!

我從虛擬機下提交報文到主機搭建的apache服務器,一直提示 Host name lookup failure 不知道是什么原因(虛擬機下firefox能正常訪問主機apache的test.php)

1、報文仿照上面百度請求報文(修改了請求地址和Host字段):

GET /test.php HTTP/1.1
Host: 192.168.1.105
Connection: keep-alive
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.43 BIDUBrowser/6.x Safari/537.31
Accept-Encoding: gzip,deflate
Accept-Language: zh-CN,zh;q=0.8
Accept-Charset: iso-8859-1,*,utf-8
Cookie: (自己的cookie)

2、linux下顯示如下:

mylinux@ubuntu:~$ nc -v http://192.168.1.105 80 </lj/test.txt
http://192.168.1.105: forward host lookup failed: Host name lookup failure : Resource temporarily unavailable
mylinux@ubuntu:~$ 

應該是Host字段填錯了,不知道該怎么填,誰幫我一下?

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM