windows - Wireshark 过滤器语法

标签 windows networking wireshark

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

-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 文件中。

最佳答案

and a filter that only captures packets with these particularities

...

"http.request.method == 'GET'" (it should be a GET request)

最后一部分使用捕获过滤器极其很难完成。如果您可以避免这种情况,那么使用捕获过滤器就可以相对容易地完成其余:

"ip src 192.168.0.1 && ip dst 111.222.111.222 && (tcp port 80 or tcp port == 443)"

并且您可能能够使用整个*shark过滤器作为读取过滤器:

-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'"

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

但是,请注意,对于 HTTP-over-SSL/TLS,如果请求已加密,您必须安排解密这些请求,以便 http.request.method = = 'GET' 即可工作。

(“or”子句周围的括号可能不是必需的,但我更喜欢它们只是让表达式的含义更加明显。)

关于windows - Wireshark 过滤器语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10288908/

相关文章:

c++ - 如何将 INT64 写入 CString

windows - Air Native Extension如何使用外部Dll?

windows - 您如何找出哪个 NIC 已连接到 Internet?

linux - ifconfig 似乎不同意 Centos 网络连接偏好

http - Wireshark 不显示 http 和 https 数据包

sockets - 未收到 Indy TCP 客户端数据

python - 将所有 pcap 文件转换为包含所需列的 csv python

linux - 模仿特定的 USB 设备

java桌面应用程序-在本地服务器上共享一台数据库主机

windows - Windows 上的管道文件在哪里?