Mac下安装Wireshark,双击闪退

时间:2023-03-09 14:16:32
Mac下安装Wireshark,双击闪退
 Mac OS X上使用Wireshark抓包(http://blog.csdn.net/phunxm/article/details/38590561)

Mac下安装Wireshark

/Applications/Wireshark.app/Contents/MacOS/Wireshark

root# export DISPLAY=:0.0

系统:OS X 10.9 Mavericks
Wireshark安装包:Wireshark 1.10.2 Intel 64_0.dmg
首先安装X11 (即XQuartz);
安装Wireshark.dmg;
报错:

The domain/default pair of (kCFPreferencesAnyApplication, AppleAquaColorVariant) does not exist

2013-10-28 23:04:03.650 defaults[4205:507]

The domain/default pair of (kCFPreferencesAnyApplication, AppleHighlightColor) does not exist

(process:4187): Gtk-WARNING **: Locale not supported by C library.

Using the fallback 'C' locale.

(wireshark-bin:4187): Gtk-WARNING **: cannot open display:

(注意以上最后一个提示)
切换到root账户;
执行以下命令:

root# export DISPLAY=:0.0

root# xhost +

root# xhost +localhost

root# xhost + localhost

root# hostname

shuiyouren.local

root# xhost + shuiyouren.local

root# export XAUTHORITY=/Users/[shuiyouren(你的用户主目录)]/.Xauthority

启动X11程序,然后以root账户运行Wireshark:

root# /Applications/Wireshark.app/Contents/MacOS/Wireshark

到此将运行Wireshark,如果失败,退出重新运行。
Mac下安装Wireshark,双击闪退
本文相关错误信息:(wireshark-bin:1336): Gtk-WARNING **: cannot open display: :0.0
将以上操作添加到profile文件方便以后运行。
注意点:一定要先运行X11,然后再通过命令行运行Wireshark!
建议:chmod g+rw /dev/bpf* (这样可以以普通用户运行,至于是否需要相关参数的配置自己再琢磨)
网上其它的方法尝试未果,原因不详,主要还是理解不深O(∩_∩)O哈!

Wireshark设置interface 时提示“There are no interfaces on which a capture can be done ”

 (http://blog.163.com/likaifeng@126/blog/static/32097310201271451655190/)
     今天在电脑上安装了WIRESHARK软件,在设置interface 时提示"There are no interfaces on which a capture can be done"  提示没有任何一个网络接口准备好。此提示明显是不对的, 我的网卡明明可以正常上网,网络接口怎么会没有准备好呢?  想着应该是和linux下的普通用户权限有关系。上网google了一下,找到了解决问题的方法, 现在整理下来, 以备后用。
  思路;即然问题与权限有关系 , 那么解决方法无法有两点, 一个就是直接使用root登陆,这样就可以有足够的权限运行任意程序了, 但显然是不安全的,另外一种方法是通过suid guid等办法给予普通用户执行wireshark的权限。这样相对来说比安全。
  第一种方法:使用root用户登陆
       xiaoshancun@xiaoshancun-VM500:~$ sudo wireshark 
  第二种方法: 通过guid形式使当前普通用户可以运行此程序。

root@xiaoshancun-VM500:~# groupadd  -g 130  wireshark

       #  新建一个名为wireshark的用户组, 130 是GID,此数字不是固定不变的, 请先查看/etc/group 文件查看最大的GID是多少,然后加1即可。
      root@xiaoshancun-VM500:~# usermod  -a -G wireshark  xiaoshancun  
      #  将当前用户 xiaoshancun 添加到wireshark组中。 使之成为新的组员。
     root@xiaoshancun-VM500:~# chgrp  wireshark   /usr/bin/dumpcap
     #  将/usr/bin/dumpcap  程序的属组更改为wireshark  。
      root@xiaoshancun-VM500:~# chmod  4750 /usr/bin/dumpcap
     修改 /usr/bin/dumpcap  的权限 更改为  4750  添加suid 权限 。 
      root@xiaoshancun-VM500:~# setcap cap_net_raw,cap_net_admin=eip /usr/bin/dumpcap 
     修改完成还不能直接使用,需要重新登陆一下才可以。需你不想重新登陆可以使用如下命令。
     root@xiaoshancun-VM500:~#  newgrp wireshark
   完屔后就可以使用普通用户执行wireshark 程序了。 
   Mac下安装Wireshark,双击闪退