Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # save the old Verbose pref
- $OldVPref = $VerbosePreference
- # enable verbose output
- $VerbosePreference = 'Continue'
- $URL = 'https://www.eff.org/files/2016/07/18/eff_large_wordlist.txt'
- $WordCount = 3
- $UpCaseCount = 4
- $NumberRange = 10..999
- $SourceDir = $env:TEMP
- $SourceFile = 'EFF_Large_Word_List.txt'
- $FullSourceFile = Join-Path -Path $SourceDir -ChildPath $SourceFile
- # if the file is there, use it
- # otherwise get from the URL and save it to the named file
- Write-Verbose 'Checking for local copy of word list ...'
- if (-not (Test-Path -Path $FullSourceFile))
- {
- Write-Verbose ' Local word list file NOT found - downloading a large-ish text file ...'
- (Invoke-RestMethod -Uri $URL).Split("`n").Trim() |
- Set-Content -LiteralPath $FullSourceFile
- Write-Verbose ' Local word list file saved.'
- }
- else
- {
- Write-Verbose ' Local word list file found.'
- }
- $SourceWordList = Get-Content -Path $FullSourceFile
- # convert the string of symbols to an array
- # the final "-ne" is to remove the blank array items from the split
- $SymbolChars = ('!@#$%^&()_-{}[]<>' -split '') -ne ''
- $WordList = Get-Random -InputObject $SourceWordList -Count $WordCount
- # each line = number<space>word, so take only the word
- $WordList = $WordList.ForEach({($_ -split '\s{1,}')[-1]})
- # title case each word
- $WordList = $WordList.ForEach({(Get-Culture).TextInfo.ToTitleCase($_)})
- # merge with spaces to make a passphrase
- $PassPhrase = $WordList -join ' '
- # merge the words into one lower case word
- $Password = (-join $WordList).ToLower()
- # get $UpCaseCount indexes for up-casing random letters in $Password
- $ChangeIndexList = Get-Random -InputObject (0..($Password.Length - 1)) -Count $UpCaseCount
- foreach ($CIL_Item in $ChangeIndexList)
- {
- $UCLetter = ([string]$Password[$CIL_Item]).ToUpper()
- $Password = $Password.Remove($CIL_Item,1).Insert($CIL_Item, $UCLetter)
- }
- $Password = -join (
- $Password,
- (Get-Random -InputObject $SymbolChars -Count 1),
- (Get-Random -InputObject $NumberRange -Count 1)
- )
- 'Password = {0}' -f $Password
- 'Pass phrase = {0}' -f $PassPhrase
- # restore previous VPref
- $VerbosePreference = $OldVPref
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement