我如何删除头文件,只得到加密的部分。

问题描述 投票:0回答:1
pcap = rdpcap(".pcap file")

for pkt in pcap:
    if Raw in pkt:
        f=pkt[Raw]
        print f

上述代码给出的输出结果如下图所示。

HTTP/1.1 200 OK
Cache-Control: private, max-age=0
Content-Type: text/html; charset=utf-8
P3P: CP="NON UNI COM NAV STA LOC CURa DEVa PSAa PSDa OUR IND"
Vary: Accept-Encoding
Content-Encoding: gzip
Date: Sat, 30 Mar 2013 19:23:33 GMT
Content-Length: 15534
Accept-Encoding: gzip, deflate

?}k{?H????+0?#!?,_???$?:?7vf?w?Hb???ƊG???9???/9U?\$;3{9g?ycAӗ???????W{?o?~?FZ?e ]>??<??n????׻?????????d?t??a?3?
?2?p??eBI?e??????ܒ?P??-?Q?-L?????ǼR?³?ׯ??%'
?2Kf?7???c?Y?I?1+c??,ae]?????<{?=ƞ,?^?J?ď???y??6O?_?z????_?ޞ~?_?????Bo%]???_?????W=?

我怎样才能去掉头,使输出是公正的。

?}k{?H????+0?#!?,_???$?:?7vf?w?Hb???ƊG???9???/9U?\$;3{9g?ycAӗ???????W{?o?~?FZ?e ]>??<??n????׻?????????d?t??a?3?
?2?p??eBI?e??????ܒ?P??-?Q?-L?????ǼR?³?ׯ??%'
?2Kf?7???c?Y?I?1+c??,ae]?????<{?=ƞ,?^?J?ď???y??6O?_?z????_?ޞ~?_?????Bo%]???_?????W=?
python scapy packet payload
1个回答
0
投票
  1. 确保你使用的是Scapy 2.4.3。
  2. 在读取pcap之前加载http层。from scapy.layers.http import *
  3. 读取pcap
  4. 你会得到你想要的原始图层的输出。

注意:您可以使用以下方法关闭自动解压功能

conf.contribs["http"]["auto_compression"] = True

此外,还可以自动匹配碎片块(这里不用)。参见 sniff 与 "TCPSession "在 https:/scapy.readthedocs.ioenlatestlayershttp.html。

© www.soinside.com 2019 - 2024. All rights reserved.