Created
March 14, 2023 22:37
-
-
Save Sp5rky/5c969f7a4272768a1a7307b641916448 to your computer and use it in GitHub Desktop.
Generates a password from wordlist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Generate a random password from a list of words and a special character | |
# Get the list of words from a URL | |
$url = 'https://gist.githubusercontent.com/Sp5rky/8d3b36dad42a2a71dd142ca80f481484/raw/5356681469364a377b506c57c03ac6dedc17be7c/gistfile1.txt' | |
$content = Invoke-WebRequest -Uri $url | Select-Object -ExpandProperty Content | |
$lines = $content -split "`n" | |
# Pick two random words from the list | |
$randomLine1 = $lines | Get-Random | |
$randomLine2 = $lines | Get-Random | |
# Define a string of special characters | |
$specialChars = '!', '@', '#', '$', '*', '%' | |
# Pick one random special character from the string | |
$randomSpecialChar1 = $specialChars | Get-Random -Count 1 | |
$randomSpecialChar2 = $specialChars | Get-Random -Count 1 | |
# Concatenate the two words and the special character to form the password | |
$password = $randomLine1 + $randomSpecialChar1 + $randomLine2 | |
if ($password.length -ge 12) { | |
# adds 23! to password if password at least 12 characters | |
$password += ('23' + $randomSpecialChar2) | |
} | |
elseif ($password.length -ge 10) { | |
# adds 2023! to password if password is between 10-12 characters | |
$password += ('2023' + $randomSpecialChar2) | |
} | |
if ($password.length -lt 10) { | |
# adds another word from $ShortName and then adds 23! to the end if its less than 10 characters | |
$randomLine = $lines | Get-Random | |
$password += $randomLine | |
$password += ('23' + $randomSpecialChar2) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment