diff --git a/SimpleWifi/ProfileFactory.cs b/SimpleWifi/ProfileFactory.cs index 8b78821..41fbe6b 100644 --- a/SimpleWifi/ProfileFactory.cs +++ b/SimpleWifi/ProfileFactory.cs @@ -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; @@ -37,12 +40,12 @@ 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: @@ -50,12 +53,12 @@ internal static string Generate(WlanAvailableNetwork network, string password) 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; diff --git a/SimpleWifi/ProfileXML/OPEN.xml b/SimpleWifi/ProfileXML/OPEN.xml index aeba700..5256fe8 100644 --- a/SimpleWifi/ProfileXML/OPEN.xml +++ b/SimpleWifi/ProfileXML/OPEN.xml @@ -1,4 +1,4 @@ - + {0} diff --git a/SimpleWifi/ProfileXML/WEP.xml b/SimpleWifi/ProfileXML/WEP.xml index 9cbb5a4..d9597ab 100644 --- a/SimpleWifi/ProfileXML/WEP.xml +++ b/SimpleWifi/ProfileXML/WEP.xml @@ -1,4 +1,4 @@ - + {0} diff --git a/SimpleWifi/ProfileXML/WPA-Enterprise-PEAP-MSCHAPv2.xml b/SimpleWifi/ProfileXML/WPA-Enterprise-PEAP-MSCHAPv2.xml index 95295bd..a9c32e2 100644 --- a/SimpleWifi/ProfileXML/WPA-Enterprise-PEAP-MSCHAPv2.xml +++ b/SimpleWifi/ProfileXML/WPA-Enterprise-PEAP-MSCHAPv2.xml @@ -1,8 +1,9 @@ - + {0} + {1} {0} diff --git a/SimpleWifi/ProfileXML/WPA-Enterprise-TLS.xml b/SimpleWifi/ProfileXML/WPA-Enterprise-TLS.xml index 071320a..65e1fb1 100644 --- a/SimpleWifi/ProfileXML/WPA-Enterprise-TLS.xml +++ b/SimpleWifi/ProfileXML/WPA-Enterprise-TLS.xml @@ -1,8 +1,9 @@ - + {0} + {1} {0} false diff --git a/SimpleWifi/ProfileXML/WPA-PSK.xml b/SimpleWifi/ProfileXML/WPA-PSK.xml index 7123a5c..28794d8 100644 --- a/SimpleWifi/ProfileXML/WPA-PSK.xml +++ b/SimpleWifi/ProfileXML/WPA-PSK.xml @@ -1,9 +1,10 @@ - + {0} - {0} + {1} + {0} ESS @@ -19,7 +20,7 @@ passPhrase false - {1} + {2} diff --git a/SimpleWifi/ProfileXML/WPA2-Enterprise-PEAP-MSCHAPv2.xml b/SimpleWifi/ProfileXML/WPA2-Enterprise-PEAP-MSCHAPv2.xml index 6ae2b7a..8cc9ebc 100644 --- a/SimpleWifi/ProfileXML/WPA2-Enterprise-PEAP-MSCHAPv2.xml +++ b/SimpleWifi/ProfileXML/WPA2-Enterprise-PEAP-MSCHAPv2.xml @@ -1,8 +1,9 @@ - + {0} + {1} {0} diff --git a/SimpleWifi/ProfileXML/WPA2-Enterprise-TLS.xml b/SimpleWifi/ProfileXML/WPA2-Enterprise-TLS.xml index 61dee8c..b408c20 100644 --- a/SimpleWifi/ProfileXML/WPA2-Enterprise-TLS.xml +++ b/SimpleWifi/ProfileXML/WPA2-Enterprise-TLS.xml @@ -1,8 +1,9 @@ - + {0} + {1} {0} diff --git a/SimpleWifi/ProfileXML/WPA2-PSK.xml b/SimpleWifi/ProfileXML/WPA2-PSK.xml index d6cd1d3..ad88713 100644 --- a/SimpleWifi/ProfileXML/WPA2-PSK.xml +++ b/SimpleWifi/ProfileXML/WPA2-PSK.xml @@ -1,8 +1,9 @@ - + {0} + {1} {0} @@ -19,7 +20,7 @@ passPhrase false - {1} + {2}