Skip to main content

pyldapsearch

This is designed to be a python "port" of the ldapsearch BOF by TrustedSec, which is a part of this repo.

pyldapsearch allows you to execute LDAP queries from Linux in a fashion similar to that of the aforementioned BOF. Its output format closely mimics that of the BOF and all query output will automatically be logged to the user's home directory in .pyldapsearch/logs, which can ingested by bofhound.

Why would I ever use this?

Great question. pyldapsearch was built for a scenario where the operator is utilizing Linux and is attempting to issue LDAP queries while flying under the radar (BloodHound will be too loud, expensive LDAP queries are alerted on, etc). When pyldapsearch is combined with bofhound, you can still obtain BloodHound compatible data that allows for AD visualization and identification of ACL-based attack paths, which are otherwise difficult to identify through manually querying LDAP.

Outside of usage during detection-conscious and bofhound-related situations, pyldapsearch can be useful for issuing targeted, one-off LDAP queries during generic engagements.

Installation

Use uv

curl -LsSf https://astral.sh/uv/install.sh | sh

# Install pyldapsearch 
git clone https://github.com/Tw1sm/pyldapserach
cd pyldapserach
uv sync
uv run pyldapserach --help

Examples

Query all the data - if you intend to do this, just run BloodHound :)

pyldapsearch ez.lab/administrator:pass '(objectClass=*)'

Query only the name, memberOf and ObjectSID of the user matt

pyldapsearch ez.lab/administrator:pass '(sAMAccountName=matt)' -attributes name,memberof,objectsid

Query all attributes for all user objects, but only return 3 results

pyldapsearch ez.lab/administrator:pass '(objectClass=user)' -limit 3

Query all attributes of the user matt, specifying the IP of the DC to query

pyldapsearch ez.lab/administrator:pass '(&(objectClass=user)(name=matt))' -dc-ip 10.4.2.20

Query all objects, specifying the search base to use

pyldapsearch ez.lab/administrator:pass '(objectClass=*)' -base-dn 'CN=Users,DC=EZ,DC=LAB'

Execute a query without displaying query results to the console (results will still be logged)

pyldapsearch ez.lab/administrator:pass '(objectClass=*)' -silent

Perform a query using an anonymous bind

pyldapsearch 'ez.lab'/'':'' '(objectClass=*)'

Perform a query across a domain trust

pyldapsearch ez.lab/administrator:pass '(objectClass=*)' -base-dn 'DC=otherdomain,DC=local' -dc-ip 10.1.4.20

References

Metadata

Release files for pyldapsearch 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyldapsearch 0.2.0
File Size Uploaded Provenance Actions
pyldapsearch-0.2.0.tar.gz 280.6 kB Without provenance Details for pyldapsearch-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pyldapsearch 0.2.0
File Interpreter ABI Platform Actions
pyldapsearch-0.2.0-py3-none-any.whl Python 3 none any Details for pyldapsearch-0.2.0-py3-none-any.whl

Total release size: 289.5 kB

Release files / pyldapsearch-0.2.0.tar.gz

Download URL pyldapsearch-0.2.0.tar.gz
Size 280.6 kB
Tags Source
SHA-256 checksum
How to use checksums
43bb535820040caee9ff5a014901436e54f5f74fab454cadb73a64835349d76e
BLAKE2b-256 checksum
How to use checksums
5afa97c853ab80bc915dcb896fbef48e6869e68199e752838339ca24f1dd83a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / pyldapsearch-0.2.0-py3-none-any.whl

Download URL pyldapsearch-0.2.0-py3-none-any.whl
Size 8.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bba6a04d5a34e30a47f87801bc6c1367e5e5e496e2bbefc84a9b5bb68ea993b2
BLAKE2b-256 checksum
How to use checksums
3127a84e318d9abb7da8632b0deab16bff7e7aa81f43dab753e065bcfab26243
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for pyldapsearch 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page