sudo apt-get install hostapd isc-dhcp-server
开机不需要启动这两个服务,建议把它们关掉:
sudo update-rc.d -f hostapd remove
注释掉下面两个文件start on那一行:
sudo nano /etc/init/isc-dhcp-server.conf
sudo nano /etc/init/isc-dhcp-server6.conf
interface=wlan0 driver=nl80211 ssid=YOUR_AP_NAME hw_mode=g channel=10 macaddr_acl=0 auth_algs=3 wpa=2 wpa_passphrase=YOUR_AP_PASSWORD wpa_key_mgmt=WPA-PSK wpa_pairwise=TKIP CCMP rsn_pairwise=TKIP CCMP
sudo nano /etc/dhcp/dhcpd.conf 在末尾加入以下内容:
subnet 192.168.0.0 netmask 255.255.255.0 { range 192.168.0.2 192.168.0.10; option routers 192.168.0.1; option domain-name-servers 192.168.0.1,180.76.76.76,8.8.8.8; }
其中180.76.76.76是百度公共DNS服务器,8.8.8.8则是Google的DNS服务器.
在自己的家目录下创建一个hostapd目录,里面新建启动和关闭脚本,比如我这样写(注意把里面eechen换成你的用户名):
nano /home/eechen/hostapd/ap-start.sh
#!/bin/bash # 开启内核IP转发 bash -c "echo 1 > /proc/sys/net/ipv4/ip_forward" # 开启防火墙NAT转发(如果本机使用eth0上网,则把ppp0改为eth0) iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE # 关闭NetworkManager对无线网卡的控制 nmcli nm wifi off # 设置并启动无线网卡 ifconfig wlan0 192.168.0.1 netmask 255.255.255.0 # 解锁无线设备,可以用rfkill list查看解锁结果. rfkill unblock wlan # 睡眠6秒,待rfkill解锁生效 sleep 6s # 启动dhcpd和hostapd,如果hostapd无法启动请查看日志hostapd.log,查看这两个进程ps -ef|egrep "dhcpd|hostapd" nohup hostapd /etc/hostapd/hostapd.conf >/home/eechen/hostapd/hostapd.log 2>&1 & dhcpd wlan0 -pf /var/run/dhcpd.pid ps -ef|head -n1 && ps -ef|egrep "dhcpd|hostapd"
nano /home/eechen/hostapd/ap-stop.sh
#!/bin/bash killall hostapd dhcpd bash -c "echo 0 > /proc/sys/net/ipv4/ip_forward" ifconfig wlan0 down
sudo apt-get install wireshark sudo chgrp eechen /usr/bin/dumpcap sudo chmod 750 /usr/bin/dumpcap sudo setcap cap_net_raw,cap_net_admin+eip /usr/bin/dumpcap
Alt+F2运行wireshark,选择网络接口wlan0,Filter里输入http.cookie contains mail.qq.com
然后手机端登录网页QQ邮箱,在WireShark即可查看和获取QQ邮箱登录的Cookie,如图所示: