From 723d0e21b82a4c27e5d962c2f48e446529504b00 Mon Sep 17 00:00:00 2001 From: Zarcolio Date: Sun, 20 Aug 2023 13:05:23 +0200 Subject: [PATCH] Add files via upload --- .../Offensive/Create-PwdDictAttack.ps1 | 43 +++++++++++++++---- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/BadUSB/Ducky Script Powershell/Offensive/Create-PwdDictAttack.ps1 b/BadUSB/Ducky Script Powershell/Offensive/Create-PwdDictAttack.ps1 index 6645638..ae6c0dc 100644 --- a/BadUSB/Ducky Script Powershell/Offensive/Create-PwdDictAttack.ps1 +++ b/BadUSB/Ducky Script Powershell/Offensive/Create-PwdDictAttack.ps1 @@ -1,12 +1,20 @@ -[CmdletBinding()] +[CmdletBinding()] param( [Parameter(Mandatory=$true, Position=0, HelpMessage="Path of the input file.")] [ValidateScript({Test-Path $_ -PathType Leaf})] [string]$InputFile, + [Parameter(Position=1, HelpMessage="Delay in milliseconds.")] [int]$Delay = 500, - [Parameter(Position=2, HelpMessage="Wait time in milliseconds.")] - [int]$Wait = $null + + [Parameter(Position=2, HelpMessage="Wait time in milliseconds if given, defaults to WAIT_FOR_BUTTON_PRESS.")] + [int]$Wait = $null, + + [Parameter(Position=3, HelpMessage="Select the processing mode: 'string' processes the entire input as a single string, 'char' processes each character separately. Default is 'string'.")] + [string]$StringMode = "string", + + [Parameter(Position=4, HelpMessage="Character delay in milliseconds. Applicable only in 'char' mode.")] + [int]$CharDelay = 500 ) # Determine output folder and file path @@ -16,17 +24,17 @@ if (-not $InputFile.Contains("\") -and -not $InputFile.Contains("/")) { $OutputFolder = Split-Path -Parent $InputFile if ([string]::IsNullOrWhiteSpace($OutputFolder)) { - Throw "Output folder cannot be determined from input file path." + Throw "Output folder cannot be determined from the input file path." } $OutputFile = Join-Path -Path $OutputFolder -ChildPath "Dict_Attack.txt" Write-Verbose "Output file path: $OutputFile" -# Create new output file or overwrite existing file +# Create a new output file or overwrite an existing file New-Item -ItemType File -Path $OutputFile -Force -ErrorAction Stop | Out-Null Write-Verbose "Output file created successfully: $OutputFile" -# Read input file and convert to ducky script +# Read input file and convert to Ducky Script $EnterKey = [char]13 $Lines = Get-Content $InputFile foreach ($Line in $Lines) { @@ -36,7 +44,26 @@ foreach ($Line in $Lines) { else { $WaitStr = "WAIT_FOR_BUTTON_PRESS" } - $command = "STRING $line`nDELAY $Delay`nENTER`n$WaitStr`n" - Add-Content -Path $OutputFile -Value $Command + + if ($StringMode -eq "string") { + $command = "ALTSTRING $Line`nDELAY $Delay`nENTER`n$WaitStr`n" + Add-Content -Path $OutputFile -Value $command + } + elseif ($StringMode -eq "char") { + $charArray = $Line.ToCharArray() + $charCount = $charArray.Length + for ($i = 0; $i -lt $charCount; $i++) { + $char = $charArray[$i] + $command = "ALTSTRING $char`nDELAY $CharDelay" + Add-Content -Path $OutputFile -Value $command + if ($i -ne ($charCount - 1)) { + Add-Content -Path $OutputFile -Value "DELAY $CharDelay" + } + } + Add-Content -Path $OutputFile -Value "DELAY $Wait`n" + } + else { + Write-Error "Invalid value for StringMode parameter. Supported values: 'string', 'char'." + } } Write-Verbose "Conversion complete."