目的:实现移动端的websocket包抓取分析.
mitmproxy,charis都没办法实现websocket包的抓取,但wireshark虽可以抓包websocket但无法使用代理, 想到在PC端建立一个移动热点,然后通过移动设备连接这个移动热点, 然后在PC端使用wireshark抓取websocket包。
马上施行,我使用的是ubuntu14.04 , 比较复杂(mac等简单设置即可),一步一步来:
1. 网上的文章有直接通过ubuntu网络连接在产生新wifi热点,见: http://jingyan.baidu.com/article/d8072ac4414864ec95cefdaf.html ,但是我可以建立连接却无法通过iphone连接到这个热点,一直提示无法连接。 推荐下面的方法
2. 具体方法如下:使用ap-hotspot来创建WIFI热点,而不要用Ad hoc。终端里输入:
$ sudo add-apt-repository ppa:nilarimogard/webupd8
$ sudo apt-get update
$ sudo apt-get install ap-hotspot
$ sudo ap-hotspot configure //这一步会检查ubuntu的网络和WIFI接口,确定后会提示你配置热点,输入ssid和密码之类的就行了
$ sudo ap-hotspot start
参数使用说明:
start start wireless hotspot//开始使用
stop stop wireless hotspot//停止使用
restart restart wireless hotspot//重启
configure configure hotspot//配置使用
安装成功后配置过程如下:
[email protected]:/tmp$ sudo ap-hotspot configure
Detecting configuration…
Detected eth0 as the network interface connected to the Internet. Press ENTER if this is correct or enter the desired interface below (e.g.- eth0, ppp0 etc.)://默认按Enter即可
Detected wlan0 as your WiFi interface. Press ENTER if this is correct or enter the desired interface (e.g.- wlan1)://默认按Enter即可
Enter the desired Access Point name or press ENTER to use the default one (myhotspot):
//Wifi名字
Enter the desired WPA Passphrase below or press ENTER to use the default one (qwerty0987):
//wifi 密码
使用篇:
$ sudo ap-hotspot start
Starting Wireless Hotspot…
Wireless Hotspot active
出现如上字样即可
问题集锦篇:
1、无法出现Wireless Hotspot active,并一直保持Starting Wireless Hotspot…
hostapd默认版本有bug
解决方法:
移除hostapd
sudo apt-get remove hostapd
然后:
去 https://pkgs.org/download/hostapd 下载对应的版本, 我下的是:
wget http://archive.ubuntu.com/ubuntu/pool/universe/w/wpa/hostapd_2.1-0ubuntu1.4_amd64.deb
sudo dpkg -i hostapd*.deb
sudo apt-mark hold hostapd
“sudo apt-mark hold hostapd” 将防止版本升级到有问题的版本。
之后需要重新安装ap-hotspot.
2、出现:
Wireless Hotspot active
bash: notify-send: 未找到命令
解决方法:
$ notify-send
程序“notify-send”尚未安装。 您可以使用以下命令安装:
sudo apt-get install libnotify-bin
$ sudo apt-get install libnotify-bin
3、Ubuntu下使用ap-hotspot出现“Another process is already running”问题的解决方案
sudo rm /tmp/hotspot.pid
再重启服务
$ sudo ap-hotspot start
如果还是一直Starting Wireless Hotspot…, 进行如下操作:
在启动前,执行以下命令:
sudo nmcli nm wifi off
sudo rfkill unblock wlan
sudo service hostapd restart
再执行
sudo ap-hotspot start
就好了。
然后打开wireshark,filter使用websocket,就可以抓包了,done!