Пример #1
0
        public void Export(string filename)
        {
            DisplayAdvancement("Starting");
            nrpc session = new nrpc();;

            DisplayAdvancement("Trusts obtained via null session");
            List <TrustedDomain> domains;
            int res = session.DsrEnumerateDomainTrusts(Server, 0x3F, out domains);

            if (res != 0)
            {
                DisplayAdvancement("Error " + res + " (" + new Win32Exception(res).Message + ")");
                return;
            }
            DisplayAdvancement("Success - " + domains.Count + " trusts found");
            using (StreamWriter sw = File.CreateText(filename))
            {
                sw.WriteLine("Trust index,DnsDomainName,NetbiosDomainName,TrustAttributes,TrustType,Flags,DomainGuid,DomainSid,ParentIndex");
                int i = 0;
                foreach (var domain in domains)
                {
                    sw.WriteLine(i++ + "\t" + domain.DnsDomainName + "\t" + domain.NetbiosDomainName + "\t" +
                                 TrustAnalyzer.GetTrustAttribute(domain.TrustAttributes) + " (" + domain.TrustAttributes + ")" + "\t" +
                                 TrustAnalyzer.GetTrustType(domain.TrustType) + " (" + domain.TrustType + ")" + "\t" + domain.Flags + "\t" +
                                 domain.DomainGuid + "\t" + domain.DomainSid + "\t" + domain.ParentIndex);
                }
            }
        }
Пример #2
0
 public bool NullTrustsTask()
 {
     return(StartTask("Null Session",
                      () =>
     {
         nrpc session = new nrpc();;
         Console.WriteLine("Trusts obtained via null session");
         List <TrustedDomain> domains;
         int res = session.DsrEnumerateDomainTrusts(Server, 0x3F, out domains);
         if (res != 0)
         {
             Console.WriteLine("Error " + res + " (" + new Win32Exception(res).Message + ")");
             return;
         }
         Console.WriteLine("Success");
         int i = 0;
         foreach (var domain in domains)
         {
             Console.WriteLine("=== Trust " + i++ + "===");
             Console.WriteLine("DnsDomainName: " + domain.DnsDomainName);
             Console.WriteLine("NetbiosDomainName: " + domain.NetbiosDomainName);
             Console.WriteLine("TrustAttributes: " + TrustAnalyzer.GetTrustAttribute(domain.TrustAttributes) + " (" + domain.TrustAttributes + ")");
             Console.WriteLine("TrustType: " + TrustAnalyzer.GetTrustType(domain.TrustType) + " (" + domain.TrustType + ")");
             Console.WriteLine("Flags: " + domain.Flags);
             Console.WriteLine("DomainGuid: " + domain.DomainGuid);
             Console.WriteLine("DomainSid: " + domain.DomainSid);
             Console.WriteLine("ParentIndex: " + domain.ParentIndex);
         }
     }
                      ));
 }