#RequireAdmin
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Change2CUI=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <Constants.au3>
#include <Array.au3>
#include <String.au3>
#include <MsgBoxConstants.au3>
;If IsAdmin() Then MsgBox(64, "", "The script is running with admin rights.")
Func _GetDOSOutput($Command)
Local $iPid , $sOutput = ''
$iPid = Run('"' & @ComSpec & '" /C ' & $Command,"",@SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
While 1
$sOutput &= StdoutRead($iPid,False,False)
If @error Then
ExitLoop
EndIf
Sleep(10)
WEnd
Return $sOutput
EndFunc
Local $MyCmd = _GetDOSOutput('netsh wlan show profiles')
$sSSID = StringRegExp($MyCmd, '(?si)ے:\s(.*?)' &@CR,3)
;_ArrayDisplay($sSSID)
For $i=1 to Ubound($sSSID)
;If $sSSID[$i] <> "" Then
$GetPassword =_GetDOSOutput('netsh wlan show profiles '&chr(34)&$sSSID[$i]&chr(34)&' key=clear |find "Conten"')
ConsoleWrite( '[' & $i & '] ' & $sSSID[$i] & $GetPassword )
;EndIf
Next
Sleep(3000)
Après la compilation je rencontre un message d'erreur qui vient je crois de la dimension du tableau ?
le message est : "Error : Array variable has incorrect number of subscripts or subcript dimension range exceeded"
Merci de votre aide
Modifié en dernier par Hackoo le mer. 21 mars 2018 01:49, modifié 2 fois.
La connaissance s'acquiert par l'expérience, tout le reste n'est que de l'information. Albert Einstein
Le savoir est la seule matière qui s'accroît quand on la partage. Socrate
#RequireAdmin #Region ;**** Directives created by AutoIt3Wrapper_GUI **** ;#AutoIt3Wrapper_Change2CUI=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
Merci mdanielm pour votre rèponse
J'ai une question : Est-ce-qu'on peut changer la couleur de l'output de la console en vert comme dans le batch ?
Sinon si vous avez des remarques a citer, je suis à votre écoute
Voici le nouveau code :
#RequireAdmin #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseUpx=y #AutoIt3Wrapper_Change2CUI=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include<Constants.au3> #include<Array.au3> #include<String.au3> #include<MsgBoxConstants.au3> Global$Title="Wifi Passwords Recovery by Hackoo 2018" IfNotIsAdmin()ThenExitMsgBox(48,$Title,"This Application must be run with admin rights !") Global$MyCmd= _GetDOSOutput('netsh wlan show profiles') Global$res="" Global$Pass="" $sSSID=StringRegExp($MyCmd,'(?si)\s*.*?:\s*(.*?)'&@cr,3) For$i=1toUbound($sSSID)-1 $GetPassword=_GetDOSOutput('netsh wlan show profiles '&chr(34)&$sSSID[$i]&chr(34)& _ ' key=clear | find "Conten"') $pass=StringRegExp($GetPassword,":\s(.*)",3) $res&='['&$i&'] '&'['&$sSSID[$i]&']'&" =======> "&chr(34)&$pass[0]&chr(34)&@CRLF Next ConsoleWrite($res) sleep(10000) FileDelete("list.txt") FileWrite("list.txt",$res) ;-------------------------------------------------------------------------------------------------- Func _GetDOSOutput($Command) Local$iPid,$sOutput='' $iPid=Run('"'&@ComSpec&'" /C '&$Command,"",@SW_HIDE,$STDERR_CHILD+$STDOUT_CHILD) $sOutput&=StdoutRead($iPid,False,False) While@error=0 Sleep(10) $sOutput&=StdoutRead($iPid,False,False) WEnd Return$sOutput EndFunc ;--------------------------------------------------------------------------------------------------
La connaissance s'acquiert par l'expérience, tout le reste n'est que de l'information. Albert Einstein
Le savoir est la seule matière qui s'accroît quand on la partage. Socrate
Ta version plante si un réseau n'a pas de mot de passe.
Après la ligne $pass=... il faut tester @error et si <> 0 , ne pas utiliser $pass[0].
Moi, je ne peux pas utiliser la console, il s'affiche:
! Your script requires Admin rights while SciTE is running at normal level.
! This means no Console output from the script will be displayed and SciTE will show the script as ended right away.
@orax Merci ça marche 5/5 cette fonction
@mdanilem
! Your script requires Admin rights while SciTE is running at normal level.
! This means no Console output from the script will be displayed and SciTE will show the script as ended right away.
J'ai le même message que vous !
Effectivement, il faut compiler cette source avec la version console pour voir le résultat
#RequireAdmin #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=wifi.ico ; icon downloaded from [ http://www.iconarchive.com/show/action-circles-icons-by-fasticon/Circle-wifi-icon.html ] #AutoIt3Wrapper_UseUpx=y #AutoIt3Wrapper_Change2CUI=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include<Constants.au3> #include<Array.au3> #include<String.au3> #include<MsgBoxConstants.au3> #include<WinAPI.au3> #include<File.au3> Global$Title="Wifi Passwords Recovery by Hackoo 2018" IfNot@CompiledThenExitMsgBox(48,$Title,"Please compile this as a console application to see what this function does.");Exit if script is not compiled $dll=DllOpen("Kernel32.dll");Open Kernel32.dll because we will be using it a lot $hnd=_WinAPI_GetStdHandle(1);Get the AutoIt process's standard output handle _WinAPI_SetConsoleTextAttribute($hnd,"6",$dll);Change text color to Green (https://www.autoitscript.com/forum/topic/110218-_winapi_setconsoletextattribute/) Global$msg=""&@CRLF $msg&=" ***********************************************"&@CRLF $msg&=" "&$Title&@CRLF $msg&=" ***********************************************"&@CRLF $msg&=" [N] [SSID] ===============> "&Chr(34)&"Password"&Chr(34)&@CRLF&@CRLF ConsoleWrite($msg) IfNotIsAdmin()ThenExitMsgBox(48,$Title,"This Application must be run with admin rights !") Global$MyCmd= _GetDOSOutput('netsh wlan show profiles') Global$res="" Global$Pass="" $sSSID=StringRegExp($MyCmd,'(?si)\s*.*?:\s*(.*?)'&@CR,3) For$i=1ToUBound($sSSID)-1 $GetPassword= _GetDOSOutput('netsh wlan show profiles '&Chr(34)&$sSSID[$i]&Chr(34)& _ ' key=clear | find "Conten"') $Pass=StringRegExp($GetPassword,":\s(.*)",3) If$Pass[0]<>""Then _WinAPI_SetConsoleTextAttribute($hnd,"10",$dll) $res&=' ['&$i&'] '&'['&$sSSID[$i]&']'&" =======> "&Chr(34)&$Pass[0]&Chr(34)&@CRLF Else _WinAPI_SetConsoleTextAttribute($hnd,"4",$dll); Set color to Red $res&=' ['&$i&'] '&'['&$sSSID[$i]&']'&" =======> Password is empty !"&@CRLF EndIf Next ConsoleWrite($res) Local$sDrive="",$sDir="",$sFileName="",$sExtension="" Local$aPathSplit=_PathSplit(@ScriptFullPath,$sDrive,$sDir,$sFileName,$sExtension) FileDelete($sFileName&".txt") FileWrite($sFileName&".txt",$msg&$res) _WinAPI_SetConsoleTextAttribute($hnd,"11",$dll) ConsoleWrite(@CRLF& _ " All Wifi SSID with their passwords are extracted successfully !"&@CRLF& _ " Saved into file "&Chr(34)&$sFileName&".txt"&Chr(34)) While1;Hold script in a loop until closed Sleep(500) WEnd ;-------------------------------------------------------------------------------------------------- Func _GetDOSOutput($Command) Local$iPid,$sOutput='' $iPid=Run('"'&@ComSpec&'" /C '&$Command,"",@SW_HIDE,$STDERR_CHILD+$STDOUT_CHILD) $sOutput&=StdoutRead($iPid,False,False) While@error=0 Sleep(10) $sOutput&=StdoutRead($iPid,False,False) WEnd Return$sOutput EndFunc;==>_GetDOSOutput ;-------------------------------------------------------------------------------------------------- ; #FUNCTION# ==================================================================================================================== ; Name...........: _WinAPI_SetConsoleTextAttribute ; Description ...: Changes the text and/or background color of text in the Windows console. ; Syntax.........: _WinAPI_SetConsoleTextAttribute($hConsole, $iColor, $hDLL = "Kernel32.dll") ; Parameters ....: $hConsole - Handle to the console screen buffer ; $iColor - Color style to apply to the console. ; $hDLL - Handle to the DLL to call. (Leave blank to open Kernel32.dll each call) ; Return values .: Success - True ; Failure - False ; Author ........: Ken Piper (Kealper) ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........: @@MsdnLink@@ SetConsoleTextAttribute ; Example .......: ; =============================================================================================================================== Func _WinAPI_SetConsoleTextAttribute($hConsole,$iColor,$hDLL="Kernel32.dll") $ret=DllCall($hDLL,"BOOL","SetConsoleTextAttribute","HANDLE",$hConsole,"WORD",$iColor) If@errorThenReturnSetError(@error,@extended,False) Return$ret[0] EndFunc;==>_WinAPI_SetConsoleTextAttribute ;===============================================================================================================================
La connaissance s'acquiert par l'expérience, tout le reste n'est que de l'information. Albert Einstein
Le savoir est la seule matière qui s'accroît quand on la partage. Socrate
Voici la nouvelle version suite a vos remarques.
Alors, si quelqu'un parmi vous me teste si ça marche ou non ou bien si ce code doit-être optimisé ou non ? avant de passer en résolu
#RequireAdmin #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=wifi.ico ; icon downloaded from [ http://www.iconarchive.com/show/action-circles-icons-by-fasticon/Circle-wifi-icon.html ] #AutoIt3Wrapper_UseUpx=y #AutoIt3Wrapper_Change2CUI=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include<Constants.au3> #include<Array.au3> #include<String.au3> #include<MsgBoxConstants.au3> #include<WinAPI.au3> #include<File.au3> Global$Title="Wifi Passwords Recovery by Hackoo 2018" IfNot@CompiledThenExitMsgBox(48,$Title,"Please compile this as a console application to see what this function does.");Exit if script is not compiled $dll=DllOpen("Kernel32.dll");Open Kernel32.dll because we will be using it a lot $hnd=_WinAPI_GetStdHandle(1);Get the AutoIt process's standard output handle _WinAPI_SetConsoleTextAttribute($hnd,"6",$dll);Change text color to Green (https://www.autoitscript.com/forum/topic/110218-_winapi_setconsoletextattribute/) Global$msg=""&@CRLF $msg&=" ***********************************************"&@CRLF $msg&=" "&$Title&@CRLF $msg&=" ***********************************************"&@CRLF $msg&=" [N] [SSID] ===============> "&Chr(34)&"Password"&Chr(34)&@CRLF&@CRLF ConsoleWrite($msg) IfNotIsAdmin()ThenExitMsgBox(48,$Title,"This Application must be run with admin rights !") Global$MyCmd= _GetDOSOutput('netsh wlan show profiles') Global$res="" Global$Pass="" $sSSID=StringRegExp($MyCmd,'(?si)\s*.*?:\s*(.*?)'&@CR,3) For$i=1ToUBound($sSSID)-1 $GetPassword= _GetDOSOutput('netsh wlan show profiles '&Chr(34)&$sSSID[$i]&Chr(34)& _ ' key=clear | find "Conten"') $Pass=StringRegExp($GetPassword,":\s(.*)",3) If@error=0Then _WinAPI_SetConsoleTextAttribute($hnd,"10",$dll) $res&=' ['&$i&'] '&'['&$sSSID[$i]&']'&" =======> "&Chr(34)&$Pass[0]&Chr(34)&@CRLF Else _WinAPI_SetConsoleTextAttribute($hnd,"4",$dll); Set color to Red $res&=' ['&$i&'] '&'['&$sSSID[$i]&']'&" =======> Password is empty !"&@CRLF EndIf Next ConsoleWrite($res) Local$sDrive="",$sDir="",$sFileName="",$sExtension="" Local$aPathSplit=_PathSplit(@ScriptFullPath,$sDrive,$sDir,$sFileName,$sExtension) FileDelete($sFileName&".txt") FileWrite($sFileName&".txt",$msg&$res) _WinAPI_SetConsoleTextAttribute($hnd,"11",$dll) ConsoleWrite(@CRLF& _ " All Wifi SSID with their passwords are extracted successfully !"&@CRLF& _ " Saved into file "&Chr(34)&$sFileName&".txt"&Chr(34)) While1;Hold script in a loop until closed Sleep(500) WEnd ;-------------------------------------------------------------------------------------------------- Func _GetDOSOutput($Command) Local$iPid,$sOutput='' $iPid=Run('"'&@ComSpec&'" /C '&$Command,"",@SW_HIDE,$STDERR_CHILD+$STDOUT_CHILD) $sOutput&=StdoutRead($iPid,False,False) While@error=0 Sleep(10) $sOutput&=StdoutRead($iPid,False,False) WEnd Return$sOutput EndFunc;==>_GetDOSOutput ;-------------------------------------------------------------------------------------------------- ; #FUNCTION# ==================================================================================================================== ; Name...........: _WinAPI_SetConsoleTextAttribute ; Description ...: Changes the text and/or background color of text in the Windows console. ; Syntax.........: _WinAPI_SetConsoleTextAttribute($hConsole, $iColor, $hDLL = "Kernel32.dll") ; Parameters ....: $hConsole - Handle to the console screen buffer ; $iColor - Color style to apply to the console. ; $hDLL - Handle to the DLL to call. (Leave blank to open Kernel32.dll each call) ; Return values .: Success - True ; Failure - False ; Author ........: Ken Piper (Kealper) ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........: @@MsdnLink@@ SetConsoleTextAttribute ; Example .......: ; =============================================================================================================================== Func _WinAPI_SetConsoleTextAttribute($hConsole,$iColor,$hDLL="Kernel32.dll") $ret=DllCall($hDLL,"BOOL","SetConsoleTextAttribute","HANDLE",$hConsole,"WORD",$iColor) If@errorThenReturnSetError(@error,@extended,False) Return$ret[0] EndFunc;==>_WinAPI_SetConsoleTextAttribute ;===============================================================================================================================
La connaissance s'acquiert par l'expérience, tout le reste n'est que de l'information. Albert Einstein
Le savoir est la seule matière qui s'accroît quand on la partage. Socrate