Friday, April 24, 2015

Enable wifi sniffer without rooting

让非root用户能使用wireshark捕捉网络数据包

分类: Linux 安全相关 2012-01-30 17:42 2366人阅读 评论(0) 收藏 举报

默认情况下,访问网络端口需要root权限,而wireshark的只是/usr/share/dumpcap的一个UI,/usr/share/dumpcap需要root权限,所以没法non-root用户无法读取网卡列表。

解决办法很简单,sudo wireshark


但是wireshark官方不推荐这么做:

Running as user "root" and group "root".
This could be dangerous.


If you're running Wireshark this way in order to perform live capture, you may want to be aware that there is a better way documented at


所以用另一种方法,改变/usr/share/dumpcap的group,添加一个group:wireshark,chgrp到wireshark组,再改成750权限,这样方便权限控制。

  1. sudo -s  
  2. groupadd wireshark  
  3. usermod -a -G wireshark <You own username>  
  4. chgrp wireshark /usr/bin/dumpcap  
  5. chmod 4750 /usr/bin/dumpcap  

又参考网上的解决方案,执行下面命令
  1. setcap cap_net_raw,cap_net_admin=eip /usr/bin/dumpcap  

用getcap /usr/bin/dumpcap,输出应当是/usr/bin/dumpcap = cap_net_admin,cap_net_raw+eip,说明生效

注意得注销一下才能生效

官方解决方案http://packetlife.net/blog/2010/mar/19/sniffing-wireshark-non-root-user/


Best regards,
Yuanda(Dave) Xu

No comments:

Post a Comment