Linux命令行下抓取HTTP流量的工具--httpry
2019独角兽企业重金招聘Python工程师标准>>>
httpry是一个专业的封包嗅探器,用C语言开发的用来用于显示和记录HTTP流量。此工具不会进行自身分析,而是用来捕获、分析、并记录流量。
它可以作为一个后台进程记录实时流量并输出到文件,由于具有轻型和灵活的特性,所以它可以很容易适应不同的应用程序。它不显示原始HTTP传输的数据,而是着重解析和显示相关数据字段的请求和响应行。
应用场景
查看用户在你的网络上在线浏览的内容
检查是否正确的服务器配置
在HTTP中使用模式的研究
关注危险下载的文件
验证HTTP策略在网络上的实施
提取的HTTP统计输出保存在捕捉文件
项目地址: http://dumpsterventures.com/jason/httpry/
安装httpry
通过包安装
CentOS/RHEL
$ yum install epel-release #安装EPEL repo
$ yum install httpry
Debian/Ubuntu
$ apt-get install httpry httpry-tools httpry-daemon
编译安装
安装依赖包
CentOS/RHEL
$ yum install wget gcc make libpcap libpcap-devel
Debian/Ubuntu
$ apt-get install wget gcc make git libpcap0.8-dev
编译httpry
创建相关数据目录
$ mkdir -p /usr/local/man/man1
$ mkdir -p /usr/man/man1/
编译httpry
$ wget http://dumpsterventures.com/jason/httpry/httpry-0.1.8.tar.gz
$ tar zvxf httpry-0.1.8.tar.gz
$ cd httpry-0.1.8
$ make
$ make install
$ mkdir /usr/local/share/httpry-0.1.8
$ mv doc scripts $_
httpry用法
$ httpry -hhttpry version 0.1.8 -- HTTP logging and information retrieval tool
Copyright (c) 2005-2014 Jason Bittel
Usage: httpry [ -dFhpqs ] [-b file ] [ -f format ] [ -i device ] [ -l threshold ][ -m methods ] [ -n count ] [ -o file ] [ -P file ] [ -r file ][ -t seconds] [ -u user ] [ 'expression' ]-b file write HTTP packets to a binary dump file-d run as daemon-f format specify output format string-F force output flush-h print this help information-i device listen on this interface-l threshold specify a rps threshold for rate statistics-m methods specify request methods to parse-n count set number of HTTP packets to parse-o file write output to a file-p disable promiscuous mode-P file use custom PID filename when running in daemon mode -q suppress non-critical output-r file read packets from input file-s run in HTTP requests per second mode-t seconds specify the display interval for rate statistics-u user set process ownerexpression specify a bpf-style capture filterAdditional information can be found at:http://dumpsterventures.com/jason/httpry
httpry使用实例
监听指定的网络接口,并且实时显示捕获到的HTTP请求与响应的包
$ httpry -i eth0
httpry version 0.1.8 -- HTTP logging and information retrieval tool
Copyright (c) 2005-2014 Jason Bittel
Starting capture on eth0 interface
2016-05-25 13:24:25 192.168.119.100 23.91.98.188 > GET hi-linux.com /2016/05/16/Linux%E5%91%BD%E4%BB%A4%E8%A1%8C%E5%AD%A6%E4%B9%A0%E7%A5%9E%E5%99%A8tldr/ HTTP/1.1 - -
2016-05-25 13:24:25 23.91.98.188 192.168.119.100 < - - - HTTP/1.1 200 OK
2016-05-25 13:24:58 192.168.119.100 23.91.98.188 > HEAD www.hi-linux.com / HTTP/1.0 - -
2016-05-25 13:24:58 23.91.98.188 192.168.119.100 < - - - HTTP/1.1 200 OK
2016-05-25 13:24:59 192.168.119.100 23.91.98.188 > HEAD www.hi-linux.com / HTTP/1.0 - -
2016-05-25 13:24:59 23.91.98.188 192.168.119.100 < - - - HTTP/1.1 200 OK
2016-05-25 13:25:00 192.168.119.100 23.91.98.188 > HEAD www.hi-linux.com / HTTP/1.0 - -
2016-05-25 13:25:00 23.91.98.188 192.168.119.100 < - - - HTTP/1.1 200 OK
^CCaught SIGINT, shutting down...
92 packets received, 0 packets dropped, 8 http packets parsed
87.6 packets/min, 7.6 http packets/min
使用-b
或-o
选项保存数据包。-b
选项将数据包以二进制文件的形式保存下来,这样可以使用httpry软件打开文件以浏览。另一方面,-o
选项将数据以可读的字符文件形式保存下来。
以二进制形式保存文件
$ httpry -i eth0 -b output.dump
浏览所保存的HTTP数据包文件
$ httpry -r output.dump
注意:不需要根用户权限就可以使用-r
选项读取数据文件。
将httpry数据以字符文件保存
$ httpry -i eth0 -o /tmp/output.txt
想监视指定的HTTP方法(如:GET,POST,PUT,HEAD,CONNECT等),使用-m
选项
$ httpry -i eth0 -m get,headhttpry version 0.1.8 -- HTTP logging and information retrieval tool
Copyright (c) 2005-2014 Jason Bittel
Starting capture on eth0 interface
2016-05-25 13:30:57 192.168.119.100 23.91.98.188 > HEAD www.hi-linux.com / HTTP/1.0 - -
2016-05-25 13:30:57 23.91.98.188 192.168.119.100 < - - - HTTP/1.1 200 OK
2016-05-25 13:30:58 192.168.119.100 23.91.98.188 > HEAD www.hi-linux.com / HTTP/1.0 - -
2016-05-25 13:30:58 23.91.98.188 192.168.119.100 < - - - HTTP/1.1 200 OK
2016-05-25 13:30:59 192.168.119.100 23.91.98.188 > HEAD www.hi-linux.com / HTTP/1.0 - -
2016-05-25 13:30:59 23.91.98.188 192.168.119.100 < - - - HTTP/1.1 200 OK
2016-05-25 13:31:09 192.168.119.100 23.91.98.188 > GET hi-linux.com /2016/05/16/Linux%E5%91%BD%E4%BB%A4%E8%A1%8C%E5%AD%A6%E4%B9%A0%E7%A5%9E%E5%99%A8tldr/ HTTP/1.1 - -
2016-05-25 13:31:09 23.91.98.188 192.168.119.100 < - - - HTTP/1.1 200 OK
^CCaught SIGINT, shutting down...
130 packets received, 0 packets dropped, 16 http packets parsed
185.7 packets/min, 22.9 http packets/min
分析httpry记录
如果是编译安装,有一个perl脚本用来帮助我们分析httpry输出。该脚本在/usr/local/share/httpry-0.1.8/scripts/
目录下。 该脚本功能有
hostname : 显示一些列唯一主机名
find_proxies:检测web代理
search_terms:查找并计算在搜索服务中输入搜索词
content_analysis:查找包含特定关键字的URI
xml_output:以xml格式输出
log_summary:生成日志摘要
db_dump:将日志转存到mysql数据库中
在使用这些脚本前,先使用-o
选项运行一段时间。一旦得到输出,可运行脚本分析
产生摘要报表
$ cd /usr/local/share/httpry-0.1.8/scripts/
$ perl ./parse_log.pl -p plugins/log_summary.pm /tmp/output.txt
parse_log.pl执行完后,会在/usr/local/share/httpry-0.1.8/scripts/
目录下生成分析结果文件log_summary.txt。看起来像下面这样
$ cat log_summary.txt LOG SUMMARYGenerated: Wed May 25 13:57:40 2016
Total lines: 14
Total run time: 0.0 secsREQUESTS BY HOUR0% 0% 0% 0% 0% 0% 0% 0% 0% 0% 0% 0% |----|----|----|----|----|----|----|----|----|----|----|00 01 02 03 04 05 06 07 08 09 10 11 0% 100% 0% 0% 0% 0% 0% 0% 0% 0% 0% 0% |----|----|----|----|----|----|----|----|----|----|----|12 13 14 15 16 17 18 19 20 21 22 23 15/5 VISITED HOSTS2 28.6% hi-linux.com
2 28.6% www.hi-linux.com
1 14.3% www.163.com
1 14.3% www.qq.com
1 14.3% www.baidu.com15/1 TOP TALKERS7 100.0% 192.168.119.10015/1 RESPONSE CODES7 100.0% 200
产生所有报表
$ perl ./parse_log.pl -d plugins /tmp/output.txt
$ ls -l *.txt
parse_log.pl执行完后,会在httpry-0.1.8/scripts
目录下生成一些分析结果文件(*.txt/xml)。
参考文档
http://www.google.com
http://www.linux78.com/http-liu-liang-ji-lu-gong-ju-httpry.html
http://www.ttlsa.com/web/how-to-sniff-http-traffic-from-the-command-line-on-linux/
https://github.com/jbittel/httpry
转载于:https://my.oschina.net/u/728453/blog/744672
Linux命令行下抓取HTTP流量的工具--httpry相关推荐
- 如何在Linux命令行下发送和接收UDP数据包
众所周知,在传输层有两个常用的协议 TCP 和 UDP,本文介绍在 Linux 命令行下,如何使用 nc 命令发送或接收 UDP 数据包,这些命令的用法对调试 UDP 通信程序将有所帮助. 1. 问题 ...
- Linux命令行下感叹号的几个用法
Linux命令行下 " ! " 的几个用法 ! 在大多数编程语言中表示取反的意思,但是在命令行中,他还有一些其他的神奇用法.熟练掌握这些用法,可以大大提高我们日常命令行操作的效率. ...
- linux命令行下命令参数前的一横(-)和两横(--)的区别
linux命令行下命令参数前的一横(-)和两横(--)的区别 原文转自:http://blog.csdn.net/songjinshi/article/details/6816776 在解释这些区别之 ...
- ffmpeg linux 命令,Linux命令行下转换媒体格式工具FFMPEG介绍
Linux命令行下转换媒体格式工具FFMPEG介绍 格式:ffmpeg [[输入文件选项]- i 输入文件名] {[输入文件选项] 输出文件名} 主要选项: -L 显示ffmpeg的版权说明 -h 显 ...
- linux命令行下载github文件,Linux命令行下使用GitHub
Linux命令行下使用GitHub 1.注册github账号 2.创建ssh密钥 cd ~ ssh-keygen -t rsa -C your_email@example.com 1 2 cd~ ss ...
- linux 命令api,linux命令行下字典,使用有道API
Linux命令行下的字典,使用"exit"退出.大家简单申请一个key就可以用了. 这里 申请 #!/usr/bin/python3.2 import urllib.request ...
- 【转】Linux命令行下svn ignore忽略文件或文件夹用法
转自:Linux命令行下svn ignore忽略文件或文件夹用法 - 陌上归人的博客 - 博客园 一.忽略单个目录 1.忽略文件夹 假如目录oa.youxi.com是从svn checkout出来的, ...
- linux 的一些实用工具,linux 命令行下的一些实用工具
linux 命令行下的一些实用工具 命令行下的一些常用应用: awesome 适合geek的桌面管理器VM mc ...
- linux的manual手册不存在,在 Linux 命令行下使用“原力”
原标题:在 Linux 命令行下使用"原力" 和绝地武士的原力一样,-f 参数是很强大的,并伴随着潜在的毁灭性,在你能用好的时候又很便利. -- Alan Formy-duval( ...
最新文章
- Go 系列教程 —— 20. 并发入门
- mysql xml生成工具_自动生成po、dao、xml 工具:mybatis-generator
- python 中 if __name__ == '__main__' 判断的作用
- 一个训练集未知的神经网络
- 经典C语言程序100例之六九
- gh0st源码分析与远控的编写(一)
- ElasticSearch探索之路(五)集群与分片:选举、动态更新、近实时搜索、事务日志、段合并
- ubuntu 安装php mcrypt扩展
- 基于RGB图像的草莓叶片白粉病检测深度学习方法
- 零基础学python难吗-Python课程学习难不难?零基础可以学习Python吗?
- CodeGear 出品 Delphi for PHP
- 推荐几个.NET开源图表组件
- unity 中画布随相机视野实时变化
- 【物理应用】基于matlab粒子群配电网重构【含Matlab源码 764期】
- 扩展欧几里得算法的证明
- 如何使用思维导图?思维导图绘制方法介绍
- 洛谷 U80341 想去玩的Seaway
- Cairo学习(一)
- 上海税前12000的工资,税后能拿到多少?
- 数字电视电子节目指南(EPG)的实现原理分析