HTTP数据包结构

发布时间:2020-05-27 20:07:45 作者:arckyli
来源:网络 阅读:2187

以以下利用一段代码读取http数据包里的request内容:

#!/usr/bin/env python 

import scapy_http.http as http
from scapy.all import * 

def process_tcp_packet(packet):
    if  not packet.haslayer(http.HTTPRequest):
        return
    http_layer = packet.getlayer(http.HTTPRequest)
    print http_layer.show()
    ip_layer = packet.getlayer(IP)
    print '\n{0[src]} just requested a {1[Method]} {1[Host]}{1[Path]}'.format(ip_layer.fields, http_layer.fields)
sniff(filter='tcp and port 80',prn=process_tcp_packet)

运行结果如下:

###[ HTTP Request ]### 

  Method    = 'GET'

  Path      = '/'

  Http-Version= 'HTTP/1.1'

  Host      = '192.168.32.142'

  User-Agent= 'curl/7.60.0'

  Accept    = '*/*'

  Accept-Language= None

  Accept-Encoding= None

  Accept-Charset= None

  Referer   = None

  Authorization= None

  Expect    = None

  From      = None

  If-Match  = None

  If-Modified-Since= None

  If-None-Match= None

  If-Range  = None

  If-Unmodified-Since= None

  Max-Forwards= None

  Proxy-Authorization= None

  Range     = None

  TE        = None

  Cache-Control= None

  Connection= None

  Date      = None

  Pragma    = None

  Trailer   = None

  Transfer-Encoding= None

  Upgrade   = None

  Via       = None

  Warning   = None

  Keep-Alive= None

  Allow     = None

  Content-Encoding= None

  Content-Language= None

  Content-Length= None

  Content-Location= None

  Content-MD5= None

  Content-Range= None

  Content-Type= None

  Expires   = None

  Last-Modified= None

  Cookie    = None

  Headers   = 'Host: 192.168.32.142\r\nAccept: */*\r\nUser-Agent: curl/7.60.0'

  Additional-Headers= None


192.168.32.10 just requested a GET 192.168.32.142/


推荐阅读:
  1. 8.1.7 OSPF数据包格式
  2. Charles抓取HTTPS数据包方法

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

http 包结构

上一篇:你们是不是对QQ总在后台莫名其妙更新一些东西很反感

下一篇:php文件上传到远程ftp服务器代码封装

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》