gpt4 book ai didi

linux - 如何动态解析 linux 嗅探器结果?

转载 作者:太空宇宙 更新时间:2023-11-04 09:46:19 25 4
gpt4 key购买 nike

我想对有多少客户端从我的服务器下载文件(3 种类型)进行排序和计算。

我安装了 tshark 并运行了应该捕获 GET 请求的命令:

`./tshark  'tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)' -R'http.request.method == "GET"'`

因此嗅探器开始工作,每一秒我都会得到新行,结果如下:

 0.000000 144.137.136.253 -> 192.168.4.7  HTTP GET /pids/QE13_593706_0.bin HTTP/1.1
8.330354 1.1.1.1 -> 2.2.2.2 HTTP GET /pids/QE13_302506_0.bin HTTP/1.1
17.231572 1.1.1.2 -> 2.2.2.2 HTTP GET /pids/QE13_382506_0.bin HTTP/1.0
18.906712 1.1.1.3 -> 2.2.2.2 HTTP GET /pids/QE13_182406_0.bin HTTP/1.1
19.485199 1.1.1.4 -> 2.2.2.2 HTTP GET /pids/QE13_302006_0.bin HTTP/1.1
21.618113 1.1.1.5 -> 2.2.2.2 HTTP GET /pids/QE13_312106_0.bin HTTP/1.1
30.951197 1.1.1.6 -> 2.2.2.2 HTTP GET /nginx_status HTTP/1.1
31.056364 1.1.1.7 -> 2.2.2.2 HTTP GET /nginx_status HTTP/1.1
37.578005 1.1.1.8 -> 2.2.2.2 HTTP GET /pids/QE13_332006_0.bin HTTP/1.1
40.132006 1.1.1.9 -> 2.2.2.2 HTTP GET /pids/PE_332006.bin HTTP/1.1
40.407742 1.1.2.1 -> 2.2.2.2 HTTP GET /pids/QE13_452906_0.bin HTTP/1.1

我需要做什么来将结果类型和计数像 /pids/*****.bin 一样存储到其他文件中。我在 linux 方面不强,但确信它可以用 1-3 行脚本来完成。

也许用 awk 但我不知道读取嗅探器结果的技术是什么。

谢谢,

最佳答案

你不能直接 grep 你的网络服务器的日志文件吗?

无论如何,要提取与您的服务器文件相关的捕获的 http 流量行,只需尝试

./tshark  'tcp port 80 and \
(((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)' \
-R'http.request.method == "GET"' | \
egrep "HTTP GET /pids/.*.bin"

关于linux - 如何动态解析 linux 嗅探器结果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15926498/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com