Skip to main content

conpass

PyPI version Twitter

Continuous password spraying for Active Directory, as fast as the password policy allows, without locking accounts out.

conpass reads every user's effective password policy (domain policy or fine-grained PSO) and bad password counter on the PDC Emulator, then tries each password as soon as it is safe for that user. Passwords can be added to the password file while it runs.

Blog posts

Warning

conpass does its best to find the effective policy of each account, but a policy it cannot see (for example a PSO it is not allowed to read) can still lead to lockouts. Use it with caution in production environments. In an emergency:

Search-ADAccount -LockedOut | Unlock-ADAccount

Installation

conpass requires Python 3.10 or later.

pipx install conpass
# or, from the sources
pipx install git+https://github.com/login-securite/conpass

Usage

conpass -d hackn.lab -u pixis -p 'P4ssw0rd' -P passwords.txt

Every password of passwords.txt is sprayed on every enabled user, one password on all users before the next one. Users who have no attempt left wait for their observation window to elapse, without blocking the others. The file is watched: passwords added to it later are queued too, and conpass keeps running until Ctrl+C.

Common options:

Option Description
-d, --domain Domain to spray (FQDN)
-u, --username / -p, --password / -H, --hashes Domain account used to read users and policies. Use DOMAIN\user to authenticate in another trusted domain
-D, --dc-ip Any domain controller: the PDC Emulator is found from there
--dns-ip DNS server, by default --dc-ip
--ldaps Only use LDAPS (see below)
-P, --password-file Passwords to spray, one per line. A 32 hexadecimal characters line is sprayed as an NT hash
-U, --user-file Only spray these users
-a, --user-as-pass Also try each username as password
-s, --security-threshold Attempts always left unused below the lockout threshold (default 2, minimum 1)
-db, --database SQLite database of tested credentials (default ~/.config/conpass/conpass.db)
--show Display the credentials found for a domain
--disable-spray Only display the policies and users
-m, --max-threads Number of parallel workers (default 10)

Resuming and results

Every test is recorded in the database, so an interrupted session can be resumed: passwords already tested on a user are skipped, and users whose password was found are not sprayed again.

conpass -d hackn.lab --show

LDAP signing and channel binding

By default conpass connects with LDAP on port 389, authenticating with NTLM and signing and sealing every message, which works whether or not the domain controller requires LDAP signing. If it fails, LDAPS (port 636) is tried, with the channel binding token, which works whether or not the domain controller requires channel binding. --ldaps only uses LDAPS.

Offline mode

Without domain credentials, give the users and the policy to assume. No lockout state can be read, so conpass relies on its own count of failures only:

conpass -d hackn.lab -D 10.0.0.1 -U users.txt -t 5 -o 1800 -P passwords.txt

How it avoids lockouts

The logic follows what domain controllers actually do:

  • Everything goes through the PDC Emulator. badPwdCount and badPasswordTime are not replicated: a failure on another DC is forwarded to the PDC, which holds the authoritative counter and decides the lockout. conpass finds the PDC (fSMORoleOwner, or the _ldap._tcp.pdc._msdcs DNS record), reads the counters there and authenticates there, so the counter it reads is the counter its attempts move. This also avoids the cases where a DC does not forward failures to the PDC.
  • Nothing is reset by a timer. When badPasswordTime is older than the observation window, the next failure restarts the counter at 1, whatever badPwdCount still contains. conpass computes the effective counter the same way, on the PDC clock.
  • The counter is read before every attempt, so failures of the users themselves are taken into account, and a local estimate of conpass' own failures is kept as a floor in case a read lags behind.
  • Locked out accounts are detected with msDS-User-Account-Control-Computed (the lockout bit of userAccountControl is never set), and are only retried once their lockout is over.
  • An attempt lost on a dropped connection is never replayed blindly: it is counted as a failure first.
  • Spraying stops at the first lockout. Attempts already running at that moment may still lock one account each, so a wrong policy can lock out up to one account per worker.

What it detects

  • Valid passwords, including when the logon is refused for another reason: expired password, password to change, expired or disabled account, logon hours or workstation restrictions. These answers are only given once the password is validated.
  • Previous passwords. The DC does not count a failure with one of the two previous passwords (N-1, N-2): when badPasswordTime does not move after a failure, the password is reported as a previous one. They often reveal how a user builds passwords.
  • NTLM grace period. For a few minutes after a password change, NTLM still accepts the previous password. A success on a recently changed password is confirmed with Kerberos, which rejects the previous password without counting a failure. Successes that Kerberos cannot confirm are flagged.

Accounts in Protected Users cannot authenticate with NTLM and are skipped.

Development

python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
pytest
ruff check . && ruff format --check .

The tests include a simulated PDC applying the lockout rules above, with users failing their own logons and dropped connections, to check that spraying never locks an account out.

License

MIT

Metadata

Release files for conpass 0.3.1

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

Source distribution (sdist)

Source distribution for conpass 0.3.1
File Size Uploaded Provenance Actions
conpass-0.3.1.tar.gz 37.4 kB Without provenance Details for conpass-0.3.1.tar.gz

Built distribution (wheel)

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

Total release size: 77.5 kB

Release files / conpass-0.3.1.tar.gz

Download URL conpass-0.3.1.tar.gz
Size 37.4 kB
Tags Source
SHA-256 checksum
How to use checksums
ff2caa3d148c6bdc2a66a01c41511c51179158b77ad81eee41f429320ff23889
BLAKE2b-256 checksum
How to use checksums
a17e1d0c6a18cd5e69067855f3140b2a8b16286f4f60a752536d4514c5789446
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Release files / conpass-0.3.1-py3-none-any.whl

Download URL conpass-0.3.1-py3-none-any.whl
Size 40.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4863ec0d6bdb4e36ff579ac39701c69a9dae74bdccc15d021f8ba8dd0f61dabe
BLAKE2b-256 checksum
How to use checksums
14b297c7de39b9866ad2cb5fd9bcbd481c28b0a049141060a189693ad0dba54d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Security for conpass 0.3.1

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