LDAP相关知识学习


最近对LDAP有点感兴趣(很早就听说过,但一直没有去主动了解相关知识),先mark一些初看上去不错的文章,后期有时间了(等自己对LDAP的知识了解更多了)再将本文内容补全。

搜索关键字:

Ldap

参考链接:

==

Ldapsearch命令的实际使用

在CentOS上需要用下面的命令安装:

$ sudo yum install openldap-clients

第一次查询:

$ ldapsearch -v -x -LLL -H "$ldap_host" -b "$ldap_base" -D "$ldap_user" -w "$ldap_passwd" "$filter" $attrs

# ldap_initialize( ldap://x.x.x.x:389/??base )
# filter: ...
# requesting: dn cn mail homePhone mobile lastLogonTimestamp description whenCreated objectGUID objectSid memberOf
# Size limit exceeded (4)

错误原因:一次查询的entry太多(1000/2000)

解决方法:

http://answers.splunk.com/answers/1538/what-is-ldap-error-size-limit-exceeded.html

1.以LDAP服务器管理员的身份修改”限制”的大小;

2.使用filter的方式进行多次小批量查询。

In AD, the default size limit is typically 1000 entries. There is nothing you can do to change this limit unless you are the LDAP server administrator.

In Splunk, you can use filters to reduce the number of LDAP entries returned so that you do not hit this limit.

解决方法:

http://www.commandlinefu.com/commands/view/2779/bypass-1000-entry-limit-of-active-directory-with-ldapsearch

$ ldapsearch -v -x -LLL -H "$ldap_host" -b "$ldap_base" -D "$ldap_user" -w "$ldap_passwd" -E pr=2147483647/noprompt "$filter" $attrs
参考解答:
$ type ldapsearch
ldapsearch is hashed (/usr/bin/ldapsearch)

$ strings /usr/bin/ldapsearch | grep paged
            [!]pr=<size>[/prompt|noprompt]   (paged results/prompt)
Invalid entries estimate in paged results response.
# with pagedResults %scontrol: size=%d
, , ,

《 “LDAP相关知识学习” 》 有 6 条评论

  1. LDAP落地实战(五):Django集成OpenLDAP认证
    https://mp.weixin.qq.com/s/ZNLufJq67RDCt5aICmTmyg
    LDAP落地实战(四):Jenkins集成OpenLDAP认证
    https://mp.weixin.qq.com/s/S5ozDJSh4yTSfP_glNoiOQ
    LDAP落地实战(三):GitLab集成OpenLDAP认证
    https://mp.weixin.qq.com/s/yDUHS0HdzZclvbjDH9pdbQ
    LDAP落地实战(二):SVN集成OpenLDAP认证
    https://mp.weixin.qq.com/s/NZv9UZ-eYJT86uaxHapgTw
    LDAP落地实战(一):OpenLDAP部署及管理维护
    https://mp.weixin.qq.com/s/JyH5mqwWFt0N1nGYZqBCBQ

  2. The Difference Between LDAP, OpenLDAP, and Active Directory
    https://jumpcloud.com/blog/difference-between-ldap-openldap-active-directory
    `
    LDAP 是协议。用于规范用户/设备和客户端同目录服务器的通信。

    LDAP是轻量目录访问协议(Lightweight Directory Access Protocol)的缩写,LDAP标准实际上是在X.500标准基础上产生的一个简化版本。

    OpenLDAP 和 Microsoft AD 是LDAP的2个具体软件实现,相比之下 Microsoft AD 的功能比 OpenLDAP 更丰富(AD is more feature-rich than OpenLDAP)。
    `

    Active Directory vs OpenLDAP
    https://stackoverflow.com/questions/997424/active-directory-vs-openldap

    AD域和LDAP协议
    https://blog.csdn.net/weixin_43522969/article/details/106924066

    配置OpenLDAP传递身份验证到Active Directory
    https://lework.github.io/2019/07/25/openldap-pass-through-ad/

    工作笔记(一)LDAP和AD介绍以及使用LDAP操作AD域
    https://zhuanlan.zhihu.com/p/46324379

    AD和LDAP的区别
    https://blog.51cto.com/davidwang456/3085212

    Active Directory简介
    https://daiker.gitbook.io/windows-protocol/ldap-pian/8

    Active Directory Domain Services
    https://docs.microsoft.com/en-us/windows/win32/ad/active-directory-domain-services

    LDAP Vs AD: What’s the Difference?
    https://www.parallels.com/blogs/ras/ldap-vs-ad/

  3. Is LDAP a TCP or a UDP protocol?
    https://stackoverflow.com/questions/5913941/is-ldap-a-tcp-or-a-udp-protocol
    `
    Normally LDAP is a TCP protocol. But Microsoft uses LDAP also over UDP.
    So it is both.
    `
    3.1.1.3.1.11 LDAP Search Over UDP
    https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/3fad0ec9-414c-432a-ba0b-837c74091dd6?redirectedfrom=MSDN

    https://wiki.wireshark.org/LDAP

    https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml?search=ldap
    `
    ldap 389 tcp Lightweight Directory Access Protocol
    ldap 389 udp Lightweight Directory Access Protocol

    ldaps 636 tcp ldap protocol over TLS/SSL (was sldap)
    ldaps 636 udp ldap protocol over TLS/SSL (was sldap)
    `

  4. 域用户密码爆破研究
    https://mp.weixin.qq.com/s/jay7BUcdXYyr5bu5XPsN8g
    `
    本篇主要针对Kerberos、LDAP、DCE/RPC、SMB协议的登陆认证过程进行研究,同时分析认证过程中产生的流量特征,制定对应的检测规则。

    0x01. Kerberos协议
    开启日志审核后,会产生Kerberos身份验证服务的日志,成功的事件ID为4768,失败事件ID为4771

    0x02. LDAP协议
    开启后进行爆破登陆,会产生事件ID为4625的安全日志

    0x03. DCE/RPC协议
    登录失败: 产生事件ID为4625的登陆日志
    登陆成功: 产生事件ID为4624的登陆日志

    0x04. SMB协议
    登陆失败,事件ID:4625
    登陆成功,事件ID:4624

    0x05. 总结
    根据上述几种协议登陆审核日志来看,事件ID跟认证方式(Kerberos,NTLM)有关,跟协议无关(LDAP、SMB、RPC事件ID相同)。

    利用Kerberos、DCE/RPC、SMB协议进行爆破的时候,攻击机可以在非域环境中,且利用DCE/RPC协议在攻击的时候由于使用了动态端口,从流量层面上来说被安全设备检测的概率会小一些。

    检测方法

    1)登陆日志
    爆破行为会在短时间内产生大量的审核失败的登陆日志

    2)流量特征
    根据上述几种协议中认证失败的流量特征,对相同源IP、目的IP的失败次数做统计,超过阈值告警。
    `

  5. 渗透基础——通过LDAP协议暴力破解域用户的口令
    https://mp.weixin.qq.com/s/vYeR9FDRUfN2ZczmF68vZQ
    https://github.com/3gstudent/Homework-of-Powershell/blob/master/Invoke-DomainPasswordSprayOutsideTheDomain.ps1
    `
    1.域内暴力破解域用户口令 – DomainPasswordSpray

    流程如下:

    (1)获得域内用户的口令策略

    根据lockoutThreshold的数值决定尝试的次数,避免帐户被锁定。

    (2)获得域用户列表

    列出所有域用户后,需要对用户的属性进行判断,去除被禁用和被锁定的用户。

    (3)尝试破解

    2.域外暴力破解域用户口令 – ldapsearch / Invoke-DomainPasswordSprayOutsideTheDomain

    如果已经获得了一个用户的口令,那么可以先读取域内用户的口令策略和用户列表,方法同上。

    如果没有任何用户的口令,只能进行盲目的尝试。
    `

回复 abc 取消回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注