【问题标题】:Does Windows10 WiFi profile support blanks in password?Windows 10 WiFi 配置文件是否支持密码中的空白?
【发布时间】:2019-09-26 20:16:00
【问题描述】:

当密码以空格开头时,无法使用 xml 配置文件连接到 Wi-Fi

您好,我使用的是 Windows10,我的 Wi-Fi 卡是 Intel(R) Dual Band Wireless-AC 7265。

如果我通过选择网络名称并手动输入密码手动连接到 ESSID,则我的 ESSID(我将其称为“MY_NETWORK_SSID”)有一个以空格开头的密码(比如说“StartsWithWhiteSpace”)很好,但是如果我使用此配置文件与 netsh 命令进行连接,它会失败:

    <?xml version="1.0"?>
    <WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1">
        <name>MY_NETWORK_SSID</name>
        <SSIDConfig>
            <SSID>
                <hex>6D746C70617461625DA3546455727473</hex>
                <name>MY_NETWORK_SSID</name>
            </SSID>
        </SSIDConfig>
        <connectionType>ESS</connectionType>
        <connectionMode>auto</connectionMode>
        <MSM>
            <security>
                <authEncryption>
                <authentication>WPA2PSK</authentication>
                    <encryption>AES</encryption>
                    <useOneX>false</useOneX>
                    </authEncryption>
                    <sharedKey>
                        <keyType>passPhrase</keyType>
                        <protected>false</protected>
                        <keyMaterial>  StartsWithWhiteSpace</keyMaterial>
                    </sharedKey>
            </security>
        </MSM>
        <MacRandomization xmlns="http://www.microsoft.com/networking/WLAN/profile/v3">
            <enableRandomization>false</enableRandomization>
            <randomizationSeed>1191479147</randomizationSeed>
        </MacRandomization>
    </WLANProfile>

注意:
我还尝试了 (&amp;#32; 和 \u0020) 来表示空白。 我还尝试了 protected=true 并对这个 xml 的密码 keyMaterial 字段进行编码: " P@ssword!23" | ConvertTo-SecureString -AsPlainText -Force | ConvertFrom-SecureString

但不幸的是,这也不起作用。

【问题讨论】:

    标签: xml powershell netsh wifi


    【解决方案1】:

    这是预期的行为,因为 XML 解析器会清除空格。 应该可以改用 PSK,这在这个用例中也更安全一些。未测试(周围没有 Windows 框),但尝试像这样编辑 XML:

                <sharedKey>
                    <keyType>networkKey</keyType>
                    <protected>true</protected>
                    <keyMaterial>XXX</keyMaterial>
                </sharedKey>
    

    XXX 将 PSK 放在那里,可以使用各种工具或在线女巫客户端 JavaScript 在其中一个页面上计算:

    https://www.wireshark.org/tools/wpa-psk.html

    http://jorisvr.nl/wpapsk.html

    【讨论】:

      【解决方案2】:

      感谢您的回复,我也发现这样做需要更少的努力,只需添加xml:space="preserve"

      <sharedKey xml:space="preserve">
          <keyType>passPhrase</keyType>
          <protected>false</protected>
          <keyMaterial> Whitespaces All over .! </keyMaterial>
      </sharedKey>
      

      我用来在标签shareKey中插入属性的powershell部分是:

      $Xml_creator.WriteStartElement("sharedKey")
      $Xml_creator.WriteAttributeString('xml:space', 'preserve')
      

      【讨论】:

        猜你喜欢
        • 2020-07-30
        • 2017-03-12
        • 1970-01-01
        • 1970-01-01
        • 2019-06-19
        • 1970-01-01
        • 2011-03-04
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多