我正试图为基于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"不是一个公认的内部或外部命令。我试过使用空格,没有空格...etc,但无法找到一种方法来完成这项工作。
问题可能来自我“连锁”条件的方式。
发布于 2013-08-06 18:24:08
以及只捕获具有这些特性的数据包的过滤器。
..。
"http.request.method == ' GET '“(应该是GET请求)
最后一部分是,很难用捕获过滤器完成。如果您可以避免这种情况,则其他的操作相对容易使用捕获筛选器:
"ip src 192.168.0.1 && ip dst 111.222.111.222 && (tcp port 80 or tcp port == 443)"您可以使用整个*鲨鱼过滤器作为读取过滤器:
-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/TLS,如果请求是加密的,则必须安排解密这些请求,以使http.request.method == 'GET'工作。
(“或”子句周围的括号可能没有必要,但我希望它们只是使表达式的含义更加明显。)
发布于 2012-04-24 12:22:19
tshark -f选项采用捕获滤波器,而不是wireshark显示过滤器。这与脂帽语法相同。
发布于 2013-08-06 13:20:37
您必须删除过滤器部件之间的"字符。尝试:
"ip && ip.src == 192.168.0.1 && ip.dst == 111.222.111.222 &&
port == 80 or port == 443 && http.request.method == 'GET'"https://stackoverflow.com/questions/10288908
复制相似问题