tcpdump tcp http Wireshark 抓包

1、tcpdump抓http包

打印在屏幕上

tcpdump -i eth0 -A -s 0 'dst 192.168.0.12 and tcp port 8082 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)'

tcpdump -i eth0 -A -s 0 'dst 117.48.214.76 and dst port 8082 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)'

写入文件

tcpdump -i eth0 -A -s 0 'host 117.48.214.76 and tcp port 8082 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)' -w ser.cap

tcpdump -i eth0 -A -s 0 'host 117.48.214.76 and dst port 8082 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)' -w cli.cap

-A是以ASCII形式输出,可将输出文件用wireshark打开分析

2、若报无权限错误,则进行安装权限管理工具

先查看当前的tcpdump的模式: 

grep tcpdump /sys/kernel/security/apparmor/profiles 

/usr/sbin/tcpdump ( enforce) 

上面显示是enforce模式,所以有这个问题,把它改成complain模式: 

aa-complain /usr/sbin/tcpdump                        ------ This will change it to complain 

再次使用tcpdump 并写文件的时候就没问题了。 

想在转换成enforce模式时: 

aa-enforce /usr/sbin/tcpdump             ----- This will renable the AppArmor profile for tcpdump

【注】  通过命令 aa-complain 或aa-enforce可以切换profile文件的状态。这需要先安装对应的utils工具: sudo apt-get install apparmor-utils

猜你喜欢

转载自blog.csdn.net/busai2/article/details/83752049