linux sh查看wifi状态,adb结合wpa_cli查看wifi状态命令集

本文详细介绍了通过adb shell wpa_cli命令行工具管理Android设备上的WIFI连接的各种操作,包括查看WIFI状态、连接/断开网络、扫描网络、获取信号强度等。此外,还展示了如何获取和设置网络参数,如BSSID、SSID、加密方式、IP地址等,以及进行网络诊断和性能评估。
摘要由CSDN通过智能技术生成

1.status  查看当前的WIFI状态

adb shell wpa_cli -iwlan0 -g@android:wpa_wlan0 IFNAME=wlan0 status

bssid=70:62:b8:62:2e:c4   // 一个长度为48位二进制的数字标志,用于识别不同的BSS(Basic Service Set)基本服务集,主要用于过滤

freq=2412(1)  2417(2)  2422(3) 2427(4) 2432(5) 2437(6) 2442(7) 2447(8) 2452(9) 2457(10) 2462(11) 2467(12) 2472(13)  //与热点连接的信道

ssid=cts //当前连接的热点AP的名称

id=2   // 当前热点AP记录下STA的编号

mode=station   // 当前设备的工作模式为STA

pairwise_cipher=CCMP 【NONE】//表示当前热点AP接受的安全加密算法  CCMP表示的是    密码块消息完整性协议

group_cipher=TKIP 【CCMP NONE】    //group_cipher 表示当前热点AP接受的安全加密算法 TKIP 表示的是  临时密码完整性协议

key_mgmt=WPA2-PSK 【NONE】  //认证密钥管理协议

wpa_state=COMPLETED 【SCANNING DISCONNECTED】//STA的连接状态

ip_address=192.168.235.18  //热点分配给STA的IP地址(任意分配)

p2p_device_address=5e:a8:6a:e5:cb:cd  // 当前设备作为 WIFI直连时的MAC地址?  是STA的MAC地址加了2 从5e->5c 其后数字一样?

address=5c:a8:6a:e5:cb:cd        //STA的MAC地址

uuid=6885e701-c4a3-51c9-bd4d-98b0a5204df2    //全通通用唯一设备标识符  固定

2.terminate   立即关闭 wpa_supplicant   // 关闭WIFI

adb shell wpa_cli -iwlan0 -g@android:wpa_wlan0 IFNAME=wlan0 terminate

3.list_networks  连接过的WIFI

adb shell wpa_cli -iwlan0 -g@android:wpa_wlan0 IFNAME=wlan0 list_networks

network id / ssid / bssid / flags

0       and-Business    any

1       CMCC-WEB        any

2       cts     any

3       MYA-L03_亏哦UK大酒店    any

4       HUAWEI_MYA_3afb any     [CURRENT]

4.select_network 设置连接到热点 nitid对应的热点   先断开连接的热点 再去连接netid

adb shell wpa_cli -iwlan0 -g@android:wpa_wlan0 IFNAME=wlan0 select_network 2

5.disable_network 断开与热点的连接  断开后又会默认连接上

adb shell wpa_cli -iwlan0 -g@android:wpa_wlan0 IFNAME=wlan0 disable_network 5

6.signal_poll      get signal parameters

adb shell wpa_cli -iwlan0 -g@android:wpa_wlan0 IFNAME=wlan0 signal_poll

RSSI=-23

LINKSPEED=65

NOISE=9999

FREQUENCY=2442

7.pktcnt_poll  get TX/RX packet counters

adb shell wpa_cli -iwlan0 -g@android:wpa_wlan0 IFNAME=wlan0 pktcnt_poll

TXGOOD=1146

TXBAD=1

RXGOOD=0

8. DRIVER MACADDR 获得MAC地址

adb shell wpa_cli -iwlan0 -g@android:wpa_wlan0 IFNAME=wlan0 DRIVER MACADDR

Macaddr = 5c:a8:6a:e5:cb:cd

9.reassociate 重连接

adb shell wpa_cli -iwlan0 -g@android:wpa_wlan0 IFNAME=wlan0 reassociate

10.reattach  重连接当前已连接的WIFI

adb shell wpa_cli -iwlan0 -g@android:wpa_wlan0 IFNAME=wlan0 reattach

11.ifname   查看当前使用的网卡

adb shell wpa_cli -iwlan0 -g@android:wpa_wlan0 IFNAME=wlan0 ifname

wlan0

12.interface 当前可用接口

adb shell wpa_cli -iwlan0 -g@android:wpa_wlan0 IFNAME=wlan0 interface

Available interfaces:

p2p0

wlan0

13.ping  检测Supplicant是否正常

adb shell wpa_cli -iwlan0 -g@android:wpa_wlan0 IFNAME=wlan0 ping

PONG

14.add_network  保存一个网络(参数未知)

adb shell wpa_cli -iwlan0 -g@android:wpa_wlan0 IFNAME=wlan0 add_network XXXX

15.remove_network

adb shell wpa_cli -iwlan0 -g@android:wpa_wlan0 IFNAME=wlan0 remove_network 6

16.disconnect  段开当前连接

adb shell wpa_cli -iwlan0 -g@android:wpa_wlan0 IFNAME=wlan0 disconnect

17.reconnect 再次连接 如果已经连接则不执行

adb shell wpa_cli -iwlan0 -g@android:wpa_wlan0 IFNAME=wlan0 reconnect

18.scan 启动扫描

adb shell wpa_cli -iwlan0 -g@android:wpa_wlan0 IFNAME=wlan0 scan

19.scan_results 得到最新的扫描结果

adb shell wpa_cli -iwlan0 -g@android:wpa_wlan0 IFNAME=wlan0 scan_results

bssid / frequency / signal level / flags / ssid

70:62:b8:62:2e:c4       2412    -68     [WPA-PSK-CCMP+TKIP][WPA2-PSK-CCMP+TKIP][WPS][ESS]       cts

02:08:22:76:b5:73       2417    -24     [WPA2-PSK-CCMP][WPS][ESS]       Lenovo S1La40

06:19:70:27:ca:96       2462    -54     [WPA2-EAP-CCMP-preauth][ESS]    CMCC

00:23:69:ce:58:b0       2412    -62     [WPA-PSK-TKIP][ESS]     LJ-7W1-V3-Linksys

06:19:70:00:32:c0       2472    -61     [WPA2-EAP-CCMP-preauth][ESS]    CMCC

00:22:aa:9e:31:48       2452    -71     [WPA-PSK-CCMP+TKIP][WPA2-PSK-CCMP+TKIP][ESS]    BW-wx20s

b8:e8:56:48:0e:ea       2462    -85     [WPA2-PSK-CCMP][ESS]    KuriMBP

00:19:70:27:ca:96       2462    -55     [ESS]   CMCC-WEB

16:19:70:27:ca:96       2462    -53     [ESS]   and-Business

16:19:70:00:32:c0       2472    -60     [ESS]   and-Business

16:19:70:00:30:2e       2437    -74     [ESS]   and-Business

00:19:70:00:32:c0       2472    -60     [ESS]   CMCC-WEB

02:08:22:da:90:11       2417    -25     [WPS][ESS]      HUAWEI_MYA_3afb

06:19:70:00:30:2e       2437    -65     [WPA2-EAP-CCMP-preauth][ESS]    CMCC

00:19:70:00:30:2e       2437    -73     [ESS]   CMCC-WEB

44:6d:57:99:38:a1       2412    -78     [WPA2-PSK-CCMP][ESS]    whr360

02:08:22:c6:74:1a       2437    -75     [WPA2-PSK-CCMP][WPS][ESS]       AAA5860

00:19:70:00:30:d6       2412    -78     [ESS]   CMCC-WEB

06:19:70:00:30:d6       2412    -78     [WPA2-EAP-CCMP-preauth][ESS]    CMCC

06:19:70:00:30:88       2472    -82     [WPA2-EAP-CCMP-preauth][ESS]    CMCC

16:19:70:00:30:88       2472    -80     [ESS]   and-Business

12:0e:0e:20:63:b7       2437    -78     [WPA-PSK-CCMP+TKIP][WPA2-PSK-CCMP+TKIP][ESS]    VIP-guest

16:19:70:00:30:d6       2412    -78     [ESS]   and-Business

10:0e:0e:20:64:ca       2462    -86     [ESS]   HQ_guest

00:23:69:ce:58:1d       2437    -81     [WPA-PSK-CCMP+TKIP][WPA2-PSK-CCMP+TKIP][ESS]    LJ-Meeting 01

00:22:aa:9e:31:24       2412    -91     [WPA-PSK-CCMP+TKIP][WPA2-PSK-CCMP+TKIP][ESS]    BW-wx20s

00:19:70:00:30:88       2472    -82     [ESS]   CMCC-WEB

22:0e:0e:20:63:b7       2437    -83     [ESS]   HQ_Office

20.bss 查看热点详情

adb shell wpa_cli -iwlan0 -g@android:wpa_wlan0 IFNAME=wlan0 bss 70:62:b8:62:2e:c4

adb shell wpa_cli -iwlan0 -g@android:wpa_wlan0 IFNAME=wlan0 bss cts

id=0

bssid=70:62:b8:62:2e:c4  //BSSID 唯一标志集合

freq=2412  //信道

beacon_int=100   //beacon帧间隔  用于通知AP的状态

capabilities=0x0411  网络接入性能

qual=0

noise=-89  //噪音程度   数值越大 噪音越大

level=-63   //信号程度   数值越大 信号越大

tsf=0000519432862866  //时间同步

age=11

ie=0003637473010882848b962430486c0301012a01042f010430180100000fac020200000fac040

00fac020100000fac020c0032040c1218602d1aff1917ffffff00010000000000000000000000000

000000000003d16010d16000000000000000000000000000000000000007f080000000000000040d

d870050f204104a0001101044000102103b000103104700101e88f48914be85b618487062b8622ec

710210006442d4c696e6b1023000d442d4c696e6b20526f75746572102400084449522d3836384c1

042000830303030303030301054000800060050f2040001101100084449522d3836384c100800022

78c103c0001011049000600372a000120dd090010180206001c0000dd1a0050f20101000050f2020

2000050f2040050f20201000050f202dd180050f2020101840003a4000027a4000042435e0062322

f00

flags=[WPA-PSK-CCMP+TKIP][WPA2-PSK-CCMP+TKIP][WPS][ESS]

ssid=cts

wps_state=configured

wps_primary_device_type=6-0050F204-1

wps_device_name=DIR-868L

wps_config_methods=0x278c

snr=26  //信号噪声比  越大越好  【 level - noise 】 -63-(-89) = 26

est_throughput=135000  bps   WIFI吞吐量

adb shell wpa_cli -iwlan0 -g@android:wpa_wlan0 IFNAME=wlan0 bss 02:08:22:da:90:11

ss 02:08:22:da:90:11

id=98

bssid=02:08:22:da:90:11

freq=2417

beacon_int=100

capabilities=0x0421

qual=0

noise=-89

level=-30

tsf=0000519432863304

age=64

ie=000f4855415745495f4d59415f33616662010882848b960c12182403010232043048606c2a010

02d1a300103ff000000000000000000000001000000000000000000003d160200010000000000000

00000000000000000000000007f0100dd180050f2020101800003a4000027a4000042435e0062322

f00dd180050f204104a00011010440001021049000600372a000120

flags=[WPS][ESS]

ssid=HUAWEI_MYA_3afb

wps_state=configured

snr=59   【 level - noise】 -30-(-89) = 59

est_throughput=65000   bps WIFI吞吐量

21.get_capability   = get capabilies

adb shell wpa_cli -iwlan0 -g@android:wpa_wlan0 IFNAME=wlan0 get_capability eap

MD5 TLS WFA-UNAUTH-TLS MSCHAPV2 PEAP TTLS GTC OTP SIM LEAP AKA AKA' FAST WSC PWD

adb shell wpa_cli -iwlan0 -g@android:wpa_wlan0 IFNAME=wlan0 get_capability pairwise

CCMP TKIP

adb shell wpa_cli -iwlan0 -g@android:wpa_wlan0 IFNAME=wlan0 get_capability group

CCMP TKIP WEP104 WEP40

adb shell wpa_cli -iwlan0 -g@android:wpa_wlan0 IFNAME=wlan0 get_capability key_mgmt

NONE IEEE8021X WPA-EAP WPA-PSK

adb shell wpa_cli -iwlan0 -g@android:wpa_wlan0 IFNAME=wlan0 get_capability proto

RSN WPA

adb shell wpa_cli -iwlan0 -g@android:wpa_wlan0 IFNAME=wlan0 get_capability auth_alg

OPEN SHARED LEAP

adb shell wpa_cli -iwlan0 -g@android:wpa_wlan0 IFNAME=wlan0 get_capability channels

Mode[G] Channels: 1 2 3 4 5 6 7 8 9 10 11 12 13

Mode[A] Channels: 36 40 44 48 52 56 60 64 149 153 157 161 165

Mode[B] Channels: 1 2 3 4 5 6 7 8 9 10 11 12 13

adb shell wpa_cli -iwlan0 -g@android:wpa_wlan0 IFNAME=wlan0 get_capability freq

Mode[G] Channels:

1 = 2412 MHz

2 = 2417 MHz

3 = 2422 MHz

4 = 2427 MHz

5 = 2432 MHz

6 = 2437 MHz

7 = 2442 MHz

8 = 2447 MHz

9 = 2452 MHz

10 = 2457 MHz

11 = 2462 MHz

12 = 2467 MHz

13 = 2472 MHz

Mode[A] Channels:

36 = 5180 MHz

40 = 5200 MHz

44 = 5220 MHz

48 = 5240 MHz

52 = 5260 MHz

56 = 5280 MHz

60 = 5300 MHz

64 = 5320 MHz

149 = 5745 MHz

153 = 5765 MHz

157 = 5785 MHz

161 = 5805 MHz

165 = 5825 MHz

Mode[B] Channels:

1 = 2412 MHz

2 = 2417 MHz

3 = 2422 MHz

4 = 2427 MHz

5 = 2432 MHz

6 = 2437 MHz

7 = 2442 MHz

8 = 2447 MHz

9 = 2452 MHz

10 = 2457 MHz

11 = 2462 MHz

12 = 2467 MHz

13 = 2472 MHz

adb shell wpa_cli -iwlan0 -g@android:wpa_wlan0 IFNAME=wlan0 get_capability modes

IBSS

22.relog

adb shell wpa_cli -iwlan0 -g@android:wpa_wlan0 IFNAME=wlan0 relog

OK

23.mib

adb shell wpa_cli -iwlan0 -g@android:wpa_wlan0 IFNAME=wlan0 mib   (Manager Info Base)基础数据库

dot11RSNAOptionImplemented=TRUE

dot11RSNAPreauthenticationImplemented=TRUE

dot11RSNAEnabled=FALSE

dot11RSNAPreauthenticationEnabled=FALSE

dot11RSNAConfigVersion=1

dot11RSNAConfigPairwiseKeysSupported=5

dot11RSNAConfigGroupCipherSize=0

dot11RSNAConfigPMKLifetime=43200

dot11RSNAConfigPMKReauthThreshold=70

dot11RSNAConfigNumberOfPTKSAReplayCounters=1

dot11RSNAConfigSATimeout=60

dot11RSNAAuthenticationSuiteSelected=00-00-00-0

dot11RSNAPairwiseCipherSelected=00-0f-ac-0

dot11RSNAGroupCipherSelected=00-0f-ac-0

dot11RSNAPMKIDUsed=

dot11RSNAAuthenticationSuiteRequested=00-00-00-0

dot11RSNAPairwiseCipherRequested=00-0f-ac-0

dot11RSNAGroupCipherRequested=00-0f-ac-0

dot11RSNAConfigNumberOfGTKSAReplayCounters=0

dot11RSNA4WayHandshakeFailures=0

dot1xSuppPaeState=9

dot1xSuppHeldPeriod=60

dot1xSuppAuthPeriod=30

dot1xSuppStartPeriod=30

dot1xSuppMaxStart=3

dot1xSuppSuppControlledPortStatus=Authorized

dot1xSuppBackendPaeState=2

dot1xSuppEapolFramesRx=0

dot1xSuppEapolFramesTx=2

dot1xSuppEapolStartFramesTx=0

dot1xSuppEapolLogoffFramesTx=0

dot1xSuppEapolRespFramesTx=0

dot1xSuppEapolReqIdFramesRx=0

dot1xSuppEapolReqFramesRx=0

dot1xSuppInvalidEapolFramesRx=0

dot1xSuppEapLengthErrorFramesRx=0

dot1xSuppLastEapolFrameVersion=0

dot1xSuppLastEapolFrameSource=00:00:00:00:00:00

24.help

adb shell wpa_cli -iwlan0 -g@android:wpa_wlan0 IFNAME=wlan0 help

commands:

mib = get MIB variables (dot1x, dot11)

25.license  查看版本 声明

adb shell wpa_cli -iwlan0 -g@android:wpa_wlan0 IFNAME=wlan0 license

wpa_cli v2.5-devel-6.0

26.dump 查看变量

adb shell wpa_cli -iwlan0 -g@android:wpa_wlan0 IFNAME=wlan0 dump

ctrl_interface=/data/misc/wifi/sockets

ctrl_interface_group=null

eapol_version=1

ap_scan=1

disable_scan_offload=0

fast_reauth=1

opensc_engine_path=null

pkcs11_engine_path=null

pkcs11_module_path=null

openssl_ciphers=null

pcsc_reader=null

pcsc_pin=null

external_sim=1

driver_param=use_p2p_group_interface=1

dot11RSNAConfigPMKLifetime=0

dot11RSNAConfigPMKReauthThreshold=0

dot11RSNAConfigSATimeout=0

update_config=1

device_name=full_hq6737t_66_1ha_m0

manufacturer=alps

model_name=hq6737t_66_1ha_m0

model_number=hq6737t_66_1ha_m0

serial_number=SJVBBBA681500266

config_methods=physical_display virtual_push_button

wps_cred_processing=0

p2p_listen_reg_class=0

p2p_listen_channel=0

p2p_oper_reg_class=0

p2p_oper_channel=0

p2p_go_intent=7

p2p_ssid_postfix=null

persistent_reconnect=0

p2p_intra_bss=1

p2p_group_idle=0

p2p_passphrase_len=0

p2p_add_cli_chan=0

p2p_optimize_listen_chan=0

p2p_go_ht40=0

p2p_go_vht=0

p2p_disabled=0

p2p_go_ctwindow=0

p2p_no_group_iface=1

p2p_ignore_shared_freq=0

ip_addr_go=0.0.0.0

ip_addr_mask=0.0.0.0

ip_addr_start=0.0.0.0

ip_addr_end=0.0.0.0

p2p_cli_probe=0

bss_max_count=200

bss_expiration_age=180

bss_expiration_scan_count=2

filter_ssids=0

filter_rssi=0

max_num_sta=128

disassoc_low_ack=0

hs20=0

interworking=0

access_network_type=15

pbc_in_m1=0

autoscan=null

wps_nfc_dev_pw_id=0

ext_password_backend=null

p2p_go_max_inactivity=300

auto_interworking=0

okc=0

pmf=0

dtim_period=0

beacon_int=0

ignore_old_scan_res=0

scan_cur_freq=0

sched_scan_interval=0

tdls_external_control=0

osu_dir=null

wowlan_triggers=disconnect

p2p_search_delay=500

mac_addr=0

rand_addr_lifetime=60

preassoc_mac_addr=0

key_mgmt_offload=1

passive_scan=0

reassoc_same_bss_optim=0

wps_priority=0

overlay_loaded=0

27. log_level

adb shell wpa_cli -iwlan0 -g@android:wpa_wlan0 IFNAME=wlan0 log_level

Current level: MSGDUMP

Timestamp: 0

28.reconfigure 重新配置   reconfigure = force wpa_supplicant to re-read its configuration file

adb shell wpa_cli -iwlan0 -g@android:wpa_wlan0 IFNAME=wlan0 reconfigure

29.scan_interval 设置扫描间隔

adb shell wpa_cli -iwlan0 -g@android:wpa_wlan0 IFNAME=wlan0 scan_interval 3

30.blacklist 黑名单

adb shell wpa_cli -iwlan0 -g@android:wpa_wlan0 IFNAME=wlan0 blacklist

31.DRIVER GET_STA_STATISTICS 查看手机STA信息

adb shell wpa_cli -iwlan0 -g@android:wpa_wlan0 IFNAME=wlan0 DRIVER GET_STA_STATISTICS 5c:a8:6a:e5:cb:cd

sta_addr=5c:a8:6a:e5:cb:cd

link_score=100

per=0

rssi=-110

phy=0x00000000

rate=0.0

total_cnt=0

threshold_cnt=0

fail_cnt=0

timeout_cnt=0

apt=0

aat=0

TC_buf_full_cnt=0:0:0:0

TC_sta_que_len=0:0:0:0

TC_avg_que_len=0:0:0:0

TC_cur_que_len=8:8:8:8

flag=0x00000000

reserved0=00000000 00000000 00000000 00000000

reserved1=00000000 00000000 00000000 00000000

32:set   【set 命令设置环境变量(dump里的变量)】

adb shell wpa_cli -iwlan0 -g@android:wpa_wlan0 IFNAME=wlan0  set passive_scan  1

adb shell wpa_cli -iwlan0 -g@android:wpa_wlan0 IFNAME=wlan0  set oce  1

adb shell wpa_cli -iwlan0 -g@android:wpa_wlan0 IFNAME=wlan0  set  okc  1

========================================================================================

33:get   【get 命令 查询环境变量(dump里的变量)】

adb shell wpa_cli -iwlan0 -g@android:wpa_wlan0 IFNAME=wlan0  get passive_scan

adb shell wpa_cli -iwlan0 -g@android:wpa_wlan0 IFNAME=wlan0  get oce

adb shell wpa_cli -iwlan0 -g@android:wpa_wlan0 IFNAME=wlan0  get  okc

========================================================================================

34:pmksa   【  show PMKSA cache  】

adb shell wpa_cli -iwlan0 -g@android:wpa_wlan0 IFNAME=wlan0 pmksa_flush  【 OK 】

adb shell wpa_cli -iwlan0 -g@android:wpa_wlan0 IFNAME=wlan0 pmksa

Index / AA / PMKID / expiration (in seconds) / opportunistic

1 18:64:72:21:85:c3 e447f44b4d61bcc34fd325ba1dafd038 41657 0

========================================================================================

35:preauthenticate   【 预先认证 】

adb shell wpa_cli -iwlan0 -g@android:wpa_wlan0 IFNAME=wlan0 preauthenticate 18:64:72:21:86:43

========================================================================================

36:blacklist   【 加入黑名单 】

adb shell wpa_cli -iwlan0 -g@android:wpa_wlan0 IFNAME=wlan0 blacklist 18:64:72:21:86:43

adb shell wpa_cli -iwlan0 -g@android:wpa_wlan0 IFNAME=wlan0 blacklist // 展示黑名单

adb shell wpa_cli -iwlan0 -g@android:wpa_wlan0 IFNAME=wlan0 blacklist clear  // 清楚黑名单

========================================================================================

37:log_level  [ DEBUG | INFO ]  【 设置LOG等级 】

adb shell wpa_cli -iwlan0 -g@android:wpa_wlan0 IFNAME=wlan0  log_level

adb shell wpa_cli -iwlan0 -g@android:wpa_wlan0 IFNAME=wlan0  log_level   DEBUG

adb shell wpa_cli -iwlan0 -g@android:wpa_wlan0 IFNAME=wlan0  log_level   INFO

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值