WPA_Suppliant简介

1.WPA_Supplicant介绍

WPA_Supplicant:开源项目源码、它主要是用来支持WEP,WPA/WPA2无线协议和加密认证的,而实际上的工作内容是通过与驱动交互上报数据给用户而用户可以通过socket发送命令给wpa_supplicant调动驱动来对WiFi芯片操作。简单的说,wpa_supplicant就是WiFi驱动和上层用户的中转站外加对协议和加密认证的支持。

WPA_Supplicant是 WPA/WPA2 认证的客户端,同时也适用于 WEAP,即WPA_supplicant实现了WPA密钥与WPA认证及使用认证服务器Radius上的EAP认证的协商。

WPA_Supplicant被设计为一个运行在后台的守护进程来控制无线的连接,支持与WPA_cli前端程序的分离WPA_Supplicant分成两部分:WPA_cli及WPA_Supplicant.conf(配置文件)

1.1 WPA_Supplicant配置文件

WPA_Supplicant配置文件中包括两部分:全局参数、网络块

1.1.1 全局参数

使用如下形式来描述,具体的参数及值含义见下面描述:

parameter = value
  • update_config

在配置文件中设置update_config = 1,即允许wpa_supplicant更新(覆盖)配置文

如:wpa_cli进行网络配置后会同步更新到wpa_supplicant.conf中

  • ctrl_interface

wpa_cli前端程序与wpa_supplicant后台交互时使用的是socket控制接口,通常情况下/var/run/wpa_supplicant(linux使用的控制接口),udp(windows使用的控制接口)

  • ctrl_interface_group

设置允许组的成员访问ctrl_interface控制接口,可以使用group id或group name来表示,当group id=0,即ctrl_interface_group = 0表示以root用户访问WPA的配置
当ctrl_interface与ctrl_interface_group同时定义时,可以使用如下方式进行定义

DIR=/var/run/wpa_supplicant GROUP=wheel
DIR=/var/run/wpa_supplicant GROUP=0
  • eapol_version

wpa_supplicant 的实现是基于 IEEE 802.1X-2004定义的EAPOL 第二版本 的标准。然而很多AP没有正确地遵循这一新版本号,为了能让wpa_supplicant和这些接入点进行交互操作,默认eapol_version=1

When using MACsec, eapol_version shall be set to 3, which is defined in IEEE Std 802.1X-2010.

  • ap_scan

ap_scan = 1使用wpa_supplicant来扫描和选择AP(默认的方式),并会先去匹配网络块中的AP,当不匹配时才会创建新的网络(AP模式或IBSS模式)

ap_scan = 0 使用驱动来扫描及选择AP

ap_scan = 2 使用驱动来扫描和选择AP,与ap_san = 0区别在于使用的是安全策略及SSID来连接AP,即必须包含key_mgmt, pairwise, group, proto 变量,并会尝试一个一个连接网络块中的AP直到驱动反馈连接成功

ap_scan=2 should not be used with the nl80211 driver interface (the current Linux interface). ap_scan=1 is optimized work working with nl80211. For finding networks using hidden SSID, scan_ssid=1 in the network block can be used with nl80211
  • device_name

对设备的描述,UTF-8编码的32个字节

仅仅是一个别名,也可以不设置

  • device_type

设备类型,0050F204为WPS默认的OUI

1-0050F204-1 (Computer / PC)
1-0050F204-2 (Computer / Server)
5-0050F204-1 (Storage / NAS)
6-0050F204-1 (Network Infrastructure / AP)

1.1.2 网络块

Network blocks:即网络块,由多个网络组成,每一个网络以如下格式列出

	   network={
		   parameter=value
		   ...
	   }
  • disabled

0:表示使能网络块,默认的

1:关闭使能网络块,但是可以使用wpa_cli或wpa_gui来使能

  • ssid

网络块的接入点名字

  • scan_ssid

1:特定的SSID进行扫描(针对那些拒绝广播SSID的AP也就我们常说的隐藏ap)

0:默认的

network={
ssid="second ssid"
scan_ssid=1
psk="very secret passphrase"
priority=2
}
  • bssid

可选的,如果配置了则仅能连接设置的ap

  • priority

网络块的优先级,当定义了多个网络块时才生效,数值越大,优先级更高,如果未定义优先级,多个网络块时,则按照网络块的顺序连接

Please note that AP scanning with scan_ssid=1 and ap_scan=2 mode are not using this priority to select the order for scanning. Instead, they try the networks in the order that used in the configuration file
  • mode

0: 基础架构模式(管理模式),与接入点AP关联连接

1: IBSS (ad-hoc网络,点对点)

2: AP (接入点)

IBSS can only be used with key_mgmt NONE (plaintext and static WEP) and
WPA-PSK (with proto=RSN). In addition, key_mgmt=WPA-NONE (fixed group key TKIP/CCMP) is available for backwards compatibility, but its use is
deprecated. WPA-None requires following network block options:
proto=WPA, key_mgmt=WPA-NONE, pairwise=NONE, group=TKIP (or CCMP, but not both), and psk must also be set.

对于以上的特殊说明,网络块描述为如下:

network={
ssid="test adhoc"
mode=1
proto=WPA
key_mgmt=WPA-NONE
pairwise=NONE
group=TKIP
psk="secret passphrase"
}
  • key_mgmt
  1. WPA-PSK:psk必须写

  2. WPA-EAP:WPA使用eap加密算法

  3. WPA-NONE:IBSS模式下使用

  4. NONE:没有使用 WPA ;可以使用明码密匙或者静态WEP

Note: IBSS can only be used with key_mgmt NONE (plaintext and static WEP) and WPA-PSK (with proto=RSN). In addition, key_mgmt=WPA-NONE (fixed group key TKIP/CCMP) is available for backwards compatibility, but its use is deprecated. WPA-None requires following network block options:proto=WPA, key_mgmt=WPA-NONE, pairwise=NONE, group=TKIP (or CCMP, but notboth), and psk must also be set.
  • auth_alg

允许的IEEE 802.11 认证算法列表,没有设置时,自动选

  1. OPEN = 开放性系统认证(WPA/WPA2的必要选项)

  2. SHARED = 共享密匙认证(静态WEP密码的必要选项)

  3. LEAP = LEAP/Network EAP (只在LEAP中使用)

  • Pairwise

WPA点对点(单播)支持的密码表格,默认的为CCMP TKIP

  1. CCMP =AES 的CBC-MAC计数模式 [RFC 3610, IEEE 802.11i/D7.0]

  2. TKIP = 临时密钥完整性协议[IEEE 802.11i/D7.0

  3. NONE = 只使用组密码 (deprecated, should not be included if APs support pairwise keys)

  • Group

组(广播/组播)支持的密码列

  1. CCMP = AES in Counter mode with CBC-MAC [RFC 3610, IEEE 802.11i/D7.0

  2. TKIP = Temporal Key Integrity Protocol [IEEE 802.11i/D7.0]

  3. WEP104 = WEP (Wired Equivalent Privacy) with 104-bit key

  4. WEP40 = WEP (Wired Equivalent Privacy) with 40-bit key [IEEE 802.11]

默认为:CCMP TKIP WEP104 WEP40

  • proto
  1. WPA = WPA/IEEE 802.11i/D3.0
    
  2. RSN = WPA2/IEEE 802.11i 即:WP2作为RSN的别名
    

默认为:WPA RSN

  • psk

WPA预共享密钥,在WPA_psk模式下使用到,注意不能低于8位

  • wep_key0…3

静态WEP密钥,对于密钥格式为ASCII码,需要使用双引号括起

  • wep_tx_keyidx

静态WEP密钥索引

  • eap

目前仅支持MSCHAPV2

  • identity

EAP的字符标识符

  • password

EAP的密码字符串

  • ca_cert

CA 证书的路径和文件名,TLS时才需要使用到,进行双向认证

  • client_cert

客户端证书的路径和文件名,TLS时才需要使用到,进行双向认证

  • private_key

文件路径到客户端的私钥文件

  • private_key_passwd

密码私钥文件,TLS时才需要使用到,进行双向认证

详细的文档介绍见:

conf

1.2 WPA_CLI

wpa_cli:基于文本形式的与wpa_supplicant交互的前端程序,直接使用开源的工具并不需要修改就可以直接与wpa_supplicant交互。

1.2.1 命令列表

以下为wpa_cli常用命令列表

Full command Short command Description
status stat 显示当前wpa_supplicant连接状态
disconnect disc wpa_supplicant断开当前与任意一个接入点的连接
quit q 退出wpa_cli
terminate term 杀死wpa_supplicant
reconfigure recon 重新加载wpa_supplicant的配置文件
scan scan 扫描可用的接入点
scan_result scan_r 显示最后扫描的结果
list_networks list_n 显示配置的网络及状态
select_network select_n 在列表中选择一个网络,如select_network 0
enable_network enable_n 使能网络 (ie enable_network 0)
disable_network disable_n 使选择的网络不可用 (ie disable_network 0)
remove_network remove_n 从列表中移除网络 (ie remove_network 0)
add_network add_n 增加网络到列表中,网络将会自动创建
set_network set_n 设置网络的参数
get_network get_n 获取网络的配置
save_config save_c 保存网络配置
发布了100 篇原创文章 · 获赞 42 · 访问量 4万+

猜你喜欢

转载自blog.csdn.net/Hh20161314/article/details/104505125