http页面解析之httpacp开源软件

来源:互联网 发布:管理客户资料的软件 编辑:程序博客网 时间:2024/06/07 00:40

之前的nDPI项目里为了分析HTTP协议浪费了很长时间,自己编写函数解析gzip、chunked等传输格式,着实浪费了很长时间,而且解析的效果并不好。前几天看到了一个Python的开源软件httpcap,效果很好,在这里记录一下。
首先安装十分简单,使用命令pip install httpcap即可安装成功。
和NDPI很类似,他也可以直接从网卡抓取数据包或者直接处理已经得到的.pcap网络数据包。

# Use tcpdump to capture packets:tcpdump -wtest.pcap tcp port 80# only output the requested URL and response statusparse-pcap test.pcap# or use pipesudo tcpdump -w- tcp port 80 | parse-pcap# parse-live need to be root. capture network device en1# on linux/osx ifconfig to see all network devicessudo parse-live en1# capture traffics on all devicessudo parse-live

可以输入不同参数选择要显示的信息。

# output http req/resp headersparse-pcap -v test.pcap# output http req/resp headers and body which belong to text typeparse-pcap -vv test.pcap# output http req/resp headers and bodyparse-pcap -vvv test.pcap# display and attempt to do url decoding and formatting json outputparse-pcap -vvb test.pcap

测试效果不错,比之前自己写的HTTP解析文件效果好多了,仔细看了一下源代码,感觉思路很清晰,也比较容易理解。时间比较紧,先写到这里,之后再把使用过程中学到的东西补上。

0 0
原创粉丝点击