(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
}
Watch video PowerShell - Crack password protected file online, duration hours minute second in high quality that is uploaded to the channel Mr Automation 26 May 2021. Share the link to the video on social media so that your subscribers and friends will also watch this video. This video clip has been viewed 917 times and liked it 15 visitors.