您的位置:首页 > 大数据 > 人工智能

Aircrack-ng之Airmon-ng命令

2015-08-29 12:52 507 查看

描述

airmon-ng用来实现无线接口在managed和monitor模式之间的转换。输入不带参数的airmon-ng命令,则会显示当前的接口状态。

用法

airmon-ng <start|stop> <interface> [channel]


或者:

airmon-ng <check|check kill>


其中:

< start|stop >表示开启或者停掉某个接口(强制)

< interface >指定接口(强制)

【channel】将网卡设定到特定的信道(可选)

< check|check kill > “check”会将所有影响到aircrack-ng工作的进程罗列出来,强烈推荐使用aircrack-ng套装的时候停掉这些进程。”check kill”会罗列并杀死影响aircrack-ng的进程。

用法范例

1. 查看各接口的状态:

~# airmon-ng
PHY Interface   Driver      Chipset

phy0    wlan0       ath9k_htc   Atheros Communications, Inc. AR9271 802.11n


2. 检查影响aircrack-ng的进程

当我们将网卡置于monitor模式的时候,会自动地检查影响aircrack-ng的进程。也可以通过以下命令手动检查:

~# airmon-ng check
Found 5 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
718 NetworkManager
870 dhclient
1104 avahi-daemon
1105 avahi-daemon
1115 wpa_supplicant


3. 杀死影响aircrack-ng的进程

以下命令会停掉network managers然后杀死所有影响aircrack-ng的进程:

~# airmon-ng check kill
Killing these processes:

PID Name
870 dhclient
1115 wpa_supplicant


4. 开启monitor模式

在开启monitor模式之前,需要关闭network managers(airmon-ng check kill):

~# airmon-ng start wlan0
Found 5 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
718 NetworkManager
870 dhclient
1104 avahi-daemon
1105 avahi-daemon
1115 wpa_supplicant

PHY Interface   Driver      Chipset

phy0    wlan0       ath9k_htc   Atheros Communications, Inc. AR9271 802.11n
(mac80211 monitor mode vif enabled for [phy0]wlan0 on [phy0]wlan0mon)
(mac80211 station mode vif disabled for [phy0]wlan0)


如我们所见,airmon-ng为我们创建了一个新的接口wlan0mon,并且罗列出了一些可能影响aircrack-ng的进程。

5. 关闭monitor模式

~# airmon-ng stop wlan0mon
PHY Interface   Driver      Chipset

phy0    wlan0mon    ath9k_htc   Atheros Communications, Inc. AR9271 802.11n
(mac80211 station mode vif enabled on [phy0]wlan0)
(mac80211 monitor mode vif disabled for [phy0]wlan0mon)


不要忘了重启network manager,通常使用以下命令即可:

service network-manager start


Madwifi-ng驱动的monitor模式

下面描述了如何将madwifi-ng驱动的网卡置于monitor模式。在开启电脑以后,输入”iwconfig”来显示当前无线接口状态,屏幕会显示:

lo        no wireless extensions.

eth0      no wireless extensions.

wifi0     no wireless extensions.

ath0      IEEE 802.11b  ESSID:""  Nickname:""
Mode:Managed  Channel:0  Access Point: Not-Associated
Bit Rate:0 kb/s   Tx-Power:0 dBm   Sensitivity=0/3
Retry:off   RTS thr:off   Fragment thr:off
Encryption key:off
Power Management:off
Link Quality:0  Signal level:0  Noise level:0
Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
Tx excessive retries:0  Invalid misc:0   Missed beacon:0


如果想要使用ath0(已经在使用中),首先:

airmon-ng stop ath0


屏幕会显示:

Interface       Chipset         Driver

wifi0           Atheros         madwifi-ng
ath0            Atheros         madwifi-ng VAP (parent: wifi0) (VAP destroyed)


现在,输入”iwconfig”,屏幕会显示:

lo        no wireless extensions.

eth0      no wireless extensions.

wifi0     no wireless extensions.


我们可以看到ath0已经不在了,然后可使用如下命令在ath0上开启monitor模式:

airmon-ng start wifi0


屏幕会显示:

Interface       Chipset         Driver

wifi0           Atheros         madwifi-ng
ath0            Atheros         madwifi-ng VAP (parent: wifi0) (monitor mode enabled)


现在输入”iwconfig”,屏幕会显示:

lo        no wireless extensions.

eth0      no wireless extensions.

wifi0     no wireless extensions.

ath0 IEEE 802.11g ESSID:""
Mode:Monitor Frequency:2.452 GHz Access Point: 00:0F:B5:88:AC:82
Bit Rate=2 Mb/s Tx-Power:18 dBm Sensitivity=0/3
Retry:off RTS thr:off Fragment thr:off
Encryption key:off
Power Management:off
Link Quality=0/94 Signal level=-96 dBm Noise level=-96 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:0 Missed beacon:0


我们可以看到现在ath0已经处于monitor模式了。同时要注意essid,nickname,encryption要保持在未设定的状态。接入点显示了网卡的MAC地址(只有在madwifi-ng驱动中才会显示,其他驱动不显示)。如果ath1、ath2等也在运行,在进行上述需要操作之前,需要先停掉它们:

airmon-ng stop ath1


可以通过在命令后加信道数来设定信道:

airmon-ng start wifi0 9


使用贴士

1. 验证网卡处于monitor模式

可使用”iwconfig”命令来检验网卡是否处于monitor模式,此时会显示出接口名和所处模式。对于madwifi-ng驱动的网卡,接入点显示的是网卡的MAC地址。

2. 设定当前的信道

可使用”iwlist < interface name> channel”命令来设定当前的信道。如果我们想要工作在特定的接入点上,那么当前的信道就必须和接入点匹配。在这种情况下,最开始运行airmon-ng命令的时候,最好使用设定信道的参数。

3. 带有空格和特殊字符的BSSID

参见这篇文章

4. 怎样将网卡设定回managed模式

这取决于我们使用的是什么样的驱动,对于madwifi-ng外的其他驱动来说:

airmon-ng stop <interface name>


对于madwifi-ng驱动:

airmon-ng stop athX


其中X表示0,1,2等等。对于iwconfig所列出的所有接口,都要使用上述命令来停掉它们,然后:

wlanconfig ath create wlandev wifi0 wlanmode sta


也可以点此处参见madwifi-ng文档。对于mac80211驱动,什么事都不需要做,因为airmon-ng会保留managed模式。如果不再需要monitor模式,停掉它就可以了:

airmon-ng stop monX


其中,X是monitor接口号,一般是0(除非开启了多个monitor模式)。

常见问题及解决方法

一般来讲

通常,linux的发行版都会设置有ath0或者更多的athX接口。在我们使用上述命令之前,这些接口都必须被关闭。另一个要主要的是,保证essid,nickname,encryptions没有被设定。

Airmon-ng显示接口不在monitor模式

~# airmon-ng stop wlan0mon
PHY Interface   Driver      Chipset

phy0    wlan0mon    ath9k_htc   Atheros Communications, Inc. AR9271 802.11n

You are trying to stop a device that isn't in monitor mode.
Doing so is a terrible idea, if you really want to do it then you
need to type 'iw wlan2mon del' yourself since it is a terrible idea.
Most likely you want to remove an interface called wlan[0-9]mon
If you feel you have reached this warning in error,
please report it.


最可能的情况是,接口被network namager从monitor模式变到了managed模式。发生这种情况时,表明最开始的时候没有用airmon-ng check kill命令来结束network manager。

网卡已经在monitor模式了,但是却没有显示

同上,这应该是在结束network manager之前,曾尝试将网卡置于monitor模式,然后network manager又改变了网卡的模式。

创建了接口ath1而不是ath0

这是由于madwifi-ng驱动造成的。首先,尝试停掉所有在运行的VAP接口:

airmon-ng stop IFACE


其中IFACE表示接口名称,可以通过iwconfig来查看需要停掉的接口。然后,再使用命令:

airmon-ng start wifi0


如果问题还是没有解决,参见这篇文章

为什么会有”ioctl(SIOCGIFINDEX)failed”

如果有如下错误信息:

“SIOCSIFFLAGS : No such file or directory”

“ioctl(SIOCGIFINDEX) failed: No such device”

参见这篇文章

错误信息:”wlanconfig: command not found”

如果有类似的错误信息,这说明w系统中没有wlanconfig命令或者不在路径中。如果是前者,那么在编译madwifi-ng驱动之后,要保证使用了make install,ubuntu中使用apt-get install madwifi-tools;如果是后者,需用locate或者find命令来找到该命令所在的文件夹。然后将文件目录添加到路径中。

airmon-ng显示的是RT2500而不是RT73

参见这篇文章

错误信息:”add_iface: Permission denied”

如果错误信息如下:

Interface       Chipset         Driver

wlan0                   iwl4965 - [phy0]/usr/sbin/airmon-ng: line 338: /sys/class/ieee80211/phy0/add_iface: Permission denied
mon0: unknown interface: No matching device found
(monitor mode enabled on mon0)


或者如下:

wlan0   iwlagn - [phy0]/usr/local/sbin/airmon-ng: 856: cannot create /sys/class/ieee80211/phy0/add_iface: Directory nonexistent
Error for wireless request "Set Mode" (8B06) :
SET failed on device mon0 ; No such device.
mon0: ERROR while getting interface flags: No such device


这说明airmon-ng的版本比较老旧,更新一下airmon-ng重新尝试。

check kill失败

Distros从现在起正在使用”upstart”来代替/sbin/init ,所以需要手动:

service network-manager stop
service avahi-daemon stop
service upstart-udev-bridge stop


然后查找并杀死dhclient和wpa_supplicant进程

SIOCSIFFLAGS: Unknown error 132

如果出现如下错误:

# airmon-ng start wlan0
Interface   Chipset     Driver
wlan0       Broadcom    b43 - [phy0]SIOCSIFFLAGS: Unknown error 132
(monitor mode enabled on mon0)


这表明RF拥堵了,尝试输入以下命令:

rfkill unblock all
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: