Skip to content

AttributeError: 'int' object has no attribute 'timetuple' patch proposal #137

Closed
@felmoltor

Description

@felmoltor

Hello,

I run into the following error today when running with the flag -c DCOnly on line 526 of the function enumerate_ous of file bloodhound/enumeration/memberships.py (sorry, I have lost the full stack trace):

AttributeError: 'int' object has no attribute 'timetuple'

I noticed that these lines correspond to an attempt to access the function 'timetuple' of the variable 'whencreated'. As seen in the previous line (525), the default value is considered to be '0' if that property is not found in the object entry property. Hence, my hypothesis is that I found an GPO entry without the property "whencreated" and the function retunred 0, which do not have the property or function 'timetuple()':

In the file bloodhound/enumeration/memberships.py we have following lines:

523             if with_properties:
524                 ou["Properties"]["description"] = ADUtils.get_entry_property(entry, 'description')
525                 whencreated = ADUtils.get_entry_property(entry, 'whencreated', **default=0**)
526                 ou["Properties"]["whencreated"] =  calendar.timegm(**whencreated.timetuple()**)

In utils.py, line 353 the behabiour is to return the default value if the property searched is empty:

https://github.com/fox-it/BloodHound.py/blob/master/bloodhound/ad/utils.py#L353

I know this is a feeble patch, but I patched it by modifying the line 526 to test the type of the 'whencreated' variable. If it is an integer, create a time.gmtime object out of it:

29    import time
[...]
524             if with_properties:
525                 ou["Properties"]["description"] = ADUtils.get_entry_property(entry, 'description')
526                 whencreated = ADUtils.get_entry_property(entry, 'whencreated', default=0)
527                 ou["Properties"]["whencreated"] =  calendar.timegm(**time.gmtime(whencreated) if type(whencreated)==int else** whencreated.timetuple())

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions