-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRSA_BIND_ID.ps1
30 lines (28 loc) · 1.02 KB
/
RSA_BIND_ID.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Function Get-BindID
{
Write-Verbose -Message "Gathering strings"
#Gather information to become the RSA Binding ID
$RSA = 'RSA Copyright 2008'
$SID = [wmi] "win32_userAccount.Domain='$Env:USERDOMAIN',Name='$ENV:UserName'" | Select-Object -ExpandProperty SID
$RSASTRING = $env:COMPUTERNAME + $SID + $RSA #String to be hashed
Write-Verbose -Message "$env:COMPUTERNAME"
Write-Verbose -Message "$SID"
Write-Verbose -Message "$RSA"
#Create a SHA1 hash to the $RSASTRING
$sha1 = [Type]"System.Security.Cryptography.SHA1"
$crypto = $sha1::Create()
$utf8 = New-Object -TypeName System.Text.UTF8Encoding
$Hash = [System.BitConverter]::ToString(
$crypto.ComputeHash(
$utf8.GetBytes(
"${RSASTRING}"
)
)
).Replace(
"-", ""
)
$BindID = $Hash.SubString(
0, 20 #Character length of the RSA Binding ID.
)
Write-Output $BindID
} #Function Get-BindID