8

Would it be possible to emulate a Wi-Fi Protected Setup Server protocol on an Android device?

This way when using the device as a portable Hotspot, I could use a strong password and allow clients to connect using the WPS push button feature.

  • Don't use WPS because it has security vulnerability. – QkiZ Jan 19 '16 at 18:03
  • 4
    @QkiZ: that's why I want to use it, I'm a security researcher :D – enrico.bacis Jan 19 '16 at 18:05
0

Needs to add the string (wps_state, eap_server) in the following files

system/netd/server/SoftapController.cpp

int SoftapController::setSoftap(int argc, char *argv[])
{
int hidden = 0;
int channel = AP_CHANNEL_DEFAULT;

int wps_state = 2;

if (argc < 5) {
ALOGE("Softap set is missing arguments. Please use:");
ALOGE("softap <wlan iface> <SSID> <hidden/broadcast> <channel> <wpa2?-psk|open> <passphrase>");
return ResponseCode::CommandSyntaxError;
}

if (!strcasecmp(argv[4], "hidden"))
hidden = 1;

if (argc >= 5) {
channel = atoi(argv[5]);
if (channel <= 0)
channel = AP_CHANNEL_DEFAULT;
}

std::string wbuf(StringPrintf("interface=%s\n"
"driver=nl80211\n"
"ctrl_interface=/data/misc/wifi/hostapd\n"
"ssid=%s\n"
"channel=%d\n"
"ieee80211n=1\n"
"hw_mode=%c\n"
"ignore_broadcast_ssid=%d, **eap_server = 1, wps_state = %d**\n",
argv[2], argv[3], channel, (channel <= 14) ? 'g' : 'a', hidden,**wps_state**));

std::string fbuf;
if (argc > 7) {
char psk_str[2*SHA256_DIGEST_LENGTH+1];
if (!strcmp(argv[6], "wpa-psk")) {
if (!generatePsk(argv[3], argv[7], psk_str)) {
return ResponseCode::OperationFailed;
}
fbuf = StringPrintf("%swpa=3\nwpa_pairwise=TKIP CCMP\nwpa_psk=%s\n", wbuf.c_str(), psk_str);
} else if (!strcmp(argv[6], "wpa2-psk")) {
if (!generatePsk(argv[3], argv[7], psk_str)) {
return ResponseCode::OperationFailed;
}
fbuf = StringPrintf("%swpa=2\nrsn_pairwise=CCMP\nwpa_psk=%s\n", wbuf.c_str(), psk_str);
} else if (!strcmp(argv[6], "open")) {

fbuf = wbuf;
}
} else if (argc > 6) {
if (!strcmp(argv[6], "open")) {
fbuf = wbuf;
}
} else {
fbuf = wbuf;
}

if (!WriteStringToFile(fbuf, HOSTAPD_CONF_FILE, 0660, AID_SYSTEM, AID_WIFI)) {
ALOGE("Cannot write to \"%s\": %s", HOSTAPD_CONF_FILE, strerror(errno));
return ResponseCode::OperationFailed;
}
return ResponseCode::SoftapStatusResult;
}

Testing

hostapd_cli  wps_pbc

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.