How to programmatically determine the type of encryption and level of encryption from a wireless network device from a Windows 2003 server

Now my team is working on a network project using a Windows C # application . I did not know how to programmatically determine the type of encryption and level of encryption from a wireless network device from a Windows 2003 server.

After searching, I got WMI (Windows Management Tool) to solve the problem. +

Please offer an example / link to search for encryption type and level of encryption from a wireless network device from a Windows 2003 server

+5
source share
2 answers

. , , NDIS. WMI . NDIS , DeviceIoControl (. http://msdn.microsoft.com/en-us/library/aa363216%28v=VS.85%29.aspx). (lpInBuffer) DWORD OID, , . , , DWORD ( ). , NDIS

#define OID_802_11_WEP_STATUS                   0x0D01011B

( DWORD lpInBuffer), DWORD

// Also aliased typedef to new name
typedef enum _NDIS_802_11_WEP_STATUS
{
    Ndis802_11WEPEnabled,
    Ndis802_11Encryption1Enabled = Ndis802_11WEPEnabled,
    Ndis802_11WEPDisabled,
    Ndis802_11EncryptionDisabled = Ndis802_11WEPDisabled,
    Ndis802_11WEPKeyAbsent,
    Ndis802_11Encryption1KeyAbsent = Ndis802_11WEPKeyAbsent,
    Ndis802_11WEPNotSupported,
    Ndis802_11EncryptionNotSupported = Ndis802_11WEPNotSupported,
    Ndis802_11Encryption2Enabled,
    Ndis802_11Encryption2KeyAbsent,
    Ndis802_11Encryption3Enabled,
    Ndis802_11Encryption3KeyAbsent
} NDIS_802_11_WEP_STATUS, *PNDIS_802_11_WEP_STATUS,
  NDIS_802_11_ENCRYPTION_STATUS, *PNDIS_802_11_ENCRYPTION_STATUS;

#define OID_802_11_AUTHENTICATION_MODE          0x0D010118

typedef enum _NDIS_802_11_AUTHENTICATION_MODE
{
    Ndis802_11AuthModeOpen,
    Ndis802_11AuthModeShared,
    Ndis802_11AuthModeAutoSwitch,
    Ndis802_11AuthModeWPA,
    Ndis802_11AuthModeWPAPSK,
    Ndis802_11AuthModeWPANone,
    Ndis802_11AuthModeWPA2,
    Ndis802_11AuthModeWPA2PSK,
    Ndis802_11AuthModeMax               // Not a real mode, defined as upper bound
} NDIS_802_11_AUTHENTICATION_MODE;

#define OID_802_11_INFRASTRUCTURE_MODE          0x0D010108

typedef enum _NDIS_802_11_NETWORK_INFRASTRUCTURE
{
    Ndis802_11IBSS,
    Ndis802_11Infrastructure,
    Ndis802_11AutoUnknown,
    Ndis802_11InfrastructureMax         // Not a real value, defined as upper bound
} NDIS_802_11_NETWORK_INFRASTRUCTURE;

.. , ntddndis.h Windows DDK.

, CreateFile. "\\.\" (). , . HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Tcpip\Parameters\Adapters.

, , , http://msdn.microsoft.com/en-us/library/aa964902%28v=VS.85%29.aspx DeviceIoControl. IoControl, , DDK. , DeviceIoControl .

, 10 , , . - . OID, , .

: http://pages.infinit.net/codeguru/WiFiArticle.htm, , , , . , CreateFile. FILE_SHARE_READ | FILE_SHARE_WRITE, . http://code.google.com/p/haggle/source/browse/winmobile/Haggle/WindowsWiFiUtils.cpp (. bool WindowsWiFiUtils:init(), bool WindowsWiFiUtils::setEncryptionMode(unsigned long adapterIndex, const unsigned int mode) ..) , . ++, #.

2: - "Native Wifi API" http://msdn.microsoft.com/en-us/library/ms706556%28VS.85%29.aspx, WlanQueryInterface ( , wlan_intf_opcode_supported_infrastructure_auth_cipher_pairs) WZCQueryInterface, , , Windows Server 2003, . , "Native Wifi API", , ( ), WMI .

+3

WMI, , .

WMI "Select * from MSNdis_80211_WEPStatus where active=true" , :

0=WEP is in use
2=Connection is unsecured
4=WPA-PSK is in use
6=WPA is in use
7=Disconnected

powershell, :

PS C:\WINDOWS > gwmi -query "Select * from MSNdis_80211_WEPStatus where active=true" -namespace root\wmi

# :

using System;
using System.Management;
class Query_SelectQuery
{
    public static int Main(string[] args) 
    {
        SelectQuery selectQuery = new 
            SelectQuery("Select * from MSNdis_80211_WEPStatus where active=true");
        ManagementObjectSearcher searcher =
            new ManagementObjectSearcher("root\wmi", selectQuery);

        foreach (ManagementObject resultVal in searcher.Get()) 
        {
            Console.WriteLine(resultVal.ToString());
        }

        Console.ReadLine();
        return 0;
    }
}

, , SSID, Ndis80211Ssid MSNdis_80211_ServiceSetIdentifier.

Windows {Vista, 7, Server 2008}, netsh wlan export XML ( ), , Windows XP, Server 2003 .

, , Windows 2003 Server, - , : http://technet.microsoft.com/en-us/library/bb878079.aspx

Windows Server 2003 , WMI root\ RSoP

wbemtest Microsoft WMI Code Creator WMI, .

WMI : (

+2

All Articles