(十)wireshark抓包分析TCP
(1)Ubuntu平台的安装
(2)wireshark添加用户组
(3)Lua脚本修改:
修改init.lua
#直接运行wireshark的话会报错:
Lua: Error during loading:
[string"/usr/share/wireshark/init.lua"]:45: dofile has been disabled
sudo gedit /usr/share/wireshark/init.lua
#注释倒数第二行,添加单行注释--
--dofile(DATA_DIR.."console.lua")
(4)sudo权限:才有网卡信息
(5)协议/端口过滤:tcp.port==1024
在Filter输入想要抓取的协议类型
#协议过滤,直接在Filter输入协议名称即可.
#常见的协议有tcp,udp,arp,http,ssl等
#过滤源ip、目的ip,如ip地址为127.0.0.1
ip.src==127.0.0.1
ip.dst==127.0.0.1
#端口过滤,如过滤80端口
tcp.port==80 #这条规则是把源端口和目的端口为80的都过滤出来
tcp.srcport==80 #只过滤源端口为80的包
tcp.dstport==80 #只过滤目的端口为80的包
#http协议过滤
http.request.method=="GET" #过滤post包
http.request.method=="POST"
#过滤两种条件时,使用and连接,如:过滤ip为192.168.0.190并且为http协议的ip.src==192.168.0.190and http
下面是一些捕捉过滤器的例子。
tcp dst port 433 :显示目的TCP端口为433的封包。
ip src host 192.168.0.1:显示来源IP地址为:192.168.0.1的封包。
host 192.168.0.1:显示目的或来源IP地址为:192.168.0.1的封包。
src portrange :1000-2000:显示来源为UDP或TCP,且端口在1000至2000范围内的封包。
not icmp:显示除了icmp以外的所有封包。
(6)wireshark报The capture sessioncould not be initiated (failed to set hardware filter to promiscuous mode)这样的错误。通过查找资料,需要将wireshark设置一下:
首先找到“Capture”菜单项,然后点击选择“Option”,去掉“promiscuous mode”前面的对勾就OK了……
(7)结果
三次握手连接:
四次挥手终止: