• 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字段填错了,不知道该怎么填,谁帮我一下?

  • 相关阅读:
    jQuery-选择器及属性修改
    jQuery 基础理论
    CSS 之 BFC(块级格式化上下文)
    H5--Web Storage
    H5 -WebWorker
    H5 --拖放
    nodejs Multer中间件
    k8s pod
    kubernetes
    优化CUDA数据传输
  • 原文地址:https://www.cnblogs.com/boluoboluo/p/6439237.html
Copyright © 2020-2023  润新知