您可以使用 Scapy 轻松读取 pcap,rdpcap然后您可以使用Raw数据包的(TCP 正上方)层来处理 HTTP 内容:
from scapy.all import *
pcap = rdpcap("my_file.pcap")
for pkt in pcap:
if Raw in pkt:
print pkt[Raw]
Run Code Online (Sandbox Code Playgroud)
如果其他用户可能有类似的问题:我最终使用以下脚本:
infile=infile.pcap
outfile=outfile
ext=txt
rm -f ${outfile}_all.${ext}
for stream in $(tshark -nlr $infile -Y tcp.flags.syn==1 -T fields -e tcp.stream | sort -n | uniq | sed 's/\r//')
do
echo "Processing stream $stream: ${outfile}_${stream}.${ext}"
tshark -nlr $infile -qz "follow,tcp,raw,$stream" | tail -n +7 | sed 's/^\s\+//g' | xxd -r -p | tee ${outfile}_${stream}.${ext} >> ${outfile}_all.${ext}
done
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5728 次 |
| 最近记录: |