From a668362986b29385986f9997963ca8bb9f2270b8 Mon Sep 17 00:00:00 2001 From: rofl0r Date: Tue, 25 Jan 2022 18:15:56 +0000 Subject: [PATCH] wash: add support for device_password_id in json mode this field, if present, and having the value 0x0004 indicates that the push button method was activated. ref: https://github.com/wiire-a/pixiewps/issues/107 --- src/libwps/libwps.c | 12 ++++++++++++ src/libwps/libwps.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/src/libwps/libwps.c b/src/libwps/libwps.c index d6256d7..cbaf2f1 100755 --- a/src/libwps/libwps.c +++ b/src/libwps/libwps.c @@ -109,6 +109,13 @@ char *wps_data_to_json(const char*bssid, const char *ssid, int channel, int rssi json_str = append_and_free(old, buf, 1); old = json_str; } + if(*wps->device_password_id) { + tmp = sanitize_string(wps->device_password_id); + nl = snprintf(buf, sizeof buf, "\"wps_device_password_id\" : \"%s\", ", tmp); + free(tmp); + json_str = append_and_free(old, buf, 1); + old = json_str; + } if(*wps->ssid) { tmp = sanitize_string(wps->ssid); nl = snprintf(buf, sizeof buf, "\"wps_ssid\" : \"%s\", ", tmp); @@ -248,6 +255,7 @@ int parse_wps_tag(const u_char *tags, size_t len, struct libwps_data *wps) MODEL_NAME, MODEL_NUMBER, DEVICE_NAME, + DEVICE_PASSWORD_ID, SSID, UUID, SERIAL, @@ -319,6 +327,10 @@ int parse_wps_tag(const u_char *tags, size_t len, struct libwps_data *wps) src = hex2str(el, el_len); ptr = wps->selected_registrar_config_methods; break; + case DEVICE_PASSWORD_ID: + src = hex2str(el, el_len); + ptr = wps->device_password_id; + break; case RESPONSE_TYPE: src = hex2str(el, el_len); ptr = wps->response_type; diff --git a/src/libwps/libwps.h b/src/libwps/libwps.h index c8355d0..342a7d3 100755 --- a/src/libwps/libwps.h +++ b/src/libwps/libwps.h @@ -39,6 +39,7 @@ struct libwps_data char model_name[LIBWPS_MAX_STR_LEN]; char model_number[LIBWPS_MAX_STR_LEN]; char device_name[LIBWPS_MAX_STR_LEN]; + char device_password_id[LIBWPS_MAX_STR_LEN]; char ssid[LIBWPS_MAX_STR_LEN]; char uuid[LIBWPS_MAX_STR_LEN]; char serial[LIBWPS_MAX_STR_LEN]; @@ -77,6 +78,7 @@ enum wps_el_number MODEL_NAME = 0x1023, MODEL_NUMBER = 0x1024, DEVICE_NAME = 0x1011, + DEVICE_PASSWORD_ID = 0x1012, SSID = 0x1045, UUID = 0x1047, SERIAL = 0x1042,