Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Local $SSIDs = "", $mesSSIDs = "", $information_wifi = ""
- $command1 = 'netsh wlan show profile key=clear | findstr .Profil'
- $mesSSIDs = _SSIDS($command1) ; permet de lister les SSID, dans une seul variable. On listera ensuite chaque SSID afin de récupérer la clé
- If $mesSSIDs <> "" Then
- For $a = 1 To StringSplit($mesSSIDs, @LF)[0]
- $SSID = StringSplit($mesSSIDs, @LF)[$a]
- If $SSID <> "" Then
- $information_wifi = _InformationWifi($SSID)
- EndIf
- Next
- EndIf
- MsgBox(0, "", $information_wifi)
- Func _SSIDS($cmd)
- $nPid = Run(@ComSpec & " /c " & $cmd, "", @SW_HIDE, 8)
- ProcessWait($nPid)
- While 1
- $SSIDs &= StdoutRead($nPid)
- If @error Or (Not ProcessExists($nPid)) Then ExitLoop
- WEnd
- If $SSIDs <> "" Then
- ; Pour info, voici la syntaxe d'une "ligne"
- For $a = 1 To StringSplit($SSIDs, @LF)[0]
- $ligne = StringSplit($SSIDs, @LF)[$a]
- If $ligne <> "" Then
- ; Pour info, voici la syntaxe d'une "ligne" >> Profil Tous les utilisateurs ÿ: Mi 10T Lite
- ; On doit donc récupérer la partie droite, après le : >> avec stringsplit
- ; Et supprimer tous les espaces du début de la ligne, et de la fin de la ligne : avec stringstripws et le paramètre 3
- ; Etant donné que je veux que les SSIDs soient dans une seul et même variable, on fait de la concaténation de variable
- $SSID = StringSplit($ligne, ":")[2] ; on split pour récupérer la partie de droite
- $SSID = StringStripWS($SSID, 3) ; on supprime les espaces de début et de fin
- $mesSSIDs &= $SSID & @CRLF ; @crlf permet de faire de lister correctement. Sinon, on aurait tout sur la même ligne
- EndIf
- Next
- Return $mesSSIDs
- EndIf
- EndFunc ;==>_SSIDS
- Func _InformationWifi($SSID)
- Local $_CleSec = "", $cle_sec
- $command2 = 'netsh wlan show profile name="' & $SSID & '" key=clear'
- $nPid = Run(@ComSpec & " /c " & $command2, "", @SW_HIDE, 8)
- ProcessWait($nPid)
- While 1
- $_CleSec &= StdoutRead($nPid)
- If @error Or (Not ProcessExists($nPid)) Then ExitLoop
- WEnd
- If StringInStr($_CleSec, "Contenu de la") Then
- $cle_sec = _ObtCleWifi($_CleSec)
- Else
- $cle_sec = ""
- EndIf
- $information_wifi &= StringStripWS($SSID, 3) & "|" & $cle_sec & @CRLF
- Return $information_wifi
- EndFunc ;==>_InformationWifi
- Func _ObtCleWifi($cl)
- $clesec = ""
- For $a = 1 To StringSplit($cl, @LF)[0]
- $ligne = StringSplit($cl, @LF)[$a]
- If StringInStr($ligne, "Contenu de la") Then
- $clesec = StringSplit($ligne, ":")[2]
- $clesec = StringStripWS($clesec, 8)
- EndIf
- Next
- Return $clesec
- EndFunc ;==>_ObtCleWifi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement