ldapdomaindump

0.10.0 · active · verified Sun Apr 12

ldapdomaindump is a Python tool designed for Active Directory information dumping via LDAP. It collects and parses information from an Active Directory domain, outputting it in human-readable HTML, as well as machine-readable JSON and greppable formats. The current version is 0.10.0. Release cadence appears sporadic but the project is actively maintained.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to run `ldapdomaindump` from Python as a command-line tool to dump Active Directory information. It uses environment variables for sensitive credentials and specifies an output directory. The primary output files will be in HTML, JSON, and greppable formats.

import os
import subprocess

LDAP_HOSTNAME = os.environ.get('LDAP_HOSTNAME', 'your_domain_controller.local')
LDAP_USERNAME = os.environ.get('LDAP_USERNAME', 'domain\\user') # Use double backslash for literal backslash
LDAP_PASSWORD = os.environ.get('LDAP_PASSWORD', 'YourPasswordHere')
OUTPUT_DIR = "./ldap_dump_output"

# Ensure output directory exists
os.makedirs(OUTPUT_DIR, exist_ok=True)

try:
    print(f"[*] Attempting to dump AD information from {LDAP_HOSTNAME}...")
    command = [
        "ldapdomaindump",
        "-u", LDAP_USERNAME,
        "-p", LDAP_PASSWORD,
        "-o", OUTPUT_DIR,
        LDAP_HOSTNAME
    ]
    
    result = subprocess.run(command, capture_output=True, text=True, check=True)
    print("[+] Command output:")
    print(result.stdout)
    if result.stderr:
        print("[!] Command error output:")
        print(result.stderr)
    print(f"[+] Active Directory dump saved to: {OUTPUT_DIR}")
    print("[+] Generated files: domain_users.html, domain_computers.json, etc.")
except subprocess.CalledProcessError as e:
    print(f"[X] Error during ldapdomaindump execution: {e}")
    print(f"[X] Stderr: {e.stderr}")
    print(f"[X] Stdout: {e.stdout}")
except FileNotFoundError:
    print("[X] Error: 'ldapdomaindump' command not found. Ensure the tool is installed and in your PATH.")
except Exception as e:
    print(f"[X] An unexpected error occurred: {e}")

view raw JSON →