Added thousands, -PostPinText and custom output file name
This commit is contained in:
@@ -1,59 +1,63 @@
|
|||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param (
|
param (
|
||||||
[switch]$UseMMDD
|
[switch]$UseMMDD,
|
||||||
|
[string]$PinOrder = "SameDigits,Sequences,AdjacentPairs,Years,Thousands,DuoCombinations,DateDDMM,DateMMDD,DoubleDigits", # Default order
|
||||||
|
[string]$PostPinText = "", # Custom text to append after each pin
|
||||||
|
[string]$OutputFile = "pin_codes.txt" # Default output file name
|
||||||
)
|
)
|
||||||
|
|
||||||
# Define the list of "very easy" numbers
|
function PostPin {
|
||||||
$veryEasyNumbers = @(0, 1, 2, 3, 4, 5, 6, 7, 8, 9) | ForEach-Object {
|
param (
|
||||||
|
[string]$pin,
|
||||||
|
[string]$text
|
||||||
|
)
|
||||||
|
return "$pin$text"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Define the list of "SameDigits" numbers
|
||||||
|
$SameDigitsNumbers = @(0, 1, 2, 3, 4, 5, 6, 7, 8, 9) | ForEach-Object {
|
||||||
$_.ToString() * 4 # Four identical digits
|
$_.ToString() * 4 # Four identical digits
|
||||||
}
|
}
|
||||||
|
|
||||||
# Define the list of "easy" numbers consisting of adjacent duos
|
# Define the list of "Sequences" numbers
|
||||||
$adjacentEasyNumbers = @(0, 1, 2, 3, 4, 5, 6, 7, 8, 9) | ForEach-Object {
|
$conseqNumbers = @()
|
||||||
|
for ($i = 0; $i -le 6; $i++) {
|
||||||
|
$sequence = $i..($i + 3) -join ''
|
||||||
|
$conseqNumbers += $sequence
|
||||||
|
}
|
||||||
|
|
||||||
|
# Define the list of "AdjacentPairs" numbers
|
||||||
|
$AdjacentPairsNumbers = @(0, 1, 2, 3, 4, 5, 6, 7, 8, 9) | ForEach-Object {
|
||||||
"{0}{0}{1}{1}" -f $_, (($_ + 1) % 10) # Two pairs of digits
|
"{0}{0}{1}{1}" -f $_, (($_ + 1) % 10) # Two pairs of digits
|
||||||
}
|
}
|
||||||
|
|
||||||
# Initialize an empty array to store the sequences
|
# Define the list of "Years" numbers
|
||||||
$conseqnumbers = @()
|
$YearsNumbers = @()
|
||||||
|
for ($year = 1900; $year -le (Get-Date).Year; $year++) {
|
||||||
# Loop through the range and generate sequences
|
$YearsNumbers += $year
|
||||||
for ($i = 0; $i -le 6; $i++) {
|
|
||||||
$sequence = $i..($i + 3) -join ''
|
|
||||||
$conseqnumbers += $sequence
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Define the list of "easy" numbers consisting of all combinations of 2 duos
|
# Define the list of "Thousands" numbers
|
||||||
$easyNumbers = @(0..9) | ForEach-Object {
|
$ThousandsNumbers = @(1, 2, 3, 4, 5, 6, 7, 8, 9) | ForEach-Object {
|
||||||
|
($_ * 1000).ToString()
|
||||||
|
}
|
||||||
|
|
||||||
|
# Define the list of "DuoCombinations" numbers
|
||||||
|
$DuoCombinationsNumbers = @(0..9) | ForEach-Object {
|
||||||
$firstDuo = "{0}{0}" -f $_
|
$firstDuo = "{0}{0}" -f $_
|
||||||
@(0..9) | ForEach-Object {
|
@(0..9) | ForEach-Object {
|
||||||
$secondDuo = "{0}{0}" -f $_
|
$secondDuo = "{0}{0}" -f $_
|
||||||
$number = "{0}{1}{2}{3}" -f $firstDuo[0], $firstDuo[1], $secondDuo[0], $secondDuo[1]
|
$number = "{0}{1}{2}{3}" -f $firstDuo[0], $firstDuo[1], $secondDuo[0], $secondDuo[1]
|
||||||
if ($veryEasyNumbers + $adjacentEasyNumbers -notcontains $number) {
|
if ($SameDigitsNumbers + $AdjacentPairsNumbers -notcontains $number) {
|
||||||
$number
|
$number
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Define the list of year numbers
|
# Define the list of "DateDDMM" numbers
|
||||||
$YearNumbers = @()
|
|
||||||
|
|
||||||
# Loop through all years from 1900 to the current year
|
|
||||||
for ($year = 1900; $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 $_
|
|
||||||
}
|
|
||||||
|
|
||||||
# Initialize an empty array to store the dates
|
|
||||||
$datesddmm = @()
|
$datesddmm = @()
|
||||||
|
for ($month = 1; $month -le 12; $month++) {
|
||||||
# Loop through all possible dates in DDMM format
|
for ($day = 1; $day -le 31; $day++) {
|
||||||
for ($month = 1; $month -le 12; $month++) {
|
|
||||||
for ($day = 1; $day -le 31; $day++) {
|
|
||||||
$formattedDay = "{0:D2}" -f $day
|
$formattedDay = "{0:D2}" -f $day
|
||||||
$formattedMonth = "{0:D2}" -f $month
|
$formattedMonth = "{0:D2}" -f $month
|
||||||
$date = $formattedDay + $formattedMonth
|
$date = $formattedDay + $formattedMonth
|
||||||
@@ -61,10 +65,8 @@ for ($day = 1; $day -le 31; $day++) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Initialize an empty array to store the dates
|
# Define the list of "DateMMDD" numbers
|
||||||
$datesmmdd = @()
|
$datesmmdd = @()
|
||||||
|
|
||||||
# Loop through all possible dates in MMDD format
|
|
||||||
for ($month = 1; $month -le 12; $month++) {
|
for ($month = 1; $month -le 12; $month++) {
|
||||||
for ($day = 1; $day -le 31; $day++) {
|
for ($day = 1; $day -le 31; $day++) {
|
||||||
$formattedMonth = "{0:D2}" -f $month
|
$formattedMonth = "{0:D2}" -f $month
|
||||||
@@ -74,42 +76,64 @@ for ($month = 1; $month -le 12; $month++) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Define the list of "DoubleDigits" numbers
|
||||||
|
$doubleUnder100 = @(0..99) | ForEach-Object {
|
||||||
|
"{0:D2}{0:D2}" -f $_
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create a hashtable for easy lookup
|
||||||
|
$pinCategories = @{
|
||||||
|
"SameDigits" = $SameDigitsNumbers
|
||||||
|
"Sequences" = $conseqNumbers
|
||||||
|
"AdjacentPairs" = $AdjacentPairsNumbers
|
||||||
|
"Years" = $YearsNumbers
|
||||||
|
"Thousands" = $ThousandsNumbers
|
||||||
|
"DuoCombinations" = $DuoCombinationsNumbers
|
||||||
|
"DateDDMM" = $datesddmm
|
||||||
|
"DateMMDD" = $datesmmdd
|
||||||
|
"DoubleDigits" = $doubleUnder100
|
||||||
|
}
|
||||||
|
|
||||||
|
# Combine numbers based on the order specified in $PinOrder
|
||||||
|
$allNumbers = @()
|
||||||
|
$PinOrder.Split(",") | ForEach-Object {
|
||||||
|
if ($pinCategories.ContainsKey($_)) {
|
||||||
|
$allNumbers += $pinCategories[$_]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Generate all combinations from 0000 to 9999
|
# Generate all combinations from 0000 to 9999
|
||||||
$combinations = 0..9999 | ForEach-Object {
|
$combinations = 0..9999 | ForEach-Object {
|
||||||
"{0:D4}" -f $_
|
"{0:D4}" -f $_
|
||||||
}
|
}
|
||||||
|
|
||||||
# Determine the order in which to combine numbers based on the parameter
|
|
||||||
$alldates = @()
|
|
||||||
if ($UseMMDD) {
|
|
||||||
$alldates = $datesmmdd + $datesddmm
|
|
||||||
} else {
|
|
||||||
$alldates = $datesddmm + $datesmmdd
|
|
||||||
}
|
|
||||||
|
|
||||||
# Combine numbers
|
|
||||||
$allNumbers = $veryEasyNumbers + $conseqnumbers + $adjacentEasyNumbers + $YearNumbers + $easyNumbers + $alldates + $doubleUnder100
|
|
||||||
|
|
||||||
# Randomize the order of the non-easy numbers
|
# Randomize the order of the non-easy numbers
|
||||||
$nonEasyNumbers = $combinations | Where-Object {
|
$nonEasyNumbers = $combinations | Where-Object {
|
||||||
$allNumbers -notcontains $_
|
$allNumbers -notcontains $_
|
||||||
}
|
}
|
||||||
$randomizedNonEasyNumbers = $nonEasyNumbers | Get-Random -Count $nonEasyNumbers.Count
|
$randomizedNonEasyNumbers = $nonEasyNumbers | Get-Random -Count $nonEasyNumbers.Count
|
||||||
|
|
||||||
# Write numbers to a file
|
# Determine the output file path
|
||||||
|
if (-not [System.IO.Path]::IsPathRooted($OutputFile)) {
|
||||||
|
# If the path is not absolute, treat it as relative to the current directory
|
||||||
|
$scriptDir = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent
|
||||||
|
$filePath = Join-Path -Path $scriptDir -ChildPath $OutputFile
|
||||||
|
} else {
|
||||||
|
# If the path is absolute, use it directly
|
||||||
|
$filePath = $OutputFile
|
||||||
|
}
|
||||||
|
|
||||||
|
# Write numbers to a file with the PostPinText appended
|
||||||
$randomizedNumbers = @()
|
$randomizedNumbers = @()
|
||||||
foreach ($number in $allNumbers) {
|
foreach ($number in $allNumbers) {
|
||||||
if ($randomizedNumbers -notcontains $number) {
|
if ($randomizedNumbers -notcontains $number) {
|
||||||
$randomizedNumbers += $number
|
$randomizedNumbers += PostPin -pin $number -text $PostPinText
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$randomizedNonEasyNumbers | ForEach-Object {
|
$randomizedNonEasyNumbers | ForEach-Object {
|
||||||
if ($randomizedNumbers -notcontains $_) {
|
if ($randomizedNumbers -notcontains $_) {
|
||||||
$randomizedNumbers += $_
|
$randomizedNumbers += PostPin -pin $_ -text $PostPinText
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$scriptDir = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent
|
|
||||||
$filePath = Join-Path -Path $scriptDir -ChildPath "pin_codes.txt"
|
|
||||||
|
|
||||||
$randomizedNumbers | Out-File -FilePath $filePath
|
$randomizedNumbers | Out-File -FilePath $filePath
|
||||||
|
|||||||
Reference in New Issue
Block a user