the-useless-one / pywerview

A (partial) Python rewriting of PowerSploit's PowerView
GNU General Public License v3.0
909 stars 113 forks source link

datetime function exception fix #28

Closed aj-cgtech closed 2 years ago

aj-cgtech commented 6 years ago

In some environments I have encountered zero value in Date fields. The datetime conversion function was throwing an exception in these cases:

python pywerview.py get-netgroupmember -t 1.2.3.4 -u user -p pass --groupname 'Group Name'

Traceback (most recent call last): File "pywerview.py", line 24, in main() File "pywerview/pywerview/cli/main.py", line 456, in main results = args.func(parsed_args) File "pywerview/pywerview/cli/helpers.py", line 134, in get_netgroupmember full_data=full_data, custom_filter=custom_filter) File "pywerview/pywerview/requester.py", line 140, in wrapper return f(*args, *kwargs) File "pywerview/pywerview/functions/net.py", line 405, in get_netgroupmember members = _get_members(groupname, sid) File "pywerview/pywerview/functions/net.py", line 363, in _get_members members += self.get_netuser(custom_filter=dn_filter, queried_domain=queried_domain) File "pywerview/pywerview/requester.py", line 140, in wrapper return f(args, kwargs) File "pywerview/pywerview/functions/net.py", line 71, in get_netuser return self._ldap_search(user_search_filter, adobj.User) File "pywerview/pywerview/requester.py", line 121, in _ldap_search results.append(class_result(result['attributes'])) File "pywerview/pywerview/objects/adobjects.py", line 112, in init ADObject.init(self, attributes) File "pywerview/pywerview/objects/adobjects.py", line 27, in init self.add_attributes(attributes) File "pywerview/pywerview/objects/adobjects.py", line 57, in add_attributes value = datetime.fromtimestamp(timestamp) ValueError: timestamp out of range for platform time_t

the-useless-one commented 2 years ago

Hi @aj-cgtech, thanks for the PR and sorry for taking so long to review it.

We now use LDAP formatters to automatically parse date attributes, it's not done in the adobjects.py file anymore. Closing.

Cheers,

Y