public override int GetHashCode()
        {
            int hash = 1;

            if (NymX.Length != 0)
            {
                hash ^= NymX.GetHashCode();
            }
            if (NymY.Length != 0)
            {
                hash ^= NymY.GetHashCode();
            }
            if (Ou.Length != 0)
            {
                hash ^= Ou.GetHashCode();
            }
            if (Role.Length != 0)
            {
                hash ^= Role.GetHashCode();
            }
            if (Proof.Length != 0)
            {
                hash ^= Proof.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Пример #2
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (ouHeld != null)
        {
            if (other.gameObject.layer == nestLayer && ouHeld.pairColor == other.GetComponent <Nest>().pairColor)
            {
                couldHatch = true;
            }
        }

        else if (other.gameObject.layer == ouLayer)
        {
            Ou otherOu = other.GetComponent <Ou>();

            if (!otherOu.isHeld)
            {
                if (otherOu.owner == null || otherOu.owner == this)
                {
                    if (hatchlingHeld == null)
                    {
                        ouHeld = otherOu;
                        ouHeld.GrabHold(this);
                        ouHeld.transform.localPosition = carryPosition;
                    }
                }
                else
                {
                    Destroy(other.gameObject);
                    if (stunIndicatorInProgress == null)
                    {
                        stunIndicatorInProgress        = Instantiate(stunIndicator, transform, false).GetComponent <StunIndicator>();
                        stunIndicatorInProgress.player = this;
                    }
                    if (hatchlingHeld != null)
                    {
                        Destroy(hatchlingHeld.gameObject);
                        hatchlingHeld = null;
                    }
                }
            }
        }

        if (hatchlingHeld != null)
        {
            if (other.gameObject.layer == houseLayer)
            {
                if (other.GetComponent <House>().pairColor == hatchlingHeld.pairColor)
                {
                    score += scoreGainOnMatching;
                }
                else
                {
                    score += scoreGainOnNonmatching;
                }
                Destroy(hatchlingHeld.gameObject);
                hatchlingHeld = null;
            }
        }
    }
Пример #3
0
        /// <summary>
        ///   Adds a Ou to a given parent ou
        /// </summary>
        /// <param name = "ouName">The new ou name</param>
        /// <param name = "parentId">The new parent id</param>
        /// <returns>IOu</returns>
        public IOu CreateOu(string ouName, int parentId)
        {
            try
            {
                if (_ous == null)
                {
                    BuildOuListing();
                }

                var sql = string.Format("insert into ous values( null, '{0}' , '{1}' , '' )", ouName, parentId);

                if (Framework.Database.IsConnected() == false)
                {
                    return(null);
                }

                if (Framework.Database.ExecuteNonQuery(sql) > 0)
                {
                    sql = string.Format("select * from ous where ou_id = ( select MAX( ou_id ) from ous )");

                    var ds = Framework.Database.ExecuteQuery(sql);

                    var ouTable = ds.Tables[0];

                    if (ouTable.Rows.Count == 0)
                    {
                        return(null);
                    }

                    var row = ouTable.Rows[0];

                    int parentou;

                    try
                    {
                        parentou = ( int )row["ou_parent_id"];
                    }
                    catch (Exception error)
                    {
                        Framework.EventBus.Publish(error);
                        parentou = -1;
                    }

                    var ou = new Ou(( int )row["ou_id"], ( string )row["ou_name"], parentou, ( string )row["ou_policygroup"]);

                    _ous.Add(ou);

                    return(_ous[_ous.Count - 1]);
                }

                return(null);
            }
            catch (Exception error)
            {
                Framework.EventBus.Publish(error);
                return(null);
            }
        }
Пример #4
0
 internal void HatcingComplete()
 {
     hatchIndicatorInProgress = null;
     Destroy(ouHeld.gameObject);
     ouHeld        = null;
     hatchlingHeld = Instantiate(hatchling, transform).GetComponent <Hatchling>();
     hatchlingHeld.transform.localPosition = carryPosition;
     couldHatch = false;
     audio.PlayOneShot(hatched);
 }
Пример #5
0
 private static bool Contains(Ou ou)
 {
     foreach (Ou cou in _ous)
     {
         if (cou.GetOuId() == ou.GetOuId())
         {
             return(true);
         }
     }
     return(false);
 }
Пример #6
0
 void Start()
 {
     r2d        = GetComponent <Rigidbody2D>();
     anim       = GetComponent <Animator>();
     wallsLayer = LayerMask.GetMask("Walls");
     ouLayer    = LayerMask.NameToLayer("Ou");
     nestLayer  = LayerMask.NameToLayer("Nest");
     houseLayer = LayerMask.NameToLayer("House");
     ouHeld     = null;
     couldHatch = false;
     hatchIndicatorInProgress = null;
     audio = GetComponent <AudioSource>();
 }
Пример #7
0
        private Task StartRunner(BlockingCollection <Wrapper <SearchResultEntry> > processQueue,
                                 BlockingCollection <Wrapper <JsonBase> > output)
        {
            return(Task.Factory.StartNew(() =>
            {
                foreach (var wrapper in processQueue.GetConsumingEnumerable())
                {
                    var entry = wrapper.Item;
                    var resolved = entry.ResolveAdEntry();

                    if (resolved == null)
                    {
                        Interlocked.Increment(ref _currentCount);
                        wrapper.Item = null;
                        continue;
                    }

                    var sid = entry.GetSid();
                    var domain = Utils.ConvertDnToDomain(entry.DistinguishedName).ToUpper();
                    var domainSid = _utils.GetDomainSid(domain);

                    if (resolved.ObjectType == "user")
                    {
                        var obj = new User
                        {
                            Name = resolved.BloodHoundDisplay
                        };

                        obj.Properties.Add("domain", domain);
                        obj.Properties.Add("objectsid", sid);
                        obj.Properties.Add("highvalue", false);

                        ObjectPropertyHelpers.GetProps(entry, resolved, ref obj);
                        GroupHelpers.GetGroupInfo(entry, resolved, domainSid, ref obj);
                        AclHelpers.GetObjectAces(entry, resolved, ref obj);

                        output.Add(new Wrapper <JsonBase>
                        {
                            Item = obj
                        });
                    }
                    else if (resolved.ObjectType == "group")
                    {
                        var obj = new Group
                        {
                            Name = resolved.BloodHoundDisplay
                        };

                        if (sid.EndsWith("-512") || sid.EndsWith("-516") || sid.EndsWith("-519") ||
                            sid.EndsWith("-520") || sid.Equals("S-1-5-32-544") || sid.Equals("S-1-5-32-550") ||
                            sid.Equals("S-1-5-32-549") || sid.Equals("S-1-5-32-551") || sid.Equals("S-1-5-32-548"))
                        {
                            obj.Properties.Add("highvalue", true);
                        }
                        else
                        {
                            obj.Properties.Add("highvalue", false);
                        }

                        obj.Properties.Add("domain", domain);
                        obj.Properties.Add("objectsid", sid);

                        ObjectPropertyHelpers.GetProps(entry, resolved, ref obj);
                        GroupHelpers.GetGroupInfo(entry, resolved, domainSid, ref obj);
                        AclHelpers.GetObjectAces(entry, resolved, ref obj);

                        output.Add(new Wrapper <JsonBase>
                        {
                            Item = obj
                        });
                    }
                    else if (resolved.ObjectType == "computer")
                    {
                        var obj = new Computer
                        {
                            Name = resolved.BloodHoundDisplay,
                            LocalAdmins = new LocalMember[] {},
                            RemoteDesktopUsers = new LocalMember[] {}
                        };

                        obj.Properties.Add("objectsid", sid);
                        obj.Properties.Add("highvalue", false);
                        obj.Properties.Add("domain", domain);


                        if (Utils.IsMethodSet(ResolvedCollectionMethod.Group))
                        {
                            if (entry.DistinguishedName.ToLower().Contains("domain controllers"))
                            {
                                _entDcs.Enqueue(new GroupMember
                                {
                                    MemberName = resolved.BloodHoundDisplay,
                                    MemberType = "computer"
                                });
                            }
                        }

                        ObjectPropertyHelpers.GetProps(entry, resolved, ref obj);
                        GroupHelpers.GetGroupInfo(entry, resolved, domainSid, ref obj);
                        AclHelpers.GetObjectAces(entry, resolved, ref obj);

                        if (!_utils.PingHost(resolved.BloodHoundDisplay))
                        {
                            Interlocked.Increment(ref _noPing);
                        }
                        else
                        {
                            var timeout = false;
                            try
                            {
                                obj.LocalAdmins = LocalGroupHelpers
                                                  .GetGroupMembers(resolved, LocalGroupHelpers.LocalGroupRids.Administrators)
                                                  .ToArray();
                            }
                            catch (TimeoutException)
                            {
                                timeout = true;
                            }

                            try
                            {
                                obj.RemoteDesktopUsers = LocalGroupHelpers.GetGroupMembers(resolved,
                                                                                           LocalGroupHelpers.LocalGroupRids.RemoteDesktopUsers).ToArray();
                            }
                            catch (TimeoutException)
                            {
                                timeout = true;
                            }

                            try
                            {
                                obj.DcomUsers = LocalGroupHelpers.GetGroupMembers(resolved,
                                                                                  LocalGroupHelpers.LocalGroupRids.DcomUsers).ToArray();
                            }
                            catch (TimeoutException)
                            {
                                timeout = true;
                            }

                            try
                            {
                                foreach (var s in SessionHelpers.GetNetSessions(resolved, domain))
                                {
                                    output.Add(new Wrapper <JsonBase>
                                    {
                                        Item = s
                                    });
                                }
                            }
                            catch (TimeoutException)
                            {
                                timeout = true;
                            }

                            try
                            {
                                foreach (var s in SessionHelpers.DoLoggedOnCollection(resolved, domain))
                                {
                                    output.Add(new Wrapper <JsonBase>
                                    {
                                        Item = s
                                    });
                                }
                            }
                            catch (TimeoutException)
                            {
                                timeout = true;
                            }

                            if (timeout)
                            {
                                Interlocked.Increment(ref _timeouts);
                            }
                        }

                        if (!_options.SessionLoopRunning)
                        {
                            output.Add(new Wrapper <JsonBase>
                            {
                                Item = obj
                            });
                        }
                    }
                    else if (resolved.ObjectType == "domain")
                    {
                        var obj = new Domain
                        {
                            Name = resolved.BloodHoundDisplay
                        };

                        obj.Properties.Add("objectsid", sid);
                        obj.Properties.Add("highvalue", true);

                        ObjectPropertyHelpers.GetProps(entry, resolved, ref obj);
                        AclHelpers.GetObjectAces(entry, resolved, ref obj);
                        ContainerHelpers.ResolveContainer(entry, resolved, ref obj);
                        TrustHelpers.DoTrustEnumeration(resolved, ref obj);

                        output.Add(new Wrapper <JsonBase>
                        {
                            Item = obj
                        });
                    }
                    else if (resolved.ObjectType == "gpo")
                    {
                        var obj = new Gpo
                        {
                            Name = resolved.BloodHoundDisplay,
                            Guid = entry.GetProp("name").Replace("{", "").Replace("}", "")
                        };

                        obj.Properties.Add("highvalue", false);

                        AclHelpers.GetObjectAces(entry, resolved, ref obj);
                        ObjectPropertyHelpers.GetProps(entry, resolved, ref obj);

                        foreach (var a in LocalGroupHelpers.GetGpoMembers(entry, domain))
                        {
                            output.Add(new Wrapper <JsonBase>
                            {
                                Item = a
                            });
                        }

                        output.Add(new Wrapper <JsonBase>
                        {
                            Item = obj
                        });
                    }
                    else if (resolved.ObjectType == "ou")
                    {
                        var obj = new Ou
                        {
                            Guid = new Guid(entry.GetPropBytes("objectguid")).ToString().ToUpper()
                        };

                        obj.Properties.Add("name", resolved.BloodHoundDisplay);
                        obj.Properties.Add("highvalue", false);

                        ContainerHelpers.ResolveContainer(entry, resolved, ref obj);
                        ObjectPropertyHelpers.GetProps(entry, resolved, ref obj);

                        output.Add(new Wrapper <JsonBase>
                        {
                            Item = obj
                        });
                    }

                    Interlocked.Increment(ref _currentCount);
                    wrapper.Item = null;
                }
            }, TaskCreationOptions.LongRunning));
        }
Пример #8
0
        internal void StartStealthEnumeration()
        {
            var output = new BlockingCollection <Wrapper <JsonBase> >();
            var writer = StartOutputWriter(output);

            foreach (var domainName in _utils.GetDomainList())
            {
                Extensions.SetPrimaryDomain(domainName);

                _currentCount = 0;
                _timeouts     = 0;
                _noPing       = 0;
                _watch        = Stopwatch.StartNew();

                Console.WriteLine($"Starting Stealth Enumeration for {domainName}");
                _statusTimer.Start();

                var domainSid = _utils.GetDomainSid(domainName);
                var res       = _options.ResolvedCollMethods;
                var data      = LdapFilter.BuildLdapData(res, _options.ExcludeDC, _options.LdapFilter);

                ContainerHelpers.BuildGpoCache(domainName);

                foreach (var entry in _utils.DoSearch(data.Filter, SearchScope.Subtree, data.Properties, domainName))
                {
                    var resolved = entry.ResolveAdEntry();
                    _currentCount++;
                    if (resolved == null)
                    {
                        continue;
                    }

                    Console.WriteLine(resolved.BloodHoundDisplay);
                    Console.WriteLine(resolved.ObjectType);
                    var domain = Utils.ConvertDnToDomain(entry.DistinguishedName);
                    var sid    = entry.GetSid();

                    if (resolved.ObjectType == "user")
                    {
                        var obj = new User
                        {
                            Name = resolved.BloodHoundDisplay
                        };

                        obj.Properties.Add("domain", domain);
                        obj.Properties.Add("objectsid", sid);
                        obj.Properties.Add("highvalue", false);

                        ObjectPropertyHelpers.GetProps(entry, resolved, ref obj);
                        GroupHelpers.GetGroupInfo(entry, resolved, domainSid, ref obj);
                        AclHelpers.GetObjectAces(entry, resolved, ref obj);

                        output.Add(new Wrapper <JsonBase>
                        {
                            Item = obj
                        });
                    }
                    else if (resolved.ObjectType == "group")
                    {
                        var obj = new Group
                        {
                            Name = resolved.BloodHoundDisplay
                        };

                        obj.Properties.Add("domain", domain);
                        obj.Properties.Add("objectsid", sid);

                        if (sid.EndsWith("-512") || sid.EndsWith("-516") || sid.EndsWith("-519") ||
                            sid.EndsWith("-520") || sid.Equals("S-1-5-32-544") || sid.Equals("S-1-5-32-550") ||
                            sid.Equals("S-1-5-32-549") || sid.Equals("S-1-5-32-551") || sid.Equals("S-1-5-32-548"))
                        {
                            obj.Properties.Add("highvalue", true);
                        }
                        else
                        {
                            obj.Properties.Add("highvalue", false);
                        }

                        ObjectPropertyHelpers.GetProps(entry, resolved, ref obj);
                        GroupHelpers.GetGroupInfo(entry, resolved, domainSid, ref obj);
                        AclHelpers.GetObjectAces(entry, resolved, ref obj);

                        output.Add(new Wrapper <JsonBase>
                        {
                            Item = obj
                        });
                    }
                    else if (resolved.ObjectType == "computer")
                    {
                        var obj = new Computer
                        {
                            Name = resolved.BloodHoundDisplay,
                        };

                        obj.Properties.Add("domain", domain);
                        obj.Properties.Add("objectsid", sid);
                        obj.Properties.Add("highvalue", false);

                        if (entry.DistinguishedName.ToLower().Contains("domain controllers"))
                        {
                            _entDcs.Enqueue(new GroupMember
                            {
                                MemberType = "computer",
                                MemberName = resolved.BloodHoundDisplay
                            });
                        }

                        ObjectPropertyHelpers.GetProps(entry, resolved, ref obj);
                        GroupHelpers.GetGroupInfo(entry, resolved, domainSid, ref obj);
                        AclHelpers.GetObjectAces(entry, resolved, ref obj);

                        output.Add(new Wrapper <JsonBase>
                        {
                            Item = obj
                        });
                    }
                    else if (resolved.ObjectType == "domain")
                    {
                        var obj = new Domain
                        {
                            Name = resolved.BloodHoundDisplay,
                        };

                        obj.Properties.Add("objectsid", sid);
                        obj.Properties.Add("highvalue", true);

                        ObjectPropertyHelpers.GetProps(entry, resolved, ref obj);
                        AclHelpers.GetObjectAces(entry, resolved, ref obj);
                        ContainerHelpers.ResolveContainer(entry, resolved, ref obj);
                        TrustHelpers.DoTrustEnumeration(resolved, ref obj);

                        output.Add(new Wrapper <JsonBase>
                        {
                            Item = obj
                        });
                    }
                    else if (resolved.ObjectType == "gpo")
                    {
                        var obj = new Gpo
                        {
                            Name = resolved.BloodHoundDisplay,
                            Guid = entry.GetProp("name").Replace("{", "").Replace("}", "")
                        };

                        obj.Properties.Add("highvalue", false);

                        AclHelpers.GetObjectAces(entry, resolved, ref obj);

                        foreach (var a in LocalGroupHelpers.GetGpoMembers(entry, domain))
                        {
                            output.Add(new Wrapper <JsonBase>
                            {
                                Item = a
                            });
                        }

                        output.Add(new Wrapper <JsonBase>
                        {
                            Item = obj
                        });
                    }
                    else if (resolved.ObjectType == "ou")
                    {
                        var obj = new Ou
                        {
                            Guid = new Guid(entry.GetPropBytes("objectguid")).ToString().ToUpper()
                        };

                        obj.Properties.Add("name", resolved.BloodHoundDisplay);
                        obj.Properties.Add("highvalue", false);

                        ContainerHelpers.ResolveContainer(entry, resolved, ref obj);

                        output.Add(new Wrapper <JsonBase>
                        {
                            Item = obj
                        });
                    }
                }

                if (Utils.IsMethodSet(ResolvedCollectionMethod.Session))
                {
                    Console.WriteLine("Doing stealth session enumeration");
                    foreach (var target in SessionHelpers.CollectStealthTargets(domainName))
                    {
                        if (!_utils.PingHost(target.BloodHoundDisplay))
                        {
                            _noPing++;
                            continue;
                        }

                        try
                        {
                            foreach (var session in SessionHelpers.GetNetSessions(target, domainName))
                            {
                                output.Add(new Wrapper <JsonBase>
                                {
                                    Item = session
                                });
                            }
                        }
                        catch (TimeoutException)
                        {
                            _timeouts++;
                        }
                    }
                }

                if (_entDcs.Count > 0)
                {
                    var dObj = _utils.GetForest(domainName);
                    var d    = dObj == null ? domainName : dObj.RootDomain.Name;
                    var n    = $"ENTERPRISE DOMAIN CONTROLLERS@{d}";
                    var obj  = new Group
                    {
                        Name    = n,
                        Members = _entDcs.ToArray()
                    };

                    obj.Properties.Add("domain", d);
                    obj.Properties.Add("objectsid", "S-1-5-9");
                    obj.Properties.Add("highvalue", true);

                    output.Add(new Wrapper <JsonBase>
                    {
                        Item = obj
                    });
                }


                PrintStatus();
                _statusTimer.Stop();

                Console.WriteLine($"Finished stealth enumeration for {domainName} in {_watch.Elapsed}");
                Console.WriteLine($"{_noPing} hosts failed ping. {_timeouts} hosts timedout.");
            }
            output.CompleteAdding();
            Utils.Verbose("Waiting for writer thread to finish");
            writer.Wait();
        }
Пример #9
0
        public static void GetObjectAces(SearchResultEntry entry, ResolvedEntry resolved, ref Ou g)
        {
            if (!Utils.IsMethodSet(ResolvedCollectionMethod.ACL))
            {
                return;
            }

            var aces = new List <ACL>();
            var ntSecurityDescriptor = entry.GetPropBytes("ntsecuritydescriptor");

            //If the ntsecuritydescriptor is null, no point in continuing
            //I'm still not entirely sure what causes this, but it can happen
            if (ntSecurityDescriptor == null)
            {
                return;
            }

            var domainName = Utils.ConvertDnToDomain(entry.DistinguishedName);

            //Convert the ntsecuritydescriptor bytes to a .net object
            var descriptor = new RawSecurityDescriptor(ntSecurityDescriptor, 0);

            //Grab the DACL
            var rawAcl = descriptor.DiscretionaryAcl;
            //Grab the Owner
            var ownerSid = descriptor.Owner.ToString();

            //Determine the owner of the object. Start by checking if we've already determined this is null
            if (!_nullSids.TryGetValue(ownerSid, out _))
            {
                //Check if its a common SID
                if (!MappedPrincipal.GetCommon(ownerSid, out var owner))
                {
                    //Resolve the sid manually if we still dont have it
                    var ownerDomain = _utils.SidToDomainName(ownerSid) ?? domainName;
                    owner = _utils.UnknownSidTypeToDisplay(ownerSid, ownerDomain, Props);
                }
                else
                {
                    owner.PrincipalName = $"{owner.PrincipalName}@{domainName}";
                }

                //Filter out the Local System principal which pretty much every entry has
                if (owner != null && !owner.PrincipalName.Contains("LOCAL SYSTEM") && !owner.PrincipalName.Contains("CREATOR OWNER"))
                {
                    aces.Add(new ACL
                    {
                        AceType       = "",
                        RightName     = "Owner",
                        PrincipalName = owner.PrincipalName,
                        PrincipalType = owner.ObjectType
                    });
                }
                else
                {
                    //We'll cache SIDs we've failed to resolve previously so we dont keep trying
                    _nullSids.TryAdd(ownerSid, new byte());
                }
            }

            foreach (var genericAce in rawAcl)
            {
                var qAce = genericAce as QualifiedAce;
                if (qAce == null)
                {
                    continue;
                }

                var objectSid = qAce.SecurityIdentifier.ToString();
                if (_nullSids.TryGetValue(objectSid, out _))
                {
                    continue;
                }

                //Check if its a common sid
                if (!MappedPrincipal.GetCommon(objectSid, out var mappedPrincipal))
                {
                    //If not common, lets resolve it normally
                    var objectDomain =
                        _utils.SidToDomainName(objectSid) ??
                        domainName;
                    mappedPrincipal = _utils.UnknownSidTypeToDisplay(objectSid, objectDomain, Props);
                    if (mappedPrincipal == null)
                    {
                        _nullSids.TryAdd(objectSid, new byte());
                        continue;
                    }
                }
                else
                {
                    if (mappedPrincipal.PrincipalName == "ENTERPRISE DOMAIN CONTROLLERS")
                    {
                        var dObj = _utils.GetForest(domainName);
                        var d    = dObj == null ? domainName : dObj.RootDomain.Name;
                        mappedPrincipal.PrincipalName = $"{mappedPrincipal.PrincipalName}@{d}".ToUpper();
                    }
                    else
                    {
                        mappedPrincipal.PrincipalName = $"{mappedPrincipal.PrincipalName}@{domainName}".ToUpper();
                    }
                }

                if (mappedPrincipal.PrincipalName.Contains("LOCAL SYSTEM") || mappedPrincipal.PrincipalName.Contains("CREATOR OWNER"))
                {
                    continue;
                }

                //Convert our right to an ActiveDirectoryRight enum object, and then to a string
                var adRight       = (ActiveDirectoryRights)Enum.ToObject(typeof(ActiveDirectoryRights), qAce.AccessMask);
                var adRightString = adRight.ToString();

                //Get the ACE for our right
                var ace  = qAce as ObjectAce;
                var guid = ace != null?ace.ObjectAceType.ToString() : "";

                var inheritedObjectType = ace != null?ace.InheritedObjectAceType.ToString() : "00000000-0000-0000-0000-000000000000";

                var flags       = ace == null ? AceFlags.None : ace.AceFlags;
                var isInherited = (flags & AceFlags.InheritOnly) != 0;

                isInherited = isInherited && (inheritedObjectType == "00000000-0000-0000-0000-000000000000" ||
                                              inheritedObjectType == "bf967aa5-0de6-11d0-a285-00aa003049e2");

                //Special case used for example by Exchange: the ACE is inherited but also applies to the object it is set on
                // this is verified by looking if this ACE is not inherited, and is not an inherit-only ACE
                if (!isInherited && (flags & AceFlags.InheritOnly) != AceFlags.InheritOnly && (flags & AceFlags.Inherited) != AceFlags.Inherited)
                {
                    //If these conditions hold the ACE applies to this object anyway
                    isInherited = true;
                }

                if (!isInherited)
                {
                    continue;
                }

                var toContinue = false;

                _guidMap.TryGetValue(guid, out var mappedGuid);

                //Interesting OU ACEs - GenericAll, GenericWrite, WriteDacl, WriteOwner,
                toContinue |= adRightString.Contains("WriteDacl") ||
                              adRightString.Contains("WriteOwner");

                if (adRightString.Contains("GenericAll"))
                {
                    toContinue |= "00000000-0000-0000-0000-000000000000".Equals(guid) || guid.Equals("") || toContinue;
                }
                if (adRightString.Contains("WriteProperty"))
                {
                    toContinue |= guid.Equals("00000000-0000-0000-0000-000000000000") ||
                                  guid.Equals("f30e3bbe-9ff0-11d1-b603-0000f80367c1") || guid.Equals("") ||
                                  toContinue;
                }

                if (!toContinue)
                {
                    continue;
                }

                if (adRightString.Contains("GenericAll"))
                {
                    if (mappedGuid == "ms-Mcs-AdmPwd")
                    {
                        aces.Add(new ACL
                        {
                            AceType       = "",
                            PrincipalName = mappedPrincipal.PrincipalName,
                            PrincipalType = mappedPrincipal.ObjectType,
                            RightName     = "ReadLAPSPassword"
                        });
                    }
                    else
                    {
                        aces.Add(new ACL
                        {
                            AceType       = "",
                            PrincipalName = mappedPrincipal.PrincipalName,
                            PrincipalType = mappedPrincipal.ObjectType,
                            RightName     = "GenericAll"
                        });
                    }
                }

                if (adRightString.Contains("WriteOwner"))
                {
                    aces.Add(new ACL
                    {
                        AceType       = "",
                        PrincipalName = mappedPrincipal.PrincipalName,
                        PrincipalType = mappedPrincipal.ObjectType,
                        RightName     = "WriteOwner"
                    });
                }

                if (adRightString.Contains("WriteDacl"))
                {
                    aces.Add(new ACL
                    {
                        AceType       = "",
                        PrincipalName = mappedPrincipal.PrincipalName,
                        PrincipalType = mappedPrincipal.ObjectType,
                        RightName     = "WriteDacl"
                    });
                }

                if (adRightString.Contains("ExtendedRight"))
                {
                    if (mappedGuid == "ms-Mcs-AdmPwd")
                    {
                        aces.Add(new ACL
                        {
                            AceType       = "",
                            PrincipalName = mappedPrincipal.PrincipalName,
                            PrincipalType = mappedPrincipal.ObjectType,
                            RightName     = "ReadLAPSPassword"
                        });
                    }
                    else
                    {
                        aces.Add(new ACL
                        {
                            AceType       = "All",
                            PrincipalName = mappedPrincipal.PrincipalName,
                            PrincipalType = mappedPrincipal.ObjectType,
                            RightName     = "ExtendedRight"
                        });
                    }
                }
            }

            g.Aces = aces.Distinct().ToArray();
        }
Пример #10
0
        private static void BuildOuListing()
        {
            var refresh = true;

            if (_ous == null)
            {
                _ous    = new List <IOu>();
                refresh = false;
            }

            try
            {
                var sql = string.Format("select * from ous");

                if (Framework.Database.IsConnected() == false)
                {
                    return;
                }

                var ds = Framework.Database.ExecuteQuery(sql);

                var ouTable = ds.Tables[0];

                if (ouTable.Rows.Count == 0)
                {
                    return;
                }

                foreach (DataRow row in ouTable.Rows)
                {
                    int parentou;

                    try
                    {
                        parentou = ( int )row["ou_parent_id"];
                    }
                    catch (Exception error)
                    {
                        Framework.EventBus.Publish(error);
                        parentou = -1;
                    }

                    var ou = new Ou(( int )row["ou_id"], ( string )row["ou_name"], parentou, ( string )row["ou_policygroup"]);

                    if (refresh)
                    {
                        if (Contains(ou) == false)
                        {
                            _ous.Add(ou);
                        }
                    }
                    else
                    {
                        _ous.Add(ou);
                    }
                }
            }
            catch (Exception error)
            {
                Framework.EventBus.Publish(error);
            }
        }
Пример #11
0
        internal static void ResolveContainer(SearchResultEntry entry, ResolvedEntry resolved, ref Ou obj)
        {
            if (!Utils.IsMethodSet(ResolvedCollectionMethod.Container))
            {
                return;
            }

            var domain = Utils.ConvertDnToDomain(entry.DistinguishedName);

            var opts = entry.GetProp("gpoptions");

            obj.Properties.Add("blocksinheritance", opts != null && opts.Equals("1"));

            //Resolve GPLinks on the ou
            var links = new List <GpLink>();

            var gpLinks = entry.GetProp("gplink");

            if (gpLinks != null)
            {
                foreach (var l in gpLinks.Split(']', '[').Where(x => x.StartsWith("LDAP")))
                {
                    var split  = l.Split(';');
                    var dn     = split[0];
                    var status = split[1];
                    if (status.Equals("3") || status.Equals("1"))
                    {
                        continue;
                    }

                    var enforced = status.Equals("2");
                    var index    = dn.IndexOf("CN=", StringComparison.OrdinalIgnoreCase) + 4;
                    var name     = dn.Substring(index, index + 25);

                    if (!_gpoCache.ContainsKey(name))
                    {
                        continue;
                    }

                    var dName = _gpoCache[name];
                    links.Add(new GpLink
                    {
                        IsEnforced = enforced,
                        Name       = $"{dName}@{domain}"
                    });
                }

                obj.Links = links.ToArray();
            }

            var computers = new List <string>();
            var users     = new List <string>();
            var ous       = new List <string>();

            foreach (var subEntry in _utils.DoSearch(
                         "(|(samAccountType=805306368)(samAccountType=805306369)(objectclass=organizationalUnit))",
                         SearchScope.OneLevel,
                         new[]
            {
                "samaccountname", "name", "objectguid", "objectclass", "objectsid", "samaccounttype", "dnshostname"
            }, domain, entry.DistinguishedName))
            {
                var subResolved = subEntry.ResolveAdEntry();

                if (subResolved == null)
                {
                    continue;
                }

                if (subResolved.ObjectType.Equals("ou"))
                {
                    ous.Add(new Guid(subEntry.GetPropBytes("objectguid")).ToString().ToUpper());
                }
                else if (subResolved.ObjectType.Equals("computer"))
                {
                    computers.Add(subResolved.BloodHoundDisplay);
                }
                else
                {
                    users.Add(subResolved.BloodHoundDisplay);
                }
            }

            obj.Users = users.ToArray();

            obj.Computers = computers.ToArray();

            obj.ChildOus = ous.ToArray();
        }
Пример #12
0
        internal static void GetProps(SearchResultEntry entry, ResolvedEntry resolved, ref Ou obj)
        {
            if (!Utils.IsMethodSet(ResolvedCollectionMethod.ObjectProps))
            {
                return;
            }

            obj.Properties.Add("description", entry.GetProp("description"));
        }
Пример #13
0
 public frmPhongBan(Account oAccount) : base(oAccount)
 {
     InitializeComponent();
     mOu = new Ou();
 }
Пример #14
0
    void Update()
    {
        Vector2 velo = r2d.velocity;

        velo.x = Input.GetAxis(whichPlayer + "Horizontal") * moveSpeed;

        if (stunIndicatorInProgress == null)
        {
            if (hatchIndicatorInProgress == null)
            {
                if (Input.GetButtonDown(whichPlayer + "Hatch") && couldHatch)
                {
                    ouHeld.transform.localPosition  = hatchPosition;
                    hatchIndicatorInProgress        = Instantiate(hatchIndicator, transform, false).GetComponent <HatchIndicator>();
                    hatchIndicatorInProgress.player = this;
                    audio.PlayOneShot(hatching);
                }
                else if (Input.GetButtonDown(whichPlayer + "Fire") && ouHeld != null)
                {
                    ouHeld.Throw((facing_left ? -1 : 1) * vrum);
                    ouHeld = null;
                    audio.PlayOneShot(shoot);
                }
            }
            else
            {
                if (Input.GetButtonUp(whichPlayer + "Hatch"))
                {
                    Destroy(hatchIndicatorInProgress.gameObject);
                    hatchIndicatorInProgress       = null;
                    ouHeld.transform.localPosition = carryPosition;
                }
            }
        }

        if (Mathf.Abs(velo.y) >= 1)   // if jumping
        {
            anim.SetBool("isJumpingRight", !facing_left);
            anim.SetBool("isJumpingLeft", facing_left);
            anim.SetBool("isWalkingLeft", false);
            anim.SetBool("isWalkingRight", false);
        }
        else
        {
            anim.SetBool("isJumpingRight", false);
            anim.SetBool("isJumpingLeft", false);

            if (velo.x != 0)
            {
                facing_left = velo.x < 0;
                anim.SetBool("isWalkingLeft", facing_left);
                anim.SetBool("isWalkingRight", !facing_left);
            }
            else
            {
                anim.SetBool("isWalkingRight", false);
                anim.SetBool("isWalkingLeft", false);
            }
        }


        // Handle pause
        if (Input.GetButtonDown("Cancel"))
        {
            //if (controlsEnabled) {
            //    freeze();
            //    Universe.TogglePause(() => defrost());
            //}
            //else {
            //    Universe.TogglePause();
            //}
        }
    }