好记性不如铅笔头

linux, 操作系统

ubuntu下使用airmon-ng和wireshark抓取802.11管理包

wireshark默认情况下无法抓取无线网络的管理包。我们可以通过配置无线网卡为monitor模式,来使用wireshark进行抓包。wireshark对于802.11抓包的WIKI介绍网址:【 https://wiki.wireshark.org/CaptureSetup/WLAN/ 】。

CONTENTS

wireshark的安装:

wireshark在ubuntu下的安装很简单,如果装好之后启动有警告,可以输入下面的命令:

sudo dpkg-reconfigure wireshark-common  #press the right arrow and enter for yes
sudo chmod +x /usr/bin/dumpcap

根据WIKI可知,wireshark建议使用airmon-ng工具来快速的将无线网卡切换到monitor模式。关于airmon-ng的使用方式,可以参考【 http://www.aircrack-ng.org/doku.php?id=airmon-ng 】。关于aircrack-ng和airmon-ng的详细使用方式,这里就不笔记了。

aircrack-ng的安装:

ubuntu下默认没有安装aircrack-ng,我们使用下面的命令安装:

cstriker1407@cstriker1407-x64:~$ sudo apt-get install aircrack-ng
cstriker1407@cstriker1407-x64:~$ aircrack-ng --help

  Aircrack-ng 1.2 beta3 - (C) 2006-2013 Thomas d'Otreppe
  http://www.aircrack-ng.org

。。。。。。
。。。。。。

改为ubuntu自带驱动:

在切换之前,有一点需要注意,就是无线网卡的驱动需要是ubuntu自带的无线驱动,如果类似作者这样之前编译过自己的驱动【 8192 】,需要将其停止,还原为以前自带的驱动。步骤分为2步:

第一步是修改blacklist,取消对自带驱动的屏蔽,修改之后的情况如下:

cstriker1407@cstriker1407-x64:/etc/modprobe.d$ cat  blacklist.conf | tail -15
# EDAC driver for amd76x clashes with the agp driver preventing the aperture
# from being initialised (Ubuntu: #297750). Blacklist so that the driver
# continues to build and is installable for the few cases where its
# really needed.
blacklist amd76x_edac

#使用ubuntu自带的无线网卡驱动
#blacklist rtl8192cu
#blacklist rtl8192c_common
#blacklist rtlwifi

第二步是删除安装的自定义驱动:

cstriker1407@cstriker1407-x64:~/下载/RTL8188C_8192C_USB_linux_v4.0.2_9000.20130911/driver/rtl8188C_8192C_usb_linux_v4.0.2_9000.20130911$ sudo make uninstall #驱动的makefile里面有unistall命令,直接执行即可。
rm -f /lib/modules/3.19.0-26-generic/kernel/drivers/net/wireless//8192cu.ko
/sbin/depmod -a 3.19.0-26-generic

使用airmon-ng切换为monitor模式:

根据wiki介绍,我们使用下面的命令来切换为monitor模式:

cstriker1407@cstriker1407-x64:~$ iwconfig #首先查看下当前无线网卡
virbr0-nic  no wireless extensions.

eth0      no wireless extensions.

wlan0     IEEE 802.11bgn  ESSID:off/any  
          Mode:Managed  Access Point: Not-Associated   Tx-Power=20 dBm   
          Retry short limit:7   RTS thr=2347 B   Fragment thr:off
          Power Management:off
          
virbr0    no wireless extensions.

lo        no wireless extensions.

cstriker1407@cstriker1407-x64:~$ sudo airmon-ng start wlan0 #切换为monitor模式


Found 4 processes that could cause trouble.
If airodump-ng, aireplay-ng or airtun-ng stops working after
a short period of time, you may want to kill (some of) them!

PID	Name
726	avahi-daemon
729	NetworkManager
787	avahi-daemon
885	wpa_supplicant


Interface	Chipset		Driver

wlan0		Unknown 	rtl8192cu - [phy0]
				(monitor mode enabled on mon0)  #切换成功,可以在mon0上进行监听

cstriker1407@cstriker1407-x64:~$ iwconfig #在此查看下当前接口列表,发现有mon0
virbr0-nic  no wireless extensions.

eth0      no wireless extensions.

mon0     .。。。

wlan0    。。。
 
virbr0    no wireless extensions.

lo        no wireless extensions.

cstriker1407@cstriker1407-x64:~$ sudo airmon-ng stop mon0 #监听完成之后,关闭monitor模式,注意这里关闭的是mon0


Interface	Chipset		Driver

mon0		Unknown 	rtl8192cu - [phy0] (removed)
wlan0		Unknown 	rtl8192cu - [phy0]

cstriker1407@cstriker1407-x64:~$ service NetworkManager restart #如果网络有问题,可以尝试重启下服务,或者直接重启

当我们开启了monitor模式之后,就可以使用wireshark来抓包了。

对mon0抓包,注意使用monitor模式:

抓取的包如下:

使用iwconfig来切换为monitor模式:

除了使用airmon-ng来切换之外,我们也可以使用ubuntu自带的工具,命令如下:

#切换为monitor模式
cstriker1407@cstriker1407-x64:~$ iwconfig wlan0 #首先看下当前网卡的模式,这里为managed模式
wlan0     IEEE 802.11bgn  ESSID:"TP-LINK"  
          Mode:Managed  Frequency:2.422 GHz  Access Point: BB:D1:77:D4:E8:40   
          Bit Rate=150 Mb/s   Tx-Power=20 dBm   
          Retry short limit:7   RTS thr=2347 B   Fragment thr:off
          Power Management:off
          Link Quality=58/70  Signal level=-52 dBm  
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:238   Missed beacon:0

cstriker1407@cstriker1407-x64:~$ sudo ifconfig wlan0 down #先停止wlan0
cstriker1407@cstriker1407-x64:~$ sudo iwconfig wlan0 mode monitor  #将网卡切为monitor模式
cstriker1407@cstriker1407-x64:~$ sudo ifconfig wlan0 up #启动wlan0

cstriker1407@cstriker1407-x64:~$ iwconfig wlan0 #这里可以看到已经切换为monitor模式了,这里就可以使用wireshark抓包了。
wlan0     IEEE 802.11bgn  Mode:Monitor  Frequency:2.422 GHz  Tx-Power=20 dBm   
          Retry short limit:7   RTS thr=2347 B   Fragment thr:off
          Power Management:off


#切回正常模式
cstriker1407@cstriker1407-x64:~$ sudo ifconfig wlan0 down #先停止
cstriker1407@cstriker1407-x64:~$ sudo iwconfig wlan0 mode managed #切换 
cstriker1407@cstriker1407-x64:~$ sudo ifconfig wlan0 up #再启动
cstriker1407@cstriker1407-x64:~$ service NetworkManager restart #如果还是无法上网,可以尝试重启下服务

发表评论

3 × 3 =

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据