溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

HTTP數據包結構

發布時間:2020-05-27 20:07:45 來源:網絡 閱讀:2230 作者:arckyli 欄目:編程語言

以以下利用一段代碼讀取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/


向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女