免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3002 | 回复: 7
打印 上一主题 下一主题

请叫怎么处理/usr/sbin/tcpdump -i eth2 arp 的输出结果; [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-11-13 15:08 |只看该作者 |倒序浏览
怎么写这个shell,处理/usr/sbin/tcpdump -i eth2 arp 的输出结果

例如:
要求执行30秒

之后比如输出结果为

14:56:46.002083 arp reply 192.168.1.95 is-at 00:07:e9:0a:83:1b (oui Unknown)
14:56:46.311967 arp who-has 192.168.0.7 tell 192.168.0.254
14:56:46.312061 arp reply 192.168.0.7 is-at 00:0b:2f:1b:1a:ae (oui Unknown)
14:56:46.339961 arp who-has 192.168.0.85 tell 192.168.0.254
14:56:46.340164 arp reply 192.168.0.85 is-at 00:07:e9:0a:3f:87 (oui Unknown)
14:56:46.429956 arp who-has 192.168.1.195 tell 192.168.0.254
14:56:46.430313 arp reply 192.168.1.195 is-at 00:07:e9:0a:82:c7 (oui Unknown)
14:56:46.664942 arp who-has 192.168.0.87 tell 192.168.0.254
14:56:46.864927 arp who-has 192.168.0.18 tell 192.168.0.254
14:56:46.865721 arp reply 192.168.0.18 is-at 00:0b:2f:1b:32:34 (oui Unknown)
14:56:46.920996 arp who-has 192.168.1.64 tell 192.168.0.57
14:56:47.663878 arp who-has 192.168.0.87 tell 192.168.0.254
14:56:48.094845 arp who-has 192.168.1.113 tell 192.168.0.254
14:56:48.095088 arp reply 192.168.1.113 is-at 00:07:e9:0a:82:f9 (oui Unknown)
14:56:48.143841 arp who-has 192.168.0.83 tell 192.168.0.254
14:56:48.144240 arp reply 192.168.0.83 is-at 00:07:e9:0a:6f:f1 (oui Unknown)
14:56:48.156792 arp who-has 192.168.1.64 tell 192.168.0.57
14:56:48.162838 arp who-has 192.168.0.202 tell 192.168.0.254
14:56:48.163418 arp reply 192.168.0.202 is-at 00:1b:24:9b:f8:b7 (oui Unknown)
14:56:48.281187 arp who-has 192.168.1.10 tell 192.168.0.252
14:56:48.281339 arp who-has 192.168.1.11 tell 192.168.0.252
14:56:48.285631 arp who-has 192.168.1.18 tell 192.168.0.252
14:56:48.286753 arp who-has 192.168.1.20 tell 192.168.0.252
14:56:48.287020 arp who-has 192.168.1.21 tell 192.168.0.252
14:56:48.288157 arp who-has 192.168.1.23 tell 192.168.0.252
14:56:48.288430 arp who-has 192.168.1.25 tell 192.168.0.252
14:56:48.292944 arp who-has 192.168.1.31 tell 192.168.0.252
14:56:48.293374 arp who-has 192.168.1.33 tell 192.168.0.252
14:56:48.294484 arp who-has 192.168.1.36 tell 192.168.0.252
14:56:48.300106 arp who-has 192.168.1.55 tell 192.168.0.252
14:56:48.300414 arp who-has 192.168.1.56 tell 192.168.0.252
14:56:48.303888 arp who-has 192.168.1.60 tell 192.168.0.252
14:56:48.305169 arp who-has 192.168.1.62 tell 192.168.0.252
14:56:48.313496 arp who-has 192.168.1.72 tell 192.168.0.252

请问我改怎么写这个shell.实现
is-at 后面mac地址出现3次以上的输出出来
tell 后面的ip地址出现3次以上的输出出来,输出格式为

次数            IP或MAC
20                    192.168.0.252
3                      00:1b:24:9b:f8:b7

请问这个shell 怎么写,在线等.

论坛徽章:
8
摩羯座
日期:2014-11-26 18:59:452015亚冠之浦和红钻
日期:2015-06-23 19:10:532015亚冠之西悉尼流浪者
日期:2015-08-21 08:40:5815-16赛季CBA联赛之山东
日期:2016-01-31 18:25:0515-16赛季CBA联赛之四川
日期:2016-02-16 16:08:30程序设计版块每日发帖之星
日期:2016-06-29 06:20:002017金鸡报晓
日期:2017-01-10 15:19:5615-16赛季CBA联赛之佛山
日期:2017-02-27 20:41:19
2 [报告]
发表于 2007-11-13 15:14 |只看该作者
awk '{a[$6]++}
END{for(i in a)print i,a[i]}' urfile

有空请读基础12篇

论坛徽章:
0
3 [报告]
发表于 2007-11-13 15:16 |只看该作者
可以写具体点吗?
本人初学,着急,谢谢.

论坛徽章:
1
荣誉会员
日期:2011-11-23 16:44:17
4 [报告]
发表于 2007-11-13 15:22 |只看该作者
try

  1. ...|awk '/is-at/{mac[$(NF-2)]++}END{for(i in mac)if(mac[i]>3){print mac[i],i}};/tell/{ip[$NF]++}END{for(j in ip)if(ip[j]>3){print ip[j],j}}'
复制代码

论坛徽章:
0
5 [报告]
发表于 2007-11-13 15:35 |只看该作者
ok,好用
那么我怎么写可以让/usr/sbin/tcpdump -i eth2 arp 只让这个命令执行 30秒???

[ 本帖最后由 mii_tool 于 2007-11-13 15:53 编辑 ]

论坛徽章:
1
荣誉会员
日期:2011-11-23 16:44:17
6 [报告]
发表于 2007-11-13 16:09 |只看该作者
原帖由 mii_tool 于 2007-11-13 15:35 发表
ok,好用
那么我怎么写可以让/usr/sbin/tcpdump -i eth2 arp 只让这个命令执行 30秒???

tcpdump没法指定运行时间, 可以用-c count 来指定劫获count个数据包后退出

论坛徽章:
0
7 [报告]
发表于 2007-11-13 16:40 |只看该作者
谢谢,写完了。

论坛徽章:
0
8 [报告]
发表于 2007-11-14 15:56 |只看该作者
嘿嘿  LZ准备抓arp欺骗吧 我也是用这个方法呢
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP