web 学习

如何在 MAC 下面使用 Aircrack-ng?

在 Mac 下面使用 Aircrack-ng 要解决的两个问题:Aircrack-ng 在 Mac 下如何安装?使用 airport 而不是 Aircrack-ng 中的工具获取握手包。

  1. Aircrack-ng 在 Mac 下编译的问题。直接使用 make 源码有问题,可以使用 Macport 进行安装。Macport 已经预置了 Aircrack-ng ,brew 没有。安装好 Macport 之后,命令行下:sudo port install aircrack-ng, Macport 会自动下载编译和安装。

  2. 获取握手包的问题。Mac 下面使用 Aircrack-ng 包中的 airmon-ng 进行嗅探有问题,会提示 wireless-tools 找不到,因为 Airmon-ng 依赖于 wireless-tools ,而 Linux wireless-tools 在 Mac 下的编译也有问题。如果使用 wireshark 的 Mon mode 的话也有问题,wireshark 的监听模式认为 Mac 的网卡不支持监听模式。其实 Mac 本身自带一个 airport 工具,可以很方便的扫描和在监听模式下进行监听: airport -s 进行扫描,airport en1 sniff 1 进行监听。具体可以参考下面这篇文章:airport – 极少人知道的命令行无线工具

我在测试 Aircrack-ng 的时候使用的是 Mountain Lion 系统,其他系统没有试过。

原文链接:http://www.tfan.org/using-aircrack-ng-under-mac/

mac上安装aircrack-ng

  1. Download and install XCode

  2. Download and install MacPorts

  3. Update Mac Ports

    sudo port-vselfupdate

  4. Install AirCrack

    sudo port install aircrack-ng

That’s it! Happy cracking.

airport – the Little Known Command Line Wireless Utility

Hidden from the casual Mac user is a spiffy command line utility that allows you to view, configure, and troubleshoot your Mac’s wireless connection, entirely from the Terminal of OS X. This command has a help file but is otherwise but not much documentation, and judging by the obscure location of the command, Apple probably didn’t think it would be too useful for the average Mac user. But the hidden command line airport tool is very useful indeed, particularly for more advanced Mac users who want to have full control over their wi-fi hardware directly from the command line in OS X.

With that in mind, here is how to access the amazingly useful yet little-known airport tool, and how you can use it for some networking tasks too.

In case you’re wondering, yes the command line airport tool exists in nearly all versions of OS X, even modern versions that stopped calling wireless networking ‘airport’ and refer to it as Wi-Fi. OK let’s begin.

First, Get Easier Access to airport Wi-Fi Tool

The first thing you’ll want to do is create a symbolic link to the airport command, because it is situated in a very inconvenient location with a deep path, this helps for quick usage. Doing so is very easy, in the Terminal type the following:

sudo ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/sbin/airport

The above may be a bit hard to read on some browsers, so alternatively you can use the following (it does the same thing, just split into two commands):

$ cd /usr/sbin $ sudo ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport

Whichever method you go with, the sudo command will prompt you for a root password, enter it and hit return.

Yes, that giant cryptic path through the depths of OS X is where Apple hid the wonderful airport utility, but by running the above command you have just linked that long path to the much shorter ‘airport’ , great.

Using the airport Wireless Tool in Mac OS X Command Line

Now that you have quick and easy access to airport with the above symbolic link, you can start using the airport tool.

For starters, you’ll probably find the -I flag and -S flags to be most useful and informative. Thus, type airport -I at the Terminal prompt, which will return something like the following:

$ airport -I commQuality: 75 rawQuality: 59 avgSignalLevel: -40 avgNoiseLevel: -97 linkStatus: ESS portType: Client lastTxRate: 11 maxRate: 11 lastAssocStatus: 1 BSSID: 00:06:5b:2a:37:10 SSID: OSXNetwork Security: none $

Displayed is detailed information on wireless signal quality, noise, security, and other WiFi network attributes.

The airport command is more powerful than just being able to list information on the current wireless network though, you can actually manually adjust any wi-fi settings, network card settings, troubleshoot networks, change security types used on a connection, capture packets into a pcap file, join and leae networks, disassociate from a wifi network, prioritize routers and networks, see signal strength and interference, adjust wi-fi hardware drivers, and perform a huge variety of network troubleshooting functions too. This is easily one of the most powerful ways to interact with a wireless card on a Mac.

airport wi-fi network command in Mac OS X

While there is no manual page for the airport command, attaching the -h or –help flag to the command to will issue a brief list of flags and explanations of their function. You can also just run ‘airport’ at the OS X command line to get the full help file, shown below:

$ airport
Usage: airport [interface] [verb] [options]

[interface]
If an interface is not specified, airport will use the first AirPort interface on the system.

[verb is one of the following:
prefs If specified with no key value pairs, displays a subset of AirPort preferences for
the specified interface.

Preferences may be configured using key=value syntax. Keys and possible values are specified below.
Boolean settings may be configured using ‘YES’ and ‘NO’.

DisconnectOnLogout (Boolean)
JoinMode (String)
Automatic
Preferred
Ranked
Recent
Strongest
JoinModeFallback (String)
Prompt
JoinOpen
KeepLooking
DoNothing
RememberRecentNetworks (Boolean)
RequireAdmin (Boolean)
RequireAdminIBSS (Boolean)
RequireAdminNetworkChange (Boolean)
RequireAdminPowerToggle (Boolean)
WoWEnabled (Boolean)

logger Monitor the driver’s logging facility.

sniff If a channel number is specified, airportd will attempt to configure the interface
to use that channel before it begins sniffing 802.11 frames. Captures files are saved to /tmp.
Requires super user privileges.

debug Enable debug logging. A debug log setting may be enabled by prefixing it with a ‘+’, and disabled
by prefixing it with a ‘-‘.

AirPort Userland Debug Flags
DriverDiscovery
DriverEvent
Info
SystemConfiguration
UserEvent
PreferredNetworks
AutoJoin
IPC
Scan
802.1x
Assoc
Keychain
RSNAuth
WoW
P2P
Roam
BTCoex
AllUserland – Enable/Disable all userland debug flags

AirPort Driver Common Flags
DriverInfo
DriverError
DriverWPA
DriverScan
AllDriver – Enable/Disable all driver debug flags

AirPort Driver Vendor Flags
VendorAssoc
VendorConnection
AllVendor – Enable/Disable all vendor debug flags

AirPort Global Flags
LogFile – Save all AirPort logs to /var/log/wifi.log

[options] is one of the following:
No options currently defined.

Examples:

Configuring preferences (requires admin privileges)
sudo airport en1 prefs JoinMode=Preferred RememberRecentNetworks=NO RequireAdmin=YES

Sniffing on channel 1:
airport en1 sniff 1

LEGACY COMMANDS:
Supported arguments:
-c[[arg]] –channel=[[arg]] Set arbitrary channel on the card
-z –disassociate Disassociate from any network
-I –getinfo Print current wireless status, e.g. signal info, BSSID, port type etc.
-s[[arg]] –scan=[[arg]] Perform a wireless broadcast scan.
Will perform a directed scan if the optional [arg] is provided
-x –xml Print info as XML
-P –psk Create PSK from specified pass phrase and SSID.
The following additional arguments must be specified with this command:
–password=[arg] Specify a WPA password
–ssid=[arg] Specify SSID when creating a PSK
-h –help Show this help

As you can see, there is an abundance of options to interact with wireless networks by using the airport utility in OS X. Advanced Mac users should really get a kick out of this one, as it’s extremely powerful, and wildly useful. The next time you’re working on any wi-fi related task or wirelessnetworking in general, remember the awesome airport tool.

查找和扫描无线网络从Mac OS X中的命令行

一个长期隐藏机场命令行实用程序在Mac OS X深埋可用于扫描和查找可用的无线网络。这个强大的工具是网络管理员和系统管理员非常有帮助的,但它的方便,对于普通用户,以帮助发现附 ​​近的Wi-Fi路由器也是如此。

要使用此工具来寻找附近的WiFi网络,你会想要做的第一件事就是创建从机场实用程序/ usr / sbin目录,方便访问的一个符号链接。

启动终端,然后键入以下命令:

sudo ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/sbin/airport

上面的命令必须出现在一行中正常工作。输入管理员密码,以创建符号链接,该作为别名职能将在Finder中。现在,您可以使用机场命令而不冗长的路径来访问它。

如何扫描无线网络从Mac OS X的终端

现在,扫描并寻找范围内的所有无线网络,键入以下内容:

airport -s

返回将显示所有可用的无线网络及其路由器名称(SSID)的列表中,路由器地址(BSSID),信号强度(RSSI),由网络使用的信道,和安全类型。

列出的无线网络

这基本上就像一个命令行的wi-fi stumbler,揭示了可用的无线网络是在范围内。

通过观看机场-s的输出和RSSI强度,你可以以类似的方式使用机场的命令行工具将Wi-Fi诊断工具来优化无线连接

您还可以得到许多相同的详细信息,从无线网络菜单按住Option键上点击,但只会显示你一个接入点的详细信息的时间。

另外,Mac用户可以转向无线网络扫描工具,原产于OS X绊倒附近的无线网络完全在GUI中。输出将是相同的无论是无线诊断应用程序的方法,或者这里提供的命令行方式。

启用和Mac OS X中的命令行禁用AirPort无线

有时候,当最简单的解决排除故障的AirPort无线连接问题是刚刚打开的AirPort和关闭。相反,使用菜单项或系统预置的,我们可以启用和Mac OS X的终端无效的AirPort非常迅速直接。

要做到这一点,我们将使用'networksetup“命令。请注意,这里使用的“飞机场”的提法,甚至与新版本的OS X,其中Wi-Fi已不再叫的AirPort,所以忽略了从命名约定苹果公司的变化和只知道,无论涉及到Mac电脑无线联网能力。

通过在OS X命令行打开Wi-Fi关闭

网络设备名称将确定正确的语法是如何进入。

networksetup -setairportpower airport off

设备名称可以是机场,EN0,EN1等,因Mac硬件和OS X的版本,因此,您可能需要指定设备端口,而不是'机场',例如EN1 EN0或:

networksetup -setairportpower en0 off

您可以使用-getairportpower标志检查端口,如果您不确定。

通过命令行Mac OS X中打开Wi-Fi(机场)在

就像在命令行转弯的Wi-Fi关闭,您还可以切换它重新打开。像以前一样,注意设备名称:

networksetup -setairportpower airport on

再次,你可能需要指定设备EN0或EN1,而不是'机场',像这样:

networksetup -setairportpower en0 on

你不会看到该命令是成功还是失败的终端的任何确认,但如果你看AirPort菜单图标,你会看到条纹消失指示无线接口被关闭,或者重新出现,表明无线被再次激活。

我们也可以将字符串命令,一个接一个电源周期在Mac上的无线接口:

很快电源循环的无线网络连接与Mac OS X的networksetup工具

networksetup -setairportpower airport off; networksetup -setairportpower airport on

机场无线网卡似乎比任何其他方法更快地命令行工具networksetup回应,使之成为一个超高速功率的测量方法循环的无线接口。这往往是足以解决像基本的无线路由器连接问题IP冲突或发生故障的DHCP请求。

我有一个特别古怪路由器定期足以遭遇,我创建了一个别名关机后再开机我的AirPort卡,您可以通过添加以下到你的.bash_profile只是确保它是在一行做到这一点:

alias airportcycle='networksetup -setairportpower airport off; networksetup -setairportpower airport on'

现在,像任何其他的别名,你只键入“airportcycle'和无线接口将立即自行关闭并重新打开。

禁用和重新启用机场是不一样的连接到命令行的无线网络,尽管你可以做到这一点还通过使用networksetup工具。

连接到无线网络命令行

利用强大的“networksetup的效用,我们可以从连接到无线网络直接命令行的Mac OS X的语法,你需要使用完成加入网络如下:

networksetup -setairportnetwork [interface] [router SSID] [password]

举例来说,如果我连接到无线路由器认定为“机场”,“OutsideWorld”的SSID和密码的界面是“68broncos”这将是语法:

networksetup -setairportnetwork Airport OutsideWorld 68broncos

使用另一个例子,加入一个使用了en0作为Wi-Fi接口,连接到广播心不是所谓的'HiddenWiFiValley“的SSID网络的WIFI网络与现代的MacBook Air,但其中有”密码1“的密码,将会像因此:

networksetup -setairportnetwork en0 HiddenWiFiValley password1

重要的是要确定使用你的个人的Mac得到这个工作正确的接口。您可以随时使用-listallhardwareports标志,如果你不能确定,但​​需要确定设备接口名称和地址。

你可以用结合这个技巧使用别名来创建快捷方式,并省去了冗长的命令。一个例子就摆在你的.bash_profile将是:

alias publicwifi='networksetup -setairportnetwork Airport OutsideWorld 68broncos'

现在,您只需在命令行键入“publicwifi”,你会连接到指定的路由器。请记住,这将存储的无线接入点的密码以纯文本格式,因此,如果有人能够访问你的.bash_profile他们也将能够看到无线路由器的密码。

如果你想探索更多的东西networksetup所提供的,输入'人networksetup“,你会发现强大的用途,命令行工具了惊人的数量。