Skip to content

Instantly share code, notes, and snippets.

@tyrells
Last active May 23, 2018 22:50
Show Gist options
  • Save tyrells/e25f1aca0983966f04802d9f76ce32b2 to your computer and use it in GitHub Desktop.
Save tyrells/e25f1aca0983966f04802d9f76ce32b2 to your computer and use it in GitHub Desktop.
LDAP User Enumaration using ldapsearch
#!/bin/bash
# Usage: ./UserEnum_LDAP.sh usernames.txt
# References:
# https://github.com/sensepost/UserEnum
# https://github.com/sensepost/UserEnum/blob/master/UserEnum_LDAP.py
# http://ldapwiki.com/wiki/LDAP%20ping
#
# Output: valid user will begin with E, otherwise will begin with F
LDAP_URI=ldap://127.0.0.1
DOMAIN=contoso.com
while IFS= read -r USERNAME
do
RESULT=`ldapsearch -H $LDAP_URI -b '' -x -LLL -s base "(&(DnsDomain=$DOMAIN)(NtVer=\03\00\00\00)(User=$USERNAME)(AAC=\10\00\00\00))" NetLogon | grep -i ^NetLogon | awk '{print $2}' | cut -c 1`
if [ "$RESULT" == "E" ]; then
echo $USERNAME exists
fi
done < "$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment