PowerShell - Crack password protected file

Опубликовано: 26 Май 2021
на канале: Mr Automation
917
15

(How to crack a password protected rarfile with powershell)
In this video i demonstrate how you can crack a password protected rarfile with a dictionary.

*powershell
*learn powershell
*automation
*learn automation
*windows
*windows powershell

Code :


$CWD = Split-Path -parent $MyInvocation.MyCommand.Definition #Current Dir of script

$RARFile = "$CWD\passwords.rar"
$RARFile = """$RARFile"""

$Passwords = Get-Content "$($CWD)\passwords.txt"
$Passwords += Get-Content "$($CWD)\passwords2.txt"

$pinfo = New-Object System.Diagnostics.ProcessStartInfo
$p = New-Object System.Diagnostics.Process

#$Command = "C:\Program Files\WinRAR\UNRAR.exe"
$Command = Get-ChildItem 'C:\Program Files', 'C:\Program Files (x86)' `
-Filter unrar.exe -Recurse -ErrorAction SilentlyContinue |
Select-Object -ExpandProperty fullname

if(-not(test-path $Command)){
Write-Error "could not find winrar"
exit 1
}

#loop all password find hit and exit loop and extract the file, the more dictionaries the better ofcourse
Foreach ($Pw in $Passwords) {
$NewPass = """$pw"""
$Params = "E -inul -y $($RARFile) -p$($NewPass)"

#$p = Start-Process -FilePath $Command -ArgumentList $Params -Wait -PassThru -WindowStyle Hidden


$pinfo.FileName = $Command
$pinfo.RedirectStandardError = $true
$pinfo.RedirectStandardOutput = $true
$pinfo.UseShellExecute = $false
$pinfo.Arguments = $Params

$p.StartInfo = $pinfo
$p.Start() | Out-Null
$p.WaitForExit()
$stdout = $p.StandardOutput.ReadToEnd()
$stderr = $p.StandardError.ReadToEnd()

#this can used if the program supports stdout and stderr streams.

If ($p.ExitCode -eq 0) {
Write-Host "The password for file '$RARFile' = $Pw" -ForegroundColor Green
exit 0
}
else {
Write-Host "$Pw is NOT correct, we continue trying" -ForegroundColor Yellow
}

$NewPass = $null
$Params = $null

}


Смотрите видео PowerShell - Crack password protected file онлайн, длительностью часов минут секунд в хорошем качестве, которое загружено на канал Mr Automation 26 Май 2021. Делитесь ссылкой на видео в социальных сетях, чтобы ваши подписчики и друзья так же посмотрели это видео. Данный видеоклип посмотрели 917 раз и оно понравилось 15 посетителям.