Skip to content

Commit

Permalink
help with sid parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
Tw1sm committed Nov 26, 2024
1 parent ddc2b45 commit 78c7960
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion bofhound/ad/models/bloodhound_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def __init__(self, object):
dc = BloodHoundObject.get_domain_component(object.get('distinguishedname').upper())
logging.debug(f"Reading Domain object {ColorScheme.domain}{self.Properties['name']}[/]", extra=OBJ_EXTRA_FMT)

if 'objectsid' in object.keys():
if self.ObjectIdentifier:
self.Properties["domainsid"] = object.get('objectsid')

if 'distinguishedname' in object.keys():
Expand Down
6 changes: 3 additions & 3 deletions bofhound/ad/models/bloodhound_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ def __init__(self, object):

if 'objectsid' in object.keys():
#objectid = BloodHoundObject.get_sid(object.get('objectsid', None), object.get('distinguishedname', None))
objectid = object.get('objectsid')
self.ObjectIdentifier = objectid
self.Properties["domainsid"] = objectid.rsplit('-',1)[0]
#objectid = object.get('objectsid')
#self.ObjectIdentifier = objectid
self.Properties["domainsid"] = self.ObjectIdentifier.rsplit('-',1)[0]


if 'distinguishedname' in object.keys():
Expand Down
10 changes: 9 additions & 1 deletion bofhound/ad/models/bloodhound_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import base64
from asn1crypto import x509
from datetime import datetime
from ldap3.protocol.formatters.formatters import format_sid
from bloodhound.enumeration.acls import SecurityDescriptor, ACL, ACCESS_ALLOWED_ACE, ACCESS_MASK, ACE, ACCESS_ALLOWED_OBJECT_ACE, has_extended_right, EXTRIGHTS_GUID_MAPPING, can_write_property, ace_applies
from bloodhound.ad.utils import ADUtils
from bofhound.logger import OBJ_EXTRA_FMT, ColorScheme
Expand Down Expand Up @@ -35,7 +36,14 @@ def __init__(self, object=None):
for item in object.keys():
self.Properties[item.lower()] = object[item]

self.ObjectIdentifier = BloodHoundObject.get_sid(object.get('objectsid', None), object.get('distinguishedname', None))
try:
# shadowhound doesn't parse SIDs out, they're still base64'd so check to see if we have b64 data
sid = format_sid(base64.b64decode(object.get('objectsid', None)))
self.ObjectIdentifier = BloodHoundObject.get_sid(sid, object.get('distinguishedname', None))
print(self.ObjectIdentifier)
except:
# not base64 data, so normal workflow
self.ObjectIdentifier = BloodHoundObject.get_sid(object.get('objectsid', None), object.get('distinguishedname', None))

if 'distinguishedname' in object.keys():
self.Properties["distinguishedname"] = object.get('distinguishedname', None).upper()
Expand Down

0 comments on commit 78c7960

Please sign in to comment.