Windows Wireshark筛选器语法

Windows Wireshark筛选器语法,windows,networking,wireshark,Windows,Networking,Wireshark,我正在尝试为TShark编写一个基于命令行的Wireshark过滤器。 我想将这些选项添加到命令中: -i 2 (interface with index n°2) -a duration:60 (the "scan" should last 60 seconds) -v (print the result and exit) -x (print an ASCII dump in the file) 以及仅捕获具有以下特殊性的数据包的过滤器: "ip" (only IP packets) "i

我正在尝试为TShark编写一个基于命令行的Wireshark过滤器。 我想将这些选项添加到命令中:

-i 2 (interface with index n°2)
-a duration:60 (the "scan" should last 60 seconds)
-v (print the result and exit)
-x (print an ASCII dump in the file)
以及仅捕获具有以下特殊性的数据包的过滤器:

"ip" (only IP packets)
"ip.src == 192.168.0.1" (source IP adress should be 192.168.0.1)
"ip.dst == 111.222.111.222" (destination IP adress should be 111.222.111.222)
"port == 80 or port == 443" (port should be http or https)
"http.request.method == 'GET'" (it should be a GET request)
然后我想把结果保存在一个文件“test.txt”中。 所以最后的命令应该是:

tshark -i 2 -a duration:60 -vx -f "ip" && "ip.src == 192.168.0.1" && "ip.dst == 111.222.111.222" && "port == 80 or port == 443" && "http.request.method == 'GET'" > test.txt
但我一直从Windows收到一条错误消息,说“ip.src==192.168.0.1”不是可识别的内部或外部命令。我试过使用空格,没有空格…等等,但想不出一个方法来完成这项工作

问题可能来自我“链接”条件的方式

  • 还想询问是否有某种“停止执行”命令可以停止当前捕获,但仍将结果保存在.txt文件中

tshark
-f
选项使用,而不是wireshark显示过滤器。这与语法相同。

您必须删除筛选器部分之间的
字符。请尝试:

"ip && ip.src == 192.168.0.1 && ip.dst == 111.222.111.222 &&
 port == 80 or port == 443 && http.request.method == 'GET'"
以及一个只捕获具有这些特殊性的数据包的过滤器

“http.request.method=='GET'”(它应该是一个GET请求)

最后一部分是非常难用捕获过滤器来完成的。如果可以避免这一点,剩下的部分则相对容易用捕获过滤器来完成:

"ip src 192.168.0.1 && ip dst 111.222.111.222 && (tcp port 80 or tcp port == 443)"
您可以将整个*shark筛选器用作读取筛选器:

(请注意,它是
tcp.port
,而不仅仅是
port

但是,请注意,对于SSL/TLS上的HTTP,如果请求是加密的,则必须安排解密这些请求,以便
HTTP.request.method=='GET'
正常工作


(在“或”子句周围的括号可能不是必需的,但我更希望它们只是使表达式的含义更加明显。)

是的,但我需要的是tshark捕获筛选器而不是显示筛选器。因此“-f“应该是正确的选项,不是吗?您得到的特定错误是由命令中的
&
引起的。”。如果使用正确的语法,则不需要任何
&
符号。
-r "ip && ip.src == 192.168.0.1 && ip.dst == 111.222.111.222 && (tcp.port == 80 or tcp.port == 443) && http.request.method == 'GET'"