Mac使用Airport获取附近可用Wi-Fi

MacOS自带的命令可以获取附近Wi-Fi的详细信息。首先我们需要把命令加到环境变量中:

Last login: Sat Oct 26 10:25:45 on ttys000
➜  ~ sudo ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/local/bin/airport

Password:
➜  ~

重启终端,就可以使用airport命令了:

➜  ~ airport
Usage: airport   

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

     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[] --channel=[]    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[] --scan=[]       Perform a wireless broadcast scan.
                   Will perform a directed scan if the optional  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=  Specify a WPA password
                                  --ssid=      Specify SSID when creating a PSK
 -h        --help               Show this help

其中-s参数可以列出当前所有能发现的wifi:

➜  ~ airport -s
                            SSID BSSID             RSSI CHANNEL HT CC SECURITY (auth/unicast/group)
                    小房间_5G 50:d2:f5:61:f4:cb -90  157     Y  CN WPA(PSK/TKIP,AES/TKIP) WPA2(PSK/TKIP,AES/TKIP)
                   ChinaNet-n9HF d0:0f:6d:d3:96:fb -88  9       Y  -- WPA(PSK/AES,TKIP/TKIP) WPA2(PSK/AES,TKIP/TKIP)
                    CMCC-gbkA-5G b4:d0:a9:02:be:c1 -87  52      Y  CN WPA(PSK/TKIP,AES/TKIP) WPA2(PSK/TKIP,AES/TKIP)
                ChinaNet-KEpF-5G fc:94:ce:51:e0:86 -84  149     Y  CN WPA2(PSK/TKIP,AES/TKIP)
                        jetum-5G cc:2d:21:38:a0:e5 -82  40      Y  -- WPA(PSK/AES/AES) WPA2(PSK/AES/AES)
                       myhome_5G 04:d4:c4:b8:30:9c -80  157     Y  -- WPA2(PSK/AES/AES)
                   ChinaNet-jU5G 00:be:9e:16:e3:3d -78  13      Y  CN WPA(PSK/AES/AES) WPA2(PSK/AES/AES)
                   ChinaNet-KEpF fc:94:ce:51:e0:82 -77  9       Y  CN WPA2(PSK/TKIP,AES/TKIP)
                   ChinaNet-y4bU ec:8a:c7:1c:2f:ed -77  8,+1    Y  CN WPA(PSK/AES/AES) WPA2(PSK/AES/AES)
                   ChinaNet-6P3X 00:1f:8f:2f:5f:0c -76  3       Y  -- WPA(PSK/TKIP/TKIP) WPA2(PSK/AES/TKIP)
                      358-58-701 c0:61:18:a3:ce:38 -67  11,-1   Y  -- WPA(PSK/AES/AES) WPA2(PSK/AES/AES)
                          myhome 04:d4:c4:b8:30:98 -67  11      Y  -- WPA2(PSK/AES/AES)
                      HUAWEI-XLJ 00:34:fe:63:0b:8c -64  5       Y  -- WPA(PSK/TKIP,AES/TKIP) WPA2(PSK/TKIP,AES/TKIP)
                   ChinaNet-z6j9 d0:60:8c:52:18:4b -63  4       Y  -- WPA(PSK/TKIP,AES/TKIP) WPA2(PSK/TKIP,AES/TKIP)
                       小房间 50:d2:f5:61:f4:ca -62  11      Y  CN WPA(PSK/TKIP,AES/TKIP) WPA2(PSK/TKIP,AES/TKIP)
                             xdy 08:1f:71:22:5d:b1 -50  2,+1    Y  CN WPA(PSK/AES/AES) WPA2(PSK/AES/AES)
                          ziroom 54:75:95:ae:c4:07 -34  1,+1    Y  CN WPA(PSK/AES/AES) WPA2(PSK/AES/AES)
                          ziroom 54:75:95:ae:c4:09 -46  149     Y  CN WPA(PSK/AES/AES) WPA2(PSK/AES/AES)

你可能感兴趣的:(Mac使用Airport获取附近可用Wi-Fi)