Add files via upload
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
[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
|
||||
)
|
||||
|
||||
# Determine output folder and file path
|
||||
if (-not $InputFile.Contains("\") -and -not $InputFile.Contains("/")) {
|
||||
$InputFile = Join-Path -Path (Get-Location) -ChildPath $InputFile
|
||||
}
|
||||
|
||||
$OutputFolder = Split-Path -Parent $InputFile
|
||||
if ([string]::IsNullOrWhiteSpace($OutputFolder)) {
|
||||
Throw "Output folder cannot be determined from 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
|
||||
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
|
||||
$EnterKey = [char]13
|
||||
$Lines = Get-Content $InputFile
|
||||
foreach ($Line in $Lines) {
|
||||
if ($Wait) {
|
||||
$WaitStr = "DELAY $Wait"
|
||||
}
|
||||
else {
|
||||
$WaitStr = "WAIT_FOR_BUTTON_PRESS"
|
||||
}
|
||||
$command = "STRING $line`nDELAY $Delay`nENTER`n$WaitStr`n"
|
||||
Add-Content -Path $OutputFile -Value $Command
|
||||
}
|
||||
Write-Verbose "Conversion complete."
|
||||
@@ -0,0 +1,66 @@
|
||||
# Define the list of "very easy" numbers
|
||||
$veryEasyNumbers = @(0, 1, 2, 3, 4, 5, 6, 7, 8, 9) | ForEach-Object {
|
||||
$_.ToString() * 4 # Four identical digits
|
||||
}
|
||||
$veryEasyNumbers += "1234" # The sequence "1234"
|
||||
|
||||
# Define the list of "easy" numbers consisting of adjacent duos
|
||||
$adjacentEasyNumbers = @(0, 1, 2, 3, 4, 5, 6, 7, 8, 9) | ForEach-Object {
|
||||
"{0}{0}{1}{1}" -f $_, (($_ + 1) % 10) # Two pairs of digits
|
||||
}
|
||||
|
||||
# Define the list of "easy" numbers consisting of all combinations of 2 duos
|
||||
$easyNumbers = @(0..9) | ForEach-Object {
|
||||
$firstDuo = "{0}{0}" -f $_
|
||||
@(0..9) | ForEach-Object {
|
||||
$secondDuo = "{0}{0}" -f $_
|
||||
$number = "{0}{1}{2}{3}" -f $firstDuo[0], $firstDuo[1], $secondDuo[0], $secondDuo[1]
|
||||
if ($veryEasyNumbers + $adjacentEasyNumbers -notcontains $number) {
|
||||
$number
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Define the list of year numbers
|
||||
$YearNumbers = @()
|
||||
|
||||
# Loop through all years from 1901 to the current year
|
||||
for ($year = 1901; $year -le (Get-Date).Year; $year++) {
|
||||
# Add the year to the array
|
||||
$YearNumbers += $year
|
||||
}
|
||||
|
||||
# Define the list of "easy" numbers consisting of all combinations under 100, twice
|
||||
$doubleUnder100 = @(0..99) | ForEach-Object {
|
||||
"{0:D2}{0:D2}" -f $_
|
||||
}
|
||||
|
||||
# Generate all combinations from 0000 to 9999
|
||||
$combinations = 0..9999 | ForEach-Object {
|
||||
"{0:D4}" -f $_
|
||||
}
|
||||
|
||||
# Randomize the order of the non-easy numbers
|
||||
$nonEasyNumbers = $combinations | Where-Object {
|
||||
$veryEasyNumbers + $adjacentEasyNumbers + $easyNumbers -notcontains $_
|
||||
}
|
||||
$randomizedNonEasyNumbers = $nonEasyNumbers | Get-Random -Count $nonEasyNumbers.Count
|
||||
|
||||
# Combine the easy, double under 100, and non-easy numbers and write to a file
|
||||
$allNumbers = $veryEasyNumbers + $adjacentEasyNumbers + $YearNumbers + $easyNumbers + $doubleUnder100
|
||||
$randomizedNumbers = @()
|
||||
foreach ($number in $allNumbers) {
|
||||
if ($randomizedNumbers -notcontains $number) {
|
||||
$randomizedNumbers += $number
|
||||
}
|
||||
}
|
||||
$randomizedNonEasyNumbers | ForEach-Object {
|
||||
if ($randomizedNumbers -notcontains $_) {
|
||||
$randomizedNumbers += $_
|
||||
}
|
||||
}
|
||||
|
||||
$scriptDir = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent
|
||||
$filePath = Join-Path -Path $scriptDir -ChildPath "pin_codes.txt"
|
||||
|
||||
$randomizedNumbers | Out-File -FilePath $filePath
|
||||
@@ -0,0 +1,81 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Converts an existing PowerShell script to a Ducky Script.
|
||||
|
||||
.DESCRIPTION
|
||||
This script reads the contents of an existing PowerShell script, converts each line to Ducky Script format,
|
||||
and saves the result to the specified output file. If the output file is not provided, it replaces the extension
|
||||
of the existing PowerShell script with .txt.
|
||||
|
||||
.PARAMETER ExistingPs1File
|
||||
The path to the existing PowerShell script to convert.
|
||||
|
||||
.PARAMETER OutputDuckyScript
|
||||
The path for the output Ducky Script file. If not provided, it replaces the extension of the existing PowerShell
|
||||
script with .txt.
|
||||
|
||||
.EXAMPLE
|
||||
ConvertToDucky.ps1 -ExistingPs1File "C:\Path\To\Existing.ps1" -OutputDuckyScript "C:\Path\To\Output.txt"
|
||||
#>
|
||||
|
||||
param (
|
||||
[Parameter(Mandatory = $true, Position = 0)]
|
||||
[ValidateScript({Test-Path $_ -PathType 'Leaf'})]
|
||||
[string]$ExistingPs1File,
|
||||
|
||||
[Parameter(Mandatory = $false, Position = 1)]
|
||||
[string]$OutputDuckyScript
|
||||
)
|
||||
|
||||
# Check if the output Ducky Script file is provided
|
||||
if (-not $OutputDuckyScript) {
|
||||
# Replace the extension of the existing PowerShell script with .txt
|
||||
$OutputDuckyScript = $ExistingPs1File -replace '\.ps1$', '.txt'
|
||||
}
|
||||
|
||||
# Initial Ducky Script commands
|
||||
$initialDuckyScript = @"
|
||||
DELAY 1000
|
||||
GUI r
|
||||
DELAY 1000
|
||||
STRING powershell
|
||||
ENTER
|
||||
DELAY 2000
|
||||
|
||||
"@
|
||||
|
||||
# Read the contents of the existing .ps1 file
|
||||
$ps1Contents = Get-Content -Path $ExistingPs1File
|
||||
|
||||
# Initialize the Ducky Script variable
|
||||
$duckyScript = ""
|
||||
|
||||
# Convert each line of the PowerShell script to Ducky Script
|
||||
foreach ($line in $ps1Contents) {
|
||||
# Remove leading and trailing whitespace from the line
|
||||
$line = $line.Trim()
|
||||
|
||||
# Ignore empty lines or lines starting with '#'
|
||||
if (-not [string]::IsNullOrWhiteSpace($line) -and -not $line.StartsWith("#")) {
|
||||
# Check if the line contains special characters
|
||||
$containsSpecialChars = $line -match '[~`^''"]'
|
||||
|
||||
if ($containsSpecialChars) {
|
||||
# Use ALTCODE command for lines with special characters
|
||||
$duckyScript += "ALTCODE $line`r`n"
|
||||
}
|
||||
else {
|
||||
# Use STRING command for lines without special characters
|
||||
$duckyScript += "STRING $line`r`n"
|
||||
}
|
||||
}
|
||||
$duckyScript += "ENTER`r`n"
|
||||
}
|
||||
|
||||
# Combine the initial Ducky Script commands with the converted PowerShell script
|
||||
$finalDuckyScript = $initialDuckyScript + $duckyScript
|
||||
|
||||
# Write the combined Ducky Script to the output file
|
||||
$finalDuckyScript | Out-File -FilePath $OutputDuckyScript -Encoding ASCII
|
||||
|
||||
Write-Verbose "Conversion completed. The Ducky Script file has been saved at: $OutputDuckyScript"
|
||||
@@ -0,0 +1,35 @@
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(Mandatory=$true)][string]$InputFile
|
||||
)
|
||||
|
||||
# Check if the input file exists
|
||||
if (-not (Test-Path $InputFile)) {
|
||||
Write-Error "The input file does not exist."
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Read the contents of the input file
|
||||
$content = Get-Content -Path $InputFile
|
||||
|
||||
# Initialize an empty array to hold the updated lines
|
||||
$updatedContent = @()
|
||||
|
||||
foreach($line in $content) {
|
||||
if($line -match "[~``'^`]"){
|
||||
$updatedLine = $line.Replace("STRING", "ALTCODE")
|
||||
$updatedContent += $updatedLine
|
||||
} else {
|
||||
$updatedContent += $line
|
||||
}
|
||||
}
|
||||
|
||||
# Remove lines equal to "STRING" after trimming
|
||||
$updatedContent = $updatedContent.Trim() -replace "(`n|^)STRING(`n|$)", ""
|
||||
|
||||
|
||||
# Prepare the output file name by adding "-edit" before the file extension
|
||||
$outputFile = [System.IO.Path]::GetFileNameWithoutExtension($InputFile) + "-edit" + [System.IO.Path]::GetExtension($InputFile)
|
||||
|
||||
# Write the updated content to the output file
|
||||
Set-Content -Path $outputFile -Value $updatedContent
|
||||
@@ -0,0 +1,26 @@
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(Mandatory=$true)][string]$InputFile
|
||||
)
|
||||
|
||||
# Check if the input file exists
|
||||
if (-not (Test-Path $InputFile)) {
|
||||
Write-Error "The input file does not exist."
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Read the contents of the input file
|
||||
$content = Get-Content -Path $InputFile
|
||||
|
||||
# Replace the specified characters in the content
|
||||
$updatedContent = $content -replace "([~`'""^])", "$('${1}' * 2)`nBACKSPACE`nSTRING "
|
||||
|
||||
# Remove lines equal to "STRING" after trimming
|
||||
$updatedContent = $updatedContent.Trim() -replace "(`n|^)STRING(`n|$)", ""
|
||||
|
||||
|
||||
# Prepare the output file name by adding "-edit" before the file extension
|
||||
$outputFile = [System.IO.Path]::GetFileNameWithoutExtension($InputFile) + "-edit" + [System.IO.Path]::GetExtension($InputFile)
|
||||
|
||||
# Write the updated content to the output file
|
||||
Set-Content -Path $outputFile -Value $updatedContent
|
||||
Reference in New Issue
Block a user