Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to connect to a Wifi that requests for a network security key using Windows Native Wifi Functions?

I'm developing a way to connect to a Wifi using VS2010 and currently stuck on how to make it connect with a network security key. I am able to enumerate all the Wifi hotspot in my area and get their SSID, MAC addresses, etc using Windows Native Wifi Functions (WlanOpenHandle, WlanEnumInterfaces, WlanQueryInterface, WlanGetNetworkBssList). I've already read about WlanConnect() on MSDN but I'm still clueless. Can you give me some hints that would make the code connect to a Wifi that asks for a network security key?

like image 362
aaa Avatar asked Dec 19 '25 15:12

aaa


1 Answers

Assuming you have at least one saved Wifi connection run the command

netsh wlan export profile

This will export all your Wifi profiles as XML files in the current directory.

When you call WlanConnect you can supply a literal XML profile string in the WLAN_CONNECTION_PARAMETERS structure if wLanConnectionMode is set to wlan_connection_mode_temporary_profile.

If you can use the XML from one of your exported profiles to connect successfully to a secured network, then presumably you should be able to alter the XML and use the same technique to connect to new networks.

I've never tried this, and I've no idea what encoding is used for the key stored in the XML, but it seems like a possible way of solving your problem.

like image 105
arx Avatar answered Dec 22 '25 05:12

arx



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!