dirkjanm / ldapdomaindump

Active Directory information dumper via LDAP
MIT License
1.19k stars 190 forks source link

unsupported operand type for bytes and datetime.datetime error #24

Closed mubix closed 4 years ago

mubix commented 4 years ago

image

Traceback (most recent call last):
  File "/usr/local/bin/ldapdomaindump", line 3, in <module>
    ldapdomaindump.main()
  File "/usr/local/lib/python3.7/dist-packages/ldapdomaindump/__init__.py", line 944, in main
    dd.domainDump()
  File "/usr/local/lib/python3.7/dist-packages/ldapdomaindump/__init__.py", line 419, in domainDump
    self.policy = self.getDomainPolicy()
  File "/usr/local/lib/python3.7/dist-packages/ldapdomaindump/__init__.py", line 258, in getDomainPolicy
    self.connection.search(self.root, '(objectClass=domain)', attributes=ldap3.ALL_ATTRIBUTES)
  File "/usr/local/lib/python3.7/dist-packages/ldap3/core/connection.py", line 788, in search
    response = self.post_send_search(self.send('searchRequest', request, controls))
  File "/usr/local/lib/python3.7/dist-packages/ldap3/strategy/sync.py", line 139, in post_send_search
    responses, result = self.get_response(message_id)
  File "/usr/local/lib/python3.7/dist-packages/ldap3/strategy/base.py", line 325, in get_response
    responses = self._get_response(message_id)
  File "/usr/local/lib/python3.7/dist-packages/ldap3/strategy/sync.py", line 165, in _get_response
    dict_response = self.decode_response_fast(ldap_resp)
  File "/usr/local/lib/python3.7/dist-packages/ldap3/strategy/base.py", line 509, in decode_response_fast
    result = search_result_entry_response_to_dict_fast(ldap_message['payload'], self.connection.server.schema, self.connection.server.custom_formatter, self.connection.check_names)
  File "/usr/local/lib/python3.7/dist-packages/ldap3/operation/search.py", line 568, in search_result_entry_response_to_dict_fast
    entry_dict['attributes'] = checked_attributes_to_dict_fast(response[1][3], schema, custom_formatter)  # attributes
  File "/usr/local/lib/python3.7/dist-packages/ldap3/operation/search.py", line 453, in checked_attributes_to_dict_fast
    checked_attributes[name] = format_attribute_values(schema, name, decode_raw_vals_fast(attribute[3][1][3]) or [], custom_formatter)
  File "/usr/local/lib/python3.7/dist-packages/ldap3/protocol/formatters/standard.py", line 213, in format_attribute_values
    formatted_values = [formatter(raw_value) for raw_value in values]  # executes formatter
  File "/usr/local/lib/python3.7/dist-packages/ldap3/protocol/formatters/standard.py", line 213, in <listcomp>
    formatted_values = [formatter(raw_value) for raw_value in values]  # executes formatter
  File "/usr/local/lib/python3.7/dist-packages/ldap3/protocol/formatters/formatters.py", line 337, in format_ad_timedelta
    return format_ad_timestamp(raw_value * -1) - format_ad_timestamp(0)
TypeError: unsupported operand type(s) for -: 'bytes' and 'datetime.datetime'
dirkjanm commented 4 years ago

Which version of ldap3 is this? Sounds like a non-compatible version

Pascal-0x90 commented 4 years ago

I am having a similar issue using ldapdomaindump with similar output as what @mubix got. OS: Kali Linux 5.3.0-kali3-amd64 #1 SMP Debian 5.3.15-1kali1 (2019-12-09) x86_64 GNU/Linux

Command ran: python3 ldapdomaindump.py 10.10.10.172 Output:

[*] Connecting as anonymous user, dumping will probably fail. Consider specifying a username/password to login with
[*] Connecting to host...
[*] Binding to host
[+] Bind OK
[*] Starting domain dump
Traceback (most recent call last):
  File "ldapdomaindump.py", line 3, in <module>
    ldapdomaindump.main()
  File "/root/Documents/htb/monteverde/recon/ldapdomaindump/ldapdomaindump/__init__.py", line 944, in main
    dd.domainDump()
  File "/root/Documents/htb/monteverde/recon/ldapdomaindump/ldapdomaindump/__init__.py", line 422, in domainDump
    rw.generateUsersReport(self)
  File "/root/Documents/htb/monteverde/recon/ldapdomaindump/ldapdomaindump/__init__.py", line 789, in generateUsersReport
    dd.mapGroupsIdsToDns()
  File "/root/Documents/htb/monteverde/recon/ldapdomaindump/ldapdomaindump/__init__.py", line 350, in mapGroupsIdsToDns
    gid = int(group.objectSid.value.split('-')[-1])
TypeError: a bytes-like object is required, not 'str'

This is the output of pip3 show ldap3:

Name: ldap3
Version: 2.5.1
Summary: A strictly RFC 4510 conforming LDAP V3 pure Python client library
Home-page: https://github.com/cannatag/ldap3
Author: Giovanni Cannata
Author-email: cannatag@gmail.com
License: LGPL v3
Location: /usr/lib/python3/dist-packages
Requires: 
Required-by: 
dirkjanm commented 4 years ago

@Pascal-0x90 you're likely running into the issue described in #26

Pascal-0x90 commented 4 years ago

Ah so it seems. Sorry for that. I should have looked further into it. Thank you!

dirkjanm commented 4 years ago

Closing due to lack of feedback