Created
September 12, 2016 02:38
-
-
Save herrcore/44eff024165b4a08dd1de3129428cba4 to your computer and use it in GitHub Desktop.
Use host specific attributes to generate asprox ID and ID_Key unique to host.
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
<# | |
.SYNOPSIS | |
Generate asprox ID and ID_Key. | |
.DESCRIPTION | |
Use host specific attributes to generate asprox ID and ID_Key unique to host. | |
.NOTES | |
File Name : asprox_id.ps1 | |
Author : @herrcore | |
Prerequisite : PowerShell V2 over Vista and upper. | |
#> | |
$sUsername = [Environment]::UserName | |
$bUsername = [system.Text.Encoding]::UTF8.GetBytes($sUsername) | |
$objUser = New-Object System.Security.Principal.NTAccount($sUserName) | |
$strSID = $objUser.Translate([System.Security.Principal.SecurityIdentifier]) | |
$bSid = New-Object 'byte[]' $strSID.BinaryLength | |
$strSID.GetBinaryForm($bSid,0) | |
if([IntPtr]::Size -eq 4){ | |
$key="hklm:\software\microsoft\windows nt\currentversion" | |
$data = Get-ItemProperty -Path $key -Name "InstallDate" | |
$bInstallDate = [System.BitConverter]::GetBytes($data.InstallDate) | |
} | |
Else{ | |
#account for error in asprox wow64 reg key lookup | |
$bInstallDate = [System.BitConverter]::GetBytes(0x0000) | |
} | |
$md5 = new-object -TypeName System.Security.Cryptography.MD5CryptoServiceProvider | |
$utf8 = new-object -TypeName System.Text.UTF8Encoding | |
$hash = [System.BitConverter]::ToString($md5.ComputeHash($bSid + $bInstallDate + $bUsername)) | |
$Id = $hash -replace '-','' | |
$IdKey = $Id.Substring(0,8) | |
echo "ID: $Id" | |
echo "ID Key: $IdKey" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment