Hack Forums
VBScript Help - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: VBScript Help (/showthread.php?tid=6257221)



VBScript Help - DramaKing - Nov 26, 2023

I'm hoping that there's someone here who knows VBScript and the Windows Native WiFi API. I've been using Copilot to build a cool script in VBScript. It uses the Wlan.WlanClient component to scan WiFi networks, checks the BSSIDs using the WIGLE API, and uploads the results to a server. When I try to run it with VbsEdit 32-bit or 64-bit or wscript, I get the error "ActiveX can't create component Wlan.WlanClient." It seems like I need the Managed Wifi DLL, but I can't find how to reference a DLL in VBScript. I'm hoping to disguise the file as a document, so I'd prefer not to have to use a language like VB.NET.

Code
' Create a WMI object
Set objWMIService = GetObject("winmgmts:\\.\root\CIMV2")

' Query the WMI object for wireless network adapters
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapter WHERE NetConnectionID = 'Wi-Fi'")

' Loop through the wireless network adapters
For Each objItem in colItems

    ' Get the device ID of the adapter
    strDeviceID = objItem.DeviceID

    ' Create a Wlan client object
    Set objWlan = CreateObject("Wlan.WlanClient")

    ' Loop through the Wlan interfaces
    For Each objInterface in objWlan.Interfaces

        ' Check if the interface matches the device ID
        If objInterface.InterfaceIndex = strDeviceID Then

            ' Scan for available networks
            objInterface.Scan()

            ' Get the list of available networks
            Set colNetworks = objInterface.GetAvailableNetworkList(0)

            ' Loop through the available networks
            For Each objNetwork in colNetworks

                ' Print the network name (SSID)
                WScript.Echo objNetwork.profileName

            Next

        End If

    Next

Next



RE: VBScript Help - HFDone - Nov 26, 2023

you can use netsh wlan show networks mode=bssid
here cmd axample to get signal you can change it to any value you need to get
for /f "tokens=2 delims=:" %%i in ('netsh wlan show networks mode^=bssid ^|find "Signal"') do echo %%i


RE: VBScript Help - DramaKing - Nov 27, 2023

(Nov 26, 2023 08:58 AM)HFDone Wrote:  you can use netsh wlan show networks mode=bssid
here cmd axample to get signal you can change it to any value you need to get
for /f "tokens=2 delims=:" %%i in ('netsh wlan show networks mode^=bssid ^|find "Signal"') do echo %%i

I'd considered netsh, but it only showed the network that I was connected to before. Seems to be inconsistent. Anyway, this worked for me:

Code
Dim objShell, objExec, strBSSID, i
Set objShell = CreateObject("WScript.Shell")
Set objExec = objShell.Exec(for /f "tokens=3* delims= " %%a in ('netsh wlan show networks mode^=bssid^|find "BSSID"') do echo %%b)
strBSSID = objExec.StdOut.ReadAll
Set objShell = Nothing

Would be nice to use native code that doesn't use a shell object, but this will work for now.


RE: VBScript Help - jleeme - Nov 28, 2023

no clue im posting this for few bytes lol [warn]