Created
April 29, 2022 14:48
-
-
Save rbleattler/a1b2e2c90255d9ba966b155ae8b03bc9 to your computer and use it in GitHub Desktop.
A PowerShell Function that generates a nerdy output that can be run to reveal an e-mail address or other strings.
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
function New-NerdSignature { | |
param( | |
[Parameter(Mandatory)] | |
[string] | |
$EmailAddress, | |
[Parameter()] | |
[switch] | |
$AsBase64Command | |
) | |
$Raw = ($EmailAddress.ToCharArray() | ForEach-Object { ([int]$_ - 42) -as [string] }) # -join '' | |
$NewRaw = $Raw | |
$Raw.Where{ $PSitem.length -lt 2 }.ForEach{ | |
$Index = $NewRaw.IndexOf($_) | |
$NewRaw[$Index] = "0$_" | |
} | |
$MyString = $NewRaw -join '' | |
$EmailLength = $EmailAddress.Length - 1 | |
$Signature = "[string]::Concat((0..$EmailLength|%{[char][int](42+('$MyString').substring((`$_*2),2))}))" | |
if ($AsBase64Command) { | |
$Bytes = [System.Text.Encoding]::Unicode.GetBytes($Signature) | |
$Base64String = [Convert]::ToBase64String($Bytes) | |
$Signature = 'powershell.exe -noprofile -encodedcommand {0}' -f $Base64String | |
} | |
Write-Output $Signature | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment