Home > Software engineering >  Connect to hidden WiFi using netsh commands
Connect to hidden WiFi using netsh commands

Time:10-07

I would like to know if it is possible to connect to a hidden WiFi network knowing the SSDI name and password. I did try to do this by myself but without any luck.

For some tests, I made hidden WiFi with the SSID name Galaxy and a password.

Firstly tried to add a profile by making a .xml file with the specified parameters.

<?xml version="1.0" encoding="US-ASCII"?>
<WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1">
    <name>GalaxyNet</name>
    <SSIDConfig>
        <SSID>
            <name>Galaxy</name>
        </SSID>
    </SSIDConfig>
    <connectionType>ESS</connectionType>
    <connectionMode>auto</connectionMode>
    <autoSwitch>true</autoSwitch>
    <MSM>
        <security>
            <authEncryption>
                <authentication>WPA2PSK</authentication>
                <encryption>AES</encryption>
                <useOneX>false</useOneX>
            </authEncryption>       
            <sharedKey>
                <keyType>passPhrase</keyType>
                <protected>false</protected>
                <keyMaterial>**** password ****</keyMaterial>
            </sharedKey>
        </security>
    </MSM>
</WLANProfile>

After that added the profile from .xml file using netsh commands.

netsh wlan add profile filename="c:\NET.xml"

Got a message:

Profile GalaxyNet is added on interface Wi-Fi.

After everything went ok with the previous steps I tried to connect to that profile but with no luck.

netsh wlan connect name="GalaxyNet" interface="wi-fi"
The network specified by profile "GalaxyNet" is not available to connect.

Also tried:

netsh wlan connect ssid="Galaxy" name="GalaxyNet" interface="wi-fi"
The network specified by profile "GalaxyNet" is not available to connect.

Is it even possible to somehow match the netsh hidden network to a profile if it wasn't "assigned" with a GUI interface?

Or does anyone know another way to connect to a hidden WiFi by any script?

CodePudding user response:

The profile configuration setting you're missing is nonBroadcast - it controls whether the profile is allowed to connect to visibly broadcasting SSIDs only, or attempt to connect to hidden networks.

You can set it for an existing profile with netsh wlan set profileparameter:

netsh wlan set profileparameter name=GalaxyNet nonBroadcast=yes

Or include it in your XML file under /WLANProfile/SSIDConfig like this:

<?xml version="1.0" encoding="US-ASCII"?>
<WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1">
    <name>GalaxyNet</name>
    <SSIDConfig>
        <SSID>
            <name>Galaxy</name>
        </SSID>
        <nonBroadcast>true</nonBroadcast>
    </SSIDConfig>
    <!-- rest of xml goes here as before -->
</WLANProfile>
  • Related