Hunter070 Posted June 22, 2022 Share Posted June 22, 2022 (edited) Wifi Tool.zip Edited June 23, 2022 by Hunter070 update Zedna 1 Link to comment Share on other sites More sharing options...
water Posted June 22, 2022 Share Posted June 22, 2022 Great tool! I've played a bit with your code and here is my version: Displays a message when there is no password needed to connect to a WLAN Translates the NetSh output from OEM to ANSI to prevent problems with other languages (tested my version with German) Moved the constants to variables for easier translation Brushed up the code a bit expandcollapse popup; *** Start added by AutoIt3Wrapper *** #include <AutoItConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> ; *** End added by AutoIt3Wrapper *** #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Add_Constants=n #AutoIt3Wrapper_Run_Au3Stripper=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <createQRw.au3> #include <Array.au3> #Region ### START Koda GUI section ### GUICreate("Wifi Password Tool", 615, 437, 470, 208) Global $hGUIList = GUICtrlCreateList("", 8, 40, 193, 370) Global $hGUIInput = GUICtrlCreateInput("", 288, 40, 321, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_READONLY, $WS_HSCROLL)) GUICtrlCreateLabel("Password :", 224, 44, 56, 17) GUICtrlCreateLabel("SSID's", 8, 16, 36, 17) GUICtrlCreateGroup("QR Code", 304, 144, 193, 169) Global $hGUIQR = GUICtrlCreatePic("", 352, 184, 100, 100) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Global $aSSIDs, $sQRData, $aKeyData, $hDLL, $nMsg Global $bFirstRun = True Global Const $sProfile = "Profil für alle Benutzer" ; "All User Profile" Global Const $sSecurityKey = "Sicherheitsschlüssel" ; "Security Key" Global Const $sSecurityKeyValue = "Vorhanden" ; Security Key set Global Const $sSecurityKeyMsg = "Kein Sicherheitsschlüssel vorhanden" ; No Security Key set Global Const $sKeyContent = "Schlüsselinhalt" ; "Key Content" While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE DLLClose($hDLL) Exit Case $hGUIList $aKeyData = GetKeyFromSSID(GUICtrlRead($hGUIList)) $sQRData = 'WIFI:S:' & $aKeyData[0] & ';T:WPA;P:' & $aKeyData[1] & ';;' _createQRw_($sQRData, $hGUIQR) GUICtrlSetData($hGUIInput, $aKeyData[1]) EndSwitch If $bFirstRun Then $bFirstRun = False $hDLL = DllOpen("user32.dll") $aSSIDs = _GetSSIDs() GUICtrlSetData($hGUIList, _ArrayToString($aSSIDs)) EndIf WEnd Func _GetSSIDs() Local $iPID = Run(@ComSpec & " /c " & 'netsh wlan show profile', @ScriptDir, @SW_HIDE, $STDOUT_CHILD + $STDERR_CHILD) ProcessWaitClose($iPID) Local $sOutput = StdoutRead($iPID) ; Translate from OEM to ANSI. ; https://www.autoitscript.com/forum/topic/28678-dos-formatted-string/?do=findComment&comment=281231 Local $aOutput = DllCall($hDLL, 'Int', 'OemToChar', 'str', $sOutput, 'str', '') $aOutput = StringSplit($aOutput[2], @CRLF) Local $iItems = 0, $aTemp Local $aSSIDs[$aOutput[0]] For $i = 1 To $aOutput[0] If StringInStr($aOutput[$i], $sProfile) Then $aTemp = StringSplit($aOutput[$i], ":") $aSSIDs[$iItems] = StringStripWS($aTemp[2], 1) $iItems += 1 EndIf Next ReDim $aSSIDs[$iItems] Return $aSSIDs EndFunc ;==>_GetSSIDs Func GetKeyFromSSID($sSSID) Local $aKey[2] = [$sSSID] Local $iPID = Run(@ComSpec & " /c " & 'netsh wlan show profile name="' & $sSSID & '" key=clear', @ScriptDir, @SW_HIDE, $STDOUT_CHILD + $STDERR_CHILD) ProcessWaitClose($iPID) Local $sOutput = StdoutRead($iPID) ; Translate from OEM to ANSI. ; https://www.autoitscript.com/forum/topic/28678-dos-formatted-string/?do=findComment&comment=281231 Local $aOutput = DllCall($hDLL, 'Int', 'OemToChar', 'str', $sOutput, 'str', '') $aOutput = StringSplit($aOutput[2], @CRLF) Local $aTemp For $i = 1 To $aOutput[0] If StringInStr($aOutput[$i], $sSecurityKey) Then $aTemp = StringSplit($aOutput[$i], ":") If StringStripWS($aTemp[2], 8) <> $sSecurityKeyValue Then $aKey[1] = $sSecurityKeyMsg ExitLoop EndIf EndIf If StringInStr($aOutput[$i], $sKeyContent) Then $aTemp = StringSplit($aOutput[$i], ":") $aKey[1] = StringStripWS($aTemp[2], 8) ExitLoop EndIf Next Return $aKey EndFunc ;==>GetKeyFromSSID My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Exit Posted June 22, 2022 Share Posted June 22, 2022 A very nice tool. Maybe it would be possible to add a delete button for obsolete items. App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
water Posted June 22, 2022 Share Posted June 22, 2022 Delete button has been added Refresh button has been added Password and QR code get cleared when a new SSID has been selected until all data has been extracted and the QR code has been created expandcollapse popup; *** Start added by AutoIt3Wrapper *** #include <AutoItConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> ; *** End added by AutoIt3Wrapper *** #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Add_Constants=n #AutoIt3Wrapper_Run_Au3Stripper=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <createQRw.au3> #include <Array.au3> Global Const $sToolName = "Wifi Password Tool" Global Const $sProfile = "Profil für alle Benutzer" ; "All User Profile" Global Const $sSecurityKey = "Sicherheitsschlüssel" ; "Security Key" Global Const $sSecurityKeyValue = "Vorhanden" ; Security Key set Global Const $sSecurityKeyMsg = "Kein Sicherheitsschlüssel vorhanden" ; No Security Key set Global Const $sKeyContent = "Schlüsselinhalt" ; "Key Content" Global Const $sDeleteEntry = "Do you really want to delete the selected SSID: " #Region ### START Koda GUI section ### GUICreate($sToolName, 615, 437, 470, 208) Global $hGUIList = GUICtrlCreateList("", 8, 40, 193, 370) Global $hGUIInput = GUICtrlCreateInput("", 288, 40, 321, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_READONLY, $WS_HSCROLL)) GUICtrlCreateLabel("Password :", 224, 44, 56, 17) GUICtrlCreateLabel("SSID's", 8, 16, 36, 17) Global $hGroup = GUICtrlCreateGroup("QR Code", 304, 144, 193, 169) Global $hGUIQR = GUICtrlCreatePic("", 352, 184, 100, 100) GUICtrlCreateGroup("", -99, -99, 1, 1) Global $hDelete = GUICtrlCreateButton("Delete", 224, 380, 80, 30) Global $hExit = GUICtrlCreateButton("Exit", 529, 380, 80, 30) Global $hRefresh = GUICtrlCreateButton("Refresh", 314, 380, 80, 30) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Global $sSSID, $aSSIDs, $sQRData, $aKeyData, $hDLL, $nMsg Global $bFirstRun = True While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE, $hExit DllClose($hDLL) Exit Case $hGUIList $sSSID = GUICtrlRead($hGUIList) GUICtrlSetData($hGroup, "QR Code") GUICtrlSetData($hGUIInput, "") GUICtrlSetState($hGUIQR, $GUI_HIDE) $aKeyData = GetKeyFromSSID($sSSID) $sQRData = 'WIFI:S:' & $aKeyData[0] & ';T:WPA;P:' & $aKeyData[1] & ';;' _createQRw_($sQRData, $hGUIQR) GUICtrlSetData($hGroup, "QR Code for SSID: " & $sSSID) GUICtrlSetData($hGUIInput, $aKeyData[1]) GUICtrlSetState($hGUIQR, $GUI_SHOW) Case $hDelete If _DeleteEntry(GUICtrlRead($hGUIList)) = 1 Then $bFirstRun = True ; Recreate the Listbox Case $hRefresh $bFirstRun = True ; Recreate the Listbox EndSwitch If $bFirstRun Then $bFirstRun = False $hDLL = DllOpen("user32.dll") $aSSIDs = _GetSSIDs() GUICtrlSetData($hGUIList, "") GUICtrlSetData($hGUIList, _ArrayToString($aSSIDs)) EndIf WEnd Func _GetSSIDs() Local $iPID = Run(@ComSpec & " /c " & 'netsh wlan show profile', @ScriptDir, @SW_HIDE, $STDOUT_CHILD + $STDERR_CHILD) ProcessWaitClose($iPID) Local $sOutput = StdoutRead($iPID) ; Translate from OEM to ANSI. ; https://www.autoitscript.com/forum/topic/28678-dos-formatted-string/?do=findComment&comment=281231 Local $aOutput = DllCall($hDLL, 'Int', 'OemToChar', 'str', $sOutput, 'str', '') $aOutput = StringSplit($aOutput[2], @CRLF) Local $iItems = 0, $aTemp Local $aSSIDs[$aOutput[0]] For $i = 1 To $aOutput[0] If StringInStr($aOutput[$i], $sProfile) Then $aTemp = StringSplit($aOutput[$i], ":") $aSSIDs[$iItems] = StringStripWS($aTemp[2], 1) $iItems += 1 EndIf Next ReDim $aSSIDs[$iItems] Return $aSSIDs EndFunc ;==>_GetSSIDs Func GetKeyFromSSID($sSSID) Local $aKey[2] = [$sSSID] Local $iPID = Run(@ComSpec & " /c " & 'netsh wlan show profile name="' & $sSSID & '" key=clear', @ScriptDir, @SW_HIDE, $STDOUT_CHILD + $STDERR_CHILD) ProcessWaitClose($iPID) Local $sOutput = StdoutRead($iPID) ; Translate from OEM to ANSI. ; https://www.autoitscript.com/forum/topic/28678-dos-formatted-string/?do=findComment&comment=281231 Local $aOutput = DllCall($hDLL, 'Int', 'OemToChar', 'str', $sOutput, 'str', '') $aOutput = StringSplit($aOutput[2], @CRLF) Local $aTemp For $i = 1 To $aOutput[0] If StringInStr($aOutput[$i], $sSecurityKey) Then $aTemp = StringSplit($aOutput[$i], ":") If StringStripWS($aTemp[2], 8) <> $sSecurityKeyValue Then $aKey[1] = $sSecurityKeyMsg ExitLoop EndIf EndIf If StringInStr($aOutput[$i], $sKeyContent) Then $aTemp = StringSplit($aOutput[$i], ":") $aKey[1] = StringStripWS($aTemp[2], 8) ExitLoop EndIf Next Return $aKey EndFunc ;==>GetKeyFromSSID Func _DeleteEntry($sSSID) If MsgBox(BitOR($MB_ICONQUESTION, $MB_OKCANCEL), $sToolName, $sDeleteEntry & $sSSID) = $IDCANCEL Then Return 0 Local $iPID = Run(@ComSpec & " /c " & 'netsh wlan delete profile name="' & $sSSID & '"', @ScriptDir, @SW_HIDE, $STDOUT_CHILD + $STDERR_CHILD) ProcessWaitClose($iPID) Local $sOutput = StdoutRead($iPID) ; Translate from OEM to ANSI. ; https://www.autoitscript.com/forum/topic/28678-dos-formatted-string/?do=findComment&comment=281231 Local $aOutput = DllCall($hDLL, 'Int', 'OemToChar', 'str', $sOutput, 'str', '') $aOutput = StringSplit($aOutput[2], @CRLF) Return 1 EndFunc ;==>_DeleteEntry Hunter070 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Hunter070 Posted June 23, 2022 Author Share Posted June 23, 2022 (edited) Thanks water, I updated the program. Edited June 23, 2022 by Hunter070 Link to comment Share on other sites More sharing options...
Exit Posted June 24, 2022 Share Posted June 24, 2022 Here we have a Babylonian confusion of languages. The Water solution only works with German locale. The Hunter070 solution only works with English locale. This is because the netsh output is parsed with locale constants. e.g. Global Const $sProfile = "All User Profile" Global Const $sProfile = "Profil für alle Benutzer" A language-independent version would be desirable. Danp2 1 App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
water Posted June 24, 2022 Share Posted June 24, 2022 I do not know of a way to change the language for CMD. Another idea would be to run a command like "print /?" then examine the returned text to determine the language. The needed text constants could then be read from an ini file. What do you think? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Danp2 Posted June 24, 2022 Share Posted June 24, 2022 What about using @OSLang? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
funkey Posted June 24, 2022 Share Posted June 24, 2022 (edited) All infos can be found in registry language independent. But I don't have a PC here with wifi adapter for testing. This could be a registry key to start: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces The Wifi passwords are stored under C:\ProgramData\Microsoft\Wlansvc\Profiles\Interfaces\[Interface Guid]. The encrypted keys are stored in .xml file. Edit: I think this is far too complicated, so @OSLang is easiest way to go for now. Edited June 24, 2022 by funkey Programming today is a race between software engineers striving tobuild bigger and better idiot-proof programs, and the Universetrying to produce bigger and better idiots.So far, the Universe is winning. Link to comment Share on other sites More sharing options...
jguinch Posted June 24, 2022 Share Posted June 24, 2022 (edited) Can you try this in command line (in elevated cmd): md c:\Windows\Temp\wifi cd /d c:\Windows\Temp\wifi netsh wlan export profile key=clear so you will have one xml file per SSID, in c:\windows\temp\wifi. You can now parse each XML file to get the informations you need. Not sure it contains the key... Edited June 24, 2022 by jguinch Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
Danp2 Posted June 24, 2022 Share Posted June 24, 2022 @jguinchThe exported files contain the encrypted key. To export the unencrypted key, change the last line to this -- netsh wlan export profile key=clear Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Exit Posted June 24, 2022 Share Posted June 24, 2022 (edited) Simply read out the information regardless of the language. Here is a hopefully language-independent solution: #include <Array.au3> #include <string.au3> Global $hDLL = DllOpen("user32.dll") $aSSIDs = _GetSSIDs() For $i = 0 To UBound($aSSIDs) - 1 $key = _GetKeyFromSSID($aSSIDs[$i]) ConsoleWrite(@TAB & $aSSIDs[$i] & @TAB & @TAB & $key & @CRLF) Next Func _GetSSIDs() Local $iPID = Run(@ComSpec & " /c " & 'netsh wlan show profile', @ScriptDir, @SW_HIDE, $STDOUT_CHILD + $STDERR_CHILD) ProcessWaitClose($iPID) Local $sOutput = StdoutRead($iPID) Local $aOutput = DllCall($hDLL, 'Int', 'OemToChar', 'str', $sOutput, 'str', '') $aOutput = _StringExplode($aOutput[2], "-" & @CRLF) $sOutput = $aOutput[UBound($aOutput) - 1] Local $aSSIDs = _StringBetween($sOutput, " : ", @CRLF) Return $aSSIDs EndFunc ;==>_GetSSIDs Func _GetKeyFromSSID($sSSID) ;returns "1" if key is not present Local $iPID = Run(@ComSpec & " /c " & 'netsh wlan show profile name="' & $sSSID & '" key=clear', @ScriptDir, @SW_HIDE, $STDOUT_CHILD + $STDERR_CHILD) ProcessWaitClose($iPID) Local $sOutput = StdoutRead($iPID) Local $aOutput = DllCall($hDLL, 'Int', 'OemToChar', 'str', $sOutput, 'str', '') $aOutput = _StringBetween($aOutput[2], " : ", @CRLF) Return $aOutput[UBound($aOutput) - 6] EndFunc ;==>_GetKeyFromSSID Can the foreign language users please confirm that it works in their language. German OK English No French ? others ? Edited June 24, 2022 by Exit App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
Danp2 Posted June 24, 2022 Share Posted June 24, 2022 @ExitIn English, that doesn't correctly retrieve the passkey for me (they all displayed "Unrestricted"). I took a quick glance at the array contents, and I think a more complex method will be required to retrieve the correct array element. Exit 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Exit Posted June 24, 2022 Share Posted June 24, 2022 since i only have access to the german version, i can't help. But surely someone will pick up the thread and continue spinning it. App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
kurtykurtyboy Posted June 24, 2022 Share Posted June 24, 2022 (edited) I really like this tool! @Exit In English, I have a similar output "Unrestricted". For me, the offset is 7 instead of 6. Return $aOutput[UBound($aOutput) - 7] Here is my solution. How does this work on German version? #include <Array.au3> #include <string.au3> Global $hDLL = DllOpen("user32.dll") $aSSIDs = _GetSSIDs() For $i = 0 To UBound($aSSIDs) - 1 $key = _GetKeyFromSSID($aSSIDs[$i]) ConsoleWrite(@TAB & $aSSIDs[$i] & @TAB & @TAB & $key & @CRLF) Next Func _GetSSIDs() Local $iPID = Run(@ComSpec & " /c " & 'netsh wlan show profile', @ScriptDir, @SW_HIDE, $STDOUT_CHILD + $STDERR_CHILD) ProcessWaitClose($iPID) Local $sOutput = StdoutRead($iPID) Local $aOutput = DllCall($hDLL, 'Int', 'OemToChar', 'str', $sOutput, 'str', '') $aOutput = _StringExplode($aOutput[2], "-" & @CRLF) $sOutput = $aOutput[UBound($aOutput) - 1] Local $aSSIDs = _StringBetween($sOutput, " : ", @CRLF) Return $aSSIDs EndFunc ;==>_GetSSIDs Func _GetKeyFromSSID($sSSID) ;returns "1" if key is not present Local $iPID = Run(@ComSpec & " /c " & 'netsh wlan show profile name="' & $sSSID & '" key=clear', @ScriptDir, @SW_HIDE, $STDOUT_CHILD + $STDERR_CHILD) ProcessWaitClose($iPID) Local $sOutput = StdoutRead($iPID) Local $aOutput = DllCall($hDLL, 'Int', 'OemToChar', 'str', $sOutput, 'str', '') $aOutput = StringSplit($aOutput[2], @CRLF & "-", $STR_ENTIRESPLIT + $STR_NOCOUNT) $aOutput = _StringBetween($aOutput[3], " : ", @CRLF) Return $aOutput[UBound($aOutput) - 1] EndFunc ;==>_GetKeyFromSSID For reference, here is my English netsh output Spoiler Profile information ------------------- Version : 1 Type : Wireless LAN Name : myID Control options : Connection mode : Connect automatically Network broadcast : Connect only if this network is broadcasting AutoSwitch : Do not switch to other networks MAC Randomization : Disabled Connectivity settings --------------------- Number of SSIDs : 1 SSID name : "myID" Network type : Infrastructure Radio type : [ Any Radio Type ] Vendor extension : Not present Security settings ----------------- Authentication : WPA2-Personal Cipher : CCMP Authentication : WPA2-Personal Cipher : GCMP Security key : Present Key Content : mypassword Cost settings ------------- Cost : Unrestricted Congested : No Approaching Data Limit : No Over Data Limit : No Roaming : No Cost Source : Default BTW, there are still some nuances to work out, like this scenario. Spoiler expandcollapse popupProfile information ------------------- Version : 1 Type : Wireless LAN Name : myID Control options : Connection mode : Connect manually Network broadcast : Connect even if this network is not broadcasting AutoSwitch : Do not switch to other networks MAC Randomization : Disabled Connectivity settings --------------------- Number of SSIDs : 1 SSID name : "myID" Network type : Infrastructure Radio type : [ Any Radio Type ] Vendor extension : Not present Security settings ----------------- Authentication : WPA2-Enterprise Cipher : CCMP Authentication : WPA2-Enterprise Cipher : GCMP Security key : Absent 802.1X : Enabled EAP type : Microsoft: Protected EAP (PEAP) 802.1X auth credential : User credential Credentials configured : No Cache user information : Yes Cost settings ------------- Cost : Unrestricted Congested : No Approaching Data Limit : No Over Data Limit : No Roaming : No Cost Source : Default Edited June 24, 2022 by kurtykurtyboy Danp2 and Exit 2 Link to comment Share on other sites More sharing options...
Exit Posted June 24, 2022 Share Posted June 24, 2022 (edited) 45 minutes ago, kurtykurtyboy said: How does this work on German version? Works like a charm Waiting for results in other languages. Edited June 24, 2022 by Exit App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
Hunter070 Posted June 24, 2022 Author Share Posted June 24, 2022 (edited) Can anyone verify this works? expandcollapse popupFunc _GetSSIDs() Local $iPID = Run(@ComSpec & " /c " & 'chcp 437 & netsh wlan show profile', @ScriptDir, @SW_SHOW, $STDOUT_CHILD + $STDERR_CHILD) ProcessWaitClose($iPID) Local $sOutput = StdoutRead($iPID) ; Translate from OEM to ANSI. ; https://www.autoitscript.com/forum/topic/28678-dos-formatted-string/?do=findComment&comment=281231 Local $aOutput = DllCall($hDLL, 'Int', 'OemToChar', 'str', $sOutput, 'str', '') $aOutput = StringSplit($aOutput[2], @CRLF) Local $iItems = 0, $aTemp Local $aSSIDs[$aOutput[0]] For $i = 1 To $aOutput[0] If StringInStr($aOutput[$i], $sProfile) Then $aTemp = StringSplit($aOutput[$i], ":") $aSSIDs[$iItems] = StringStripWS($aTemp[2], 1) $iItems += 1 EndIf Next ReDim $aSSIDs[$iItems] Return $aSSIDs EndFunc ;==>_GetSSIDs Func GetKeyFromSSID($sSSID) ;returns "!" if key is not present Local $aKey[4] $aKey[2] = $sSSID Local $iPID = Run(@ComSpec & " /c " & 'chcp 437 & netsh wlan show profile name="' & $sSSID & '" key=clear', @ScriptDir, @SW_HIDE, $STDOUT_CHILD + $STDERR_CHILD) ProcessWaitClose($iPID) Local $sOutput = StdoutRead($iPID) ; Translate from OEM to ANSI. ; https://www.autoitscript.com/forum/topic/28678-dos-formatted-string/?do=findComment&comment=281231 Local $aOutput = DllCall($hDLL, 'Int', 'OemToChar', 'str', $sOutput, 'str', '') $aOutput = StringSplit($aOutput[2], @CRLF) Local $aTemp For $i = 1 To $aOutput[0] If StringInStr($aOutput[$i], $sSecurityKey) Then $aTemp = StringSplit($aOutput[$i], ":") $aKey[3] = StringStripWS($aTemp[2], 8) ;security key value If StringStripWS($aTemp[2], 8) <> $sSecurityKeyValue Then $aKey[1] = "!" ExitLoop EndIf EndIf If StringInStr($aOutput[$i], $sKeyContent) Then $aTemp = StringSplit($aOutput[$i], ":") $aKey[1] = StringStripWS($aTemp[2], 8) ExitLoop EndIf Next Return $aKey EndFunc ;==>GetKeyFromSSID chcp changes the language of command prompt Edited June 24, 2022 by Hunter070 Link to comment Share on other sites More sharing options...
kurtykurtyboy Posted June 25, 2022 Share Posted June 25, 2022 (edited) @Hunter070That works for me (English). But I don't think changing the code page will change the language of the netsh output.. I tried changing it to Russian for fun and the output looked exactly the same. Here is another roundabout solution. It exports the profile to an xml file then grabs the password and deletes the file. But this all depends on if other languages use the same file tags <keyMaterial> or some other translated string. Could someone test? * I also changed the SSID grabber to use a regular expression since it seems more straightforward to me, but I know others don't like it, so 🤷♂️. expandcollapse popup#include <AutoItConstants.au3> #include <StringConstants.au3> Global $hDLL = DllOpen("user32.dll") $aSSIDs = _GetSSIDs() For $i = 0 To UBound($aSSIDs) - 1 $key = _GetKeyFromSSID($aSSIDs[$i]) ConsoleWrite(@TAB & $aSSIDs[$i] & @TAB & @TAB & $key & @CRLF) Next Func _GetSSIDs() Local $iPID = Run(@ComSpec & " /c " & 'netsh wlan show profile', @ScriptDir, @SW_HIDE, $STDOUT_CHILD + $STDERR_CHILD) ProcessWaitClose($iPID) Local $sOutput = StdoutRead($iPID) Local $aOutput = DllCall($hDLL, 'Int', 'OemToChar', 'str', $sOutput, 'str', '') Local $aSSIDs = StringRegExp($aOutput[2], '(?m)\s+:\s+(.*?)$', $STR_REGEXPARRAYGLOBALMATCH) Return $aSSIDs EndFunc ;==>_GetSSIDs Func _GetKeyFromSSID($sSSID) ;returns "1" if key is not present ;export to xml file Local $iPID = Run(@ComSpec & " /c " & 'netsh wlan export profile name="' & $sSSID & '" folder="' & @ScriptDir & '" key=clear', @ScriptDir, @SW_HIDE, $STDOUT_CHILD + $STDERR_CHILD) ProcessWaitClose($iPID) Local $sOutput = StdoutRead($iPID) Local $aOutput = DllCall($hDLL, 'Int', 'OemToChar', 'str', $sOutput, 'str', '') ;get filename of the file that was exported $aRegExp = StringRegExp($aOutput[2], '"((?:""|[^"])*)"', $STR_REGEXPARRAYGLOBALMATCH ) $sFilename = $aRegExp[1] ;load the file and parse out the password $sFileData = FileRead($sFilename) FileDelete($sFilename) $aPassword = StringRegExp($sFileData, '(?m)<keyMaterial>(.*?)</keyMaterial>', $STR_REGEXPARRAYGLOBALMATCH ) ;if error, then no password was found If @error Then Return "" Else Return $aPassword[0] EndIf EndFunc ;==>_GetKeyFromSSID edit: I just saw @jguinch had already made the suggestion to export and read the profiles... here I was thinking I had this genius idea! Edited June 25, 2022 by kurtykurtyboy Link to comment Share on other sites More sharing options...
Exit Posted June 25, 2022 Share Posted June 25, 2022 (edited) 3 hours ago, kurtykurtyboy said: Could someone test? Works like a charm in German environment Waiting for results in other languages. Edited June 25, 2022 by Exit App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
Gianni Posted June 25, 2022 Share Posted June 25, 2022 4 hours ago, Exit said: Waiting for results in other languages. @kurtykurtyboy's latest script works on Italian system, you get a password in binary format. To get the password in clear text, add #RequireAdmin at the beginning of the script Exit 1 Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now