Advertisement
Guest User

Untitled

a guest
Aug 9th, 2021
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 2.56 KB | None | 0 0
  1. Local $SSIDs = "", $mesSSIDs = "", $information_wifi = ""
  2.  
  3. $command1 = 'netsh wlan show profile key=clear | findstr .Profil'
  4. $mesSSIDs = _SSIDS($command1) ; permet de lister les SSID, dans une seul variable. On listera ensuite chaque SSID afin de récupérer la clé
  5.  
  6. If $mesSSIDs <> "" Then
  7.     For $a = 1 To StringSplit($mesSSIDs, @LF)[0]
  8.         $SSID = StringSplit($mesSSIDs, @LF)[$a]
  9.         If $SSID <> "" Then
  10.             $information_wifi = _InformationWifi($SSID)
  11.         EndIf
  12.     Next
  13. EndIf
  14.  
  15. MsgBox(0, "", $information_wifi)
  16.  
  17.  
  18. Func _SSIDS($cmd)
  19.  
  20.     $nPid = Run(@ComSpec & " /c " & $cmd, "", @SW_HIDE, 8)
  21.     ProcessWait($nPid)
  22.     While 1
  23.         $SSIDs &= StdoutRead($nPid)
  24.         If @error Or (Not ProcessExists($nPid)) Then ExitLoop
  25.     WEnd
  26.  
  27.     If $SSIDs <> "" Then
  28.  
  29.         ; Pour info, voici la syntaxe d'une "ligne"
  30.  
  31.  
  32.         For $a = 1 To StringSplit($SSIDs, @LF)[0]
  33.             $ligne = StringSplit($SSIDs, @LF)[$a]
  34.             If $ligne <> "" Then
  35.                 ; Pour info, voici la syntaxe d'une "ligne" >>     Profil Tous les utilisateurs    ÿ: Mi 10T Lite
  36.                 ; On doit donc récupérer la partie droite, après le : >> avec stringsplit
  37.                 ; 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
  38.                 ; Etant donné que je veux que les SSIDs soient dans une seul et même variable, on fait de la concaténation de variable
  39.                 $SSID = StringSplit($ligne, ":")[2] ; on split pour récupérer la partie de droite
  40.                 $SSID = StringStripWS($SSID, 3) ; on supprime les espaces de début et de fin
  41.                 $mesSSIDs &= $SSID & @CRLF ; @crlf permet de faire de lister correctement. Sinon, on aurait tout sur la même ligne
  42.             EndIf
  43.         Next
  44.  
  45.         Return $mesSSIDs
  46.  
  47.  
  48.     EndIf
  49.  
  50.  
  51. EndFunc   ;==>_SSIDS
  52.  
  53. Func _InformationWifi($SSID)
  54.  
  55.     Local $_CleSec = "", $cle_sec
  56.  
  57.     $command2 = 'netsh wlan show profile name="' & $SSID & '" key=clear'
  58.     $nPid = Run(@ComSpec & " /c " & $command2, "", @SW_HIDE, 8)
  59.     ProcessWait($nPid)
  60.     While 1
  61.         $_CleSec &= StdoutRead($nPid)
  62.         If @error Or (Not ProcessExists($nPid)) Then ExitLoop
  63.     WEnd
  64.  
  65.     If StringInStr($_CleSec, "Contenu de la") Then
  66.         $cle_sec = _ObtCleWifi($_CleSec)
  67.     Else
  68.         $cle_sec = ""
  69.     EndIf
  70.  
  71.     $information_wifi &= StringStripWS($SSID, 3) & "|" & $cle_sec & @CRLF
  72.     Return $information_wifi
  73.  
  74. EndFunc   ;==>_InformationWifi
  75.  
  76. Func _ObtCleWifi($cl)
  77.     $clesec = ""
  78.     For $a = 1 To StringSplit($cl, @LF)[0]
  79.         $ligne = StringSplit($cl, @LF)[$a]
  80.         If StringInStr($ligne, "Contenu de la") Then
  81.             $clesec = StringSplit($ligne, ":")[2]
  82.             $clesec = StringStripWS($clesec, 8)
  83.         EndIf
  84.     Next
  85.     Return $clesec
  86. EndFunc   ;==>_ObtCleWifi
  87.  
  88.  
  89.    
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement