Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions SimpleWifi/ProfileFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ internal static string Generate(WlanAvailableNetwork network, string password)
{
string profile = string.Empty;
string template = string.Empty;
string name = Encoding.ASCII.GetString(network.dot11Ssid.SSID, 0, (int)network.dot11Ssid.SSIDLength);
string hex = GetHexString(network.dot11Ssid.SSID);
string name = Encoding.UTF8.GetString(network.dot11Ssid.SSID, 0, (int)network.dot11Ssid.SSIDLength);
string hex = GetHexString(network.dot11Ssid.SSID);

name = System.Security.SecurityElement.Escape(name);
password = System.Security.SecurityElement.Escape(password);

var authAlgo = network.dot11DefaultAuthAlgorithm;

Expand All @@ -37,25 +40,25 @@ internal static string Generate(WlanAvailableNetwork network, string password)
if (authAlgo == Dot11AuthAlgorithm.RSNA)
{
template = GetTemplate("WPA2-Enterprise-PEAP-MSCHAPv2");
profile = string.Format(template, name);
profile = string.Format(template, name, hex);
}
else // PSK
{
template = GetTemplate("WPA2-PSK");
profile = string.Format(template, name, password);
profile = string.Format(template, name, hex, password);
}
break;
case Dot11CipherAlgorithm.TKIP:
#warning Robin: Not sure WPA uses RSNA
if (authAlgo == Dot11AuthAlgorithm.RSNA)
{
template = GetTemplate("WPA-Enterprise-PEAP-MSCHAPv2");
profile = string.Format(template, name);
profile = string.Format(template, name, hex);
}
else // PSK
{
template = GetTemplate("WPA-PSK");
profile = string.Format(template, name, password);
profile = string.Format(template, name, hex, password);
}

break;
Expand Down
2 changes: 1 addition & 1 deletion SimpleWifi/ProfileXML/OPEN.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0"?>
<?xml version="1.0" encoding="utf-8"?>
<WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1">
<name>{0}</name>
<SSIDConfig>
Expand Down
2 changes: 1 addition & 1 deletion SimpleWifi/ProfileXML/WEP.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0"?>
<?xml version="1.0" encoding="utf-8"?>
<WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1">
<name>{0}</name>
<SSIDConfig>
Expand Down
3 changes: 2 additions & 1 deletion SimpleWifi/ProfileXML/WPA-Enterprise-PEAP-MSCHAPv2.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?xml version="1.0" encoding="us-ascii"?>
<?xml version="1.0" encoding="utf-8"?>
<WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1">
<name>{0}</name>
<SSIDConfig>
<SSID>
<hex>{1}</hex>
<name>{0}</name>
</SSID>
</SSIDConfig>
Expand Down
3 changes: 2 additions & 1 deletion SimpleWifi/ProfileXML/WPA-Enterprise-TLS.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?xml version="1.0" encoding="us-ascii"?>
<?xml version="1.0" encoding="utf-8"?>
<WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1">
<name>{0}</name>
<SSIDConfig>
<SSID>
<hex>{1}</hex>
<name>{0}</name>
</SSID>
<nonBroadcast>false</nonBroadcast>
Expand Down
7 changes: 4 additions & 3 deletions SimpleWifi/ProfileXML/WPA-PSK.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?xml version="1.0" encoding="us-ascii"?>
<?xml version="1.0" encoding="utf-8"?>
<WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1">
<name>{0}</name>
<SSIDConfig>
<SSID>
<name>{0}</name>
<hex>{1}</hex>
<name>{0}</name>
</SSID>
</SSIDConfig>
<connectionType>ESS</connectionType>
Expand All @@ -19,7 +20,7 @@
<sharedKey>
<keyType>passPhrase</keyType>
<protected>false</protected>
<keyMaterial>{1}</keyMaterial>
<keyMaterial>{2}</keyMaterial>
</sharedKey>
</security>
</MSM>
Expand Down
3 changes: 2 additions & 1 deletion SimpleWifi/ProfileXML/WPA2-Enterprise-PEAP-MSCHAPv2.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?xml version="1.0" encoding="us-ascii"?>
<?xml version="1.0" encoding="utf-8"?>
<WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1">
<name>{0}</name>
<SSIDConfig>
<SSID>
<hex>{1}</hex>
<name>{0}</name>
</SSID>
</SSIDConfig>
Expand Down
3 changes: 2 additions & 1 deletion SimpleWifi/ProfileXML/WPA2-Enterprise-TLS.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?xml version="1.0" encoding="us-ascii"?>
<?xml version="1.0" encoding="utf-8"?>
<WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1">
<name>{0}</name>
<SSIDConfig>
<SSID>
<hex>{1}</hex>
<name>{0}</name>
</SSID>
</SSIDConfig>
Expand Down
5 changes: 3 additions & 2 deletions SimpleWifi/ProfileXML/WPA2-PSK.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?xml version="1.0" encoding="us-ascii"?>
<?xml version="1.0" encoding="utf-8"?>
<WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1">
<name>{0}</name>
<SSIDConfig>
<SSID>
<hex>{1}</hex>
<name>{0}</name>
</SSID>
</SSIDConfig>
Expand All @@ -19,7 +20,7 @@
<sharedKey>
<keyType>passPhrase</keyType>
<protected>false</protected>
<keyMaterial>{1}</keyMaterial>
<keyMaterial>{2}</keyMaterial>
</sharedKey>
</security>
</MSM>
Expand Down