预装软件:
[plain] view plain copy print?
- yum -y install flex
- yum -y install bison
- yum -y install gcc
yum -y install flex
yum -y install bison
yum -y install gcc
下载及安装
[plain] view plain copy print?
- cd /var/install/
- wget http://www.tcpdump.org/release/libpcap-1.5.3.tar.gz
- wget http://www.tcpdump.org/release/tcpdump-4.5.1.tar.gz
- tar -zxvf libpcap-1.5.3.tar.gz
- cd libpcap-1.5.3
- ./configure
- make && make install
- cd ..
- tar -zxvf tcpdump-4.5.1.tar.gz
- cd tcpdump-4.5.1
- ./configure
- make && make install
cd /var/install/
wget http://www.tcpdump.org/release/libpcap-1.5.3.tar.gz
wget http://www.tcpdump.org/release/tcpdump-4.5.1.tar.gz
tar -zxvf libpcap-1.5.3.tar.gz
cd libpcap-1.5.3
./configure
make && make install
cd ..
tar -zxvf tcpdump-4.5.1.tar.gz
cd tcpdump-4.5.1
./configure
make && make install
安装完毕,下面开始抓包
使用tcpdump抓取HTTP包
[plain] view plain copy print?
- tcpdump -XvvennSs 0 -i eth0 tcp[20:2]=0x4745 or tcp[20:2]=0x4854 -w /tmp/http
tcpdump -XvvennSs 0 -i eth0 tcp[20:2]=0x4745 or tcp[20:2]=0x4854 -w /tmp/http
(0x4745 为"GET"前两个字母"GE",0x4854 为"HTTP"前两个字母"HT"。)
这句话意思是说将HTTP请求及GET请求的数据包放到/tmp/http文件中。
2、tcpdump tcp -i eth0 -t -s 0 -c 100 and dst port 6000 and src net 10.86.201.168 -w /tmp/tcpdump.cap
(1)tcp: ip icmp arp rarp 和 tcp、udp、icmp这些选项等都要放到第一个参数的位置,用来过滤数据报的类型
(2)-i eth0 : 只抓经过接口eth0的包
(3)-t : 不显示时间戳
(4)-s 0 : 抓取数据包时默认抓取长度为68字节。加上-S 0 后可以抓到完整的数据包
(5)-c 100 : 只抓取100个数据包
(6)dst port 6000【! 22】 : 抓取目标端口是6000的数据包【不抓取目标端口是22的数据包】
(7)src net 10.86.201.168 : 数据包的源网络地址为10.86.201.168
(8)-w ./tcpdump.cap : 保存成cap文件,方便用wireshark分析
更多其他抓包方式查看:http://blog.chinaunix.net/uid-22570852-id-225969.html
下面安装Wireshark分析一下数据包。
Wireshark下载问度娘。
Wireshark使用教程:http://blog.youkuaiyun.com/xmphoenix/article/details/6546022