Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect IP selection from resolved hostname when multiple IPs are returned by NS #217

Open
scmanjarrez opened this issue Feb 21, 2025 · 0 comments

Comments

@scmanjarrez
Copy link

scmanjarrez commented Feb 21, 2025

Hi,
First of all, thank you very much for your tool. I recently encountered an error with bloodhound-python, which happened during an HTB machine. However, I believe this issue might be more common:

When a hostname resolves to multiple IPs, bloodhound-python only chooses the last one instead of testing connectivity with all the resolved IPs. This behavior can be seen here: https://github.com/dirkjanm/BloodHound.py/blob/bloodhound-ce/bloodhound/ad/domain.py#L67

I currently have a workaround, but I think a cleaner solution could be implemented.

# Imports
import ldap3
# <SNIP>
        for r in q:
            try:
                logging.info('Testing resolved hostname connectivity %s' % r.address)
                _tmp_serv = ldap3.Server(r.address, connect_timeout=5)
                _conn = ldap3.Connection(_tmp_serv)
                _bind = _conn.bind()
            except ldap3.core.exceptions.LDAPSocketOpenError:
                continue
            else:
                if _conn:
                    ip = r.address
                    break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant