mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2024-11-28 18:28:23 -05:00
Add parsed information from WPS IE(s) into scan results
This makes it easier for external programs to show WPS information since they do not need to parse the WPS IE themselves anymore.
This commit is contained in:
parent
e9a2bca6f5
commit
611ed49118
101
src/wps/wps.c
101
src/wps/wps.c
@ -356,3 +356,104 @@ void wps_free_pending_msgs(struct upnp_pending_message *msgs)
|
||||
os_free(prev);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int wps_attr_text(struct wpabuf *data, char *buf, char *end)
|
||||
{
|
||||
struct wps_parse_attr attr;
|
||||
char *pos = buf;
|
||||
int ret;
|
||||
|
||||
if (wps_parse_msg(data, &attr) < 0)
|
||||
return -1;
|
||||
|
||||
if (attr.wps_state) {
|
||||
if (*attr.wps_state == WPS_STATE_NOT_CONFIGURED)
|
||||
ret = os_snprintf(pos, end - pos,
|
||||
"wps_state=unconfigured\n");
|
||||
else if (*attr.wps_state == WPS_STATE_CONFIGURED)
|
||||
ret = os_snprintf(pos, end - pos,
|
||||
"wps_state=configured\n");
|
||||
else
|
||||
ret = 0;
|
||||
if (ret < 0 || ret >= end - pos)
|
||||
return pos - buf;
|
||||
pos += ret;
|
||||
}
|
||||
|
||||
if (attr.ap_setup_locked && *attr.ap_setup_locked) {
|
||||
ret = os_snprintf(pos, end - pos,
|
||||
"wps_ap_setup_locked=1\n");
|
||||
if (ret < 0 || ret >= end - pos)
|
||||
return pos - buf;
|
||||
pos += ret;
|
||||
}
|
||||
|
||||
if (attr.selected_registrar && *attr.selected_registrar) {
|
||||
ret = os_snprintf(pos, end - pos,
|
||||
"wps_selected_registrar=1\n");
|
||||
if (ret < 0 || ret >= end - pos)
|
||||
return pos - buf;
|
||||
pos += ret;
|
||||
}
|
||||
|
||||
if (attr.dev_password_id) {
|
||||
ret = os_snprintf(pos, end - pos,
|
||||
"wps_device_password_id=%u\n",
|
||||
WPA_GET_BE16(attr.dev_password_id));
|
||||
if (ret < 0 || ret >= end - pos)
|
||||
return pos - buf;
|
||||
pos += ret;
|
||||
}
|
||||
|
||||
if (attr.sel_reg_config_methods) {
|
||||
ret = os_snprintf(pos, end - pos,
|
||||
"wps_selected_registrar_config_methods="
|
||||
"0x%04x\n",
|
||||
WPA_GET_BE16(attr.sel_reg_config_methods));
|
||||
if (ret < 0 || ret >= end - pos)
|
||||
return pos - buf;
|
||||
pos += ret;
|
||||
}
|
||||
|
||||
if (attr.primary_dev_type) {
|
||||
ret = os_snprintf(pos, end - pos,
|
||||
"wps_primary_device_type=%u-%08x-%u\n",
|
||||
WPA_GET_BE16(attr.primary_dev_type),
|
||||
WPA_GET_BE32(&attr.primary_dev_type[2]),
|
||||
WPA_GET_BE16(&attr.primary_dev_type[6]));
|
||||
if (ret < 0 || ret >= end - pos)
|
||||
return pos - buf;
|
||||
pos += ret;
|
||||
}
|
||||
|
||||
if (attr.dev_name) {
|
||||
char *str = os_malloc(attr.dev_name_len + 1);
|
||||
size_t i;
|
||||
if (str == NULL)
|
||||
return pos - buf;
|
||||
for (i = 0; i < attr.dev_name_len; i++) {
|
||||
if (attr.dev_name[i] < 32)
|
||||
str[i] = '_';
|
||||
else
|
||||
str[i] = attr.dev_name[i];
|
||||
}
|
||||
str[i] = '\0';
|
||||
ret = os_snprintf(pos, end - pos, "wps_device_name=%s\n", str);
|
||||
os_free(str);
|
||||
if (ret < 0 || ret >= end - pos)
|
||||
return pos - buf;
|
||||
pos += ret;
|
||||
}
|
||||
|
||||
if (attr.config_methods) {
|
||||
ret = os_snprintf(pos, end - pos,
|
||||
"wps_config_methods=0x%04x\n",
|
||||
WPA_GET_BE16(attr.config_methods));
|
||||
if (ret < 0 || ret >= end - pos)
|
||||
return pos - buf;
|
||||
pos += ret;
|
||||
}
|
||||
|
||||
return pos - buf;
|
||||
}
|
||||
|
@ -589,5 +589,6 @@ struct oob_nfc_device_data * wps_get_oob_nfc_device(char *device_name);
|
||||
int wps_get_oob_method(char *method);
|
||||
int wps_process_oob(struct wps_context *wps, struct oob_device_data *oob_dev,
|
||||
int registrar);
|
||||
int wps_attr_text(struct wpabuf *data, char *buf, char *end);
|
||||
|
||||
#endif /* WPS_H */
|
||||
|
@ -1547,6 +1547,14 @@ static int wpa_supplicant_ctrl_iface_bss(struct wpa_supplicant *wpa_s,
|
||||
return pos - buf;
|
||||
pos += ret;
|
||||
|
||||
#ifdef CONFIG_WPS
|
||||
ie = (const u8 *) (bss + 1);
|
||||
ret = wpas_wps_scan_result_text(ie, bss->ie_len, pos, end);
|
||||
if (ret < 0 || ret >= end - pos)
|
||||
return pos - buf;
|
||||
pos += ret;
|
||||
#endif /* CONFIG_WPS */
|
||||
|
||||
return pos - buf;
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
#include "common.h"
|
||||
#include "ieee802_11_defs.h"
|
||||
#include "ieee802_11_common.h"
|
||||
#include "wpa_common.h"
|
||||
#include "config.h"
|
||||
#include "eap_peer/eap.h"
|
||||
@ -983,3 +984,19 @@ int wpas_wps_searching(struct wpa_supplicant *wpa_s)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int wpas_wps_scan_result_text(const u8 *ies, size_t ies_len, char *buf,
|
||||
char *end)
|
||||
{
|
||||
struct wpabuf *wps_ie;
|
||||
int ret;
|
||||
|
||||
wps_ie = ieee802_11_vendor_ie_concat(ies, ies_len, WPS_DEV_OUI_WFA);
|
||||
if (wps_ie == NULL)
|
||||
return 0;
|
||||
|
||||
ret = wps_attr_text(wps_ie, buf, end);
|
||||
wpabuf_free(wps_ie);
|
||||
return ret;
|
||||
}
|
||||
|
@ -47,6 +47,8 @@ int wpas_wps_scan_pbc_overlap(struct wpa_supplicant *wpa_s,
|
||||
struct wpa_ssid *ssid);
|
||||
void wpas_wps_notify_scan_results(struct wpa_supplicant *wpa_s);
|
||||
int wpas_wps_searching(struct wpa_supplicant *wpa_s);
|
||||
int wpas_wps_scan_result_text(const u8 *ies, size_t ies_len, char *pos,
|
||||
char *end);
|
||||
|
||||
#else /* CONFIG_WPS */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user