Page 1 sur 1
[R] Wifi Passwords Recovery by Hackoo
Posté : jeu. 08 mars 2018 13:42
par Hackoo
Salut tout le monde
Je suis entrain de "traduire" mon batch
Wifi Passwords Recovery.bat vers Autoit.
Image d'écran du batch :

► Afficher le texteWifi Passwords Recovery.au3
Code : Tout sélectionner
#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

Re: Wifi Passwords Recovery
Posté : jeu. 08 mars 2018 16:47
par mdanielm
A toi de peaufiner:
#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.")Global $MyCmd = _GetDOSOutput
('netsh wlan show profiles')$sSSID = StringRegExp($MyCmd, '(?si)\s*.*?:\s*(.*?)' & @cr, 3)Global $res = ""For $i=1 to Ubound($sSSID)-1;If $sSSID[$i] <> "" Then $GetPassword =_GetDOSOutput
('netsh wlan show profiles '& chr(34) & $sSSID[$i] & chr(34) & _
' key=clear | find "Conten"') $res &= '[' & $i & '] ' & $sSSID[$i] & $GetPassword & @crlf;EndIfNextFileDelete("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 $sOutputEndFunc
Re: Wifi Passwords Recovery
Posté : jeu. 08 mars 2018 20:37
par Hackoo
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 :
► Afficher le texteWifi Passwords Recovery.au3
#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"If Not IsAdmin() Then Exit MsgBox(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=1 to Ubound($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) & @CRLFNextConsoleWrite($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 $sOutputEndFunc;--------------------------------------------------------------------------------------------------
Re: Wifi Passwords Recovery
Posté : ven. 09 mars 2018 00:55
par orax
Pour écrire en couleur dans la console :
SetConsoleTextAttribute.
Re: Wifi Passwords Recovery
Posté : ven. 09 mars 2018 05:04
par mdanielm
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.
Re: Wifi Passwords Recovery
Posté : ven. 09 mars 2018 13:30
par Hackoo
@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
► Afficher le texteWifi Passwords Recovery.au3
#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"If Not @Compiled Then Exit MsgBox(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 & @CRLFConsoleWrite($msg)If Not IsAdmin() Then Exit MsgBox(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 = 1 To UBound($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 EndIfNextConsoleWrite($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))While 1 ;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 $sOutputEndFunc ;==>_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 @error Then Return SetError(@error, @extended, False) Return $ret[0]EndFunc ;==>_WinAPI_SetConsoleTextAttribute;===============================================================================================================================
Re: Wifi Passwords Recovery
Posté : ven. 09 mars 2018 17:36
par TommyDDR
Si vous voulez éviter ce message, lancer SciTe avec les droits d'administrateur.
Re: Wifi Passwords Recovery
Posté : ven. 09 mars 2018 19:53
par mdanielm
Toujours pas. Remplace. If $pass[0] <> 0. par. If @error = 0
[R] Wifi Passwords Recovery by Hackoo
Posté : mer. 14 mars 2018 09:57
par Hackoo
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
► Afficher le texteWifi Passwords Recovery
#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"If Not @Compiled Then Exit MsgBox(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 & @CRLFConsoleWrite($msg)If Not IsAdmin() Then Exit MsgBox(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 = 1 To UBound($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 = 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 EndIfNextConsoleWrite($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))While 1 ;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 $sOutputEndFunc ;==>_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 @error Then Return SetError(@error, @extended, False) Return $ret[0]EndFunc ;==>_WinAPI_SetConsoleTextAttribute;===============================================================================================================================