如何使用LDAP-Monitoring-Watchdog实时监控 LDAP 目录中记录修改

admin 2025年1月28日14:30:50评论11 views字数 2765阅读9分13秒阅读模式
如何使用LDAP-Monitoring-Watchdog实时监控 LDAP 目录中记录修改

关于LDAP-Monitoring-Watchdog

LDAP-Monitoring-Watchdog是一种用于实时监控 LDAP 目录中记录更改的工具,该工具能够与Linux兼容,用于检测目录变化,为管理员和安全研究人员提供对添加、修改和删除的可见性。

如何使用LDAP-Monitoring-Watchdog实时监控 LDAP 目录中记录修改

该工具提供了一种机制来跟踪和可视化用户和组条目的修改、添加和删除,使用户可以将预期更改与实际更改关联起来并识别潜在的安全事件。它是为 OpenLDAP 和 Linux 创建的,但它可能适用于 LDAP 的其他实现。它是用 Python 编写的,只需要 ldap3 库。

功能介绍

1、通过 Slack webhook 集成随时了解 LDAP 目录中发生的情况;

2、查看 LDAP 中出现的新员工、离职人员和晋升信息;

3、监控人力资源部门何时做了什么;

4、检测 LDAP 中未经授权的更改操作;

5、监控意外泄露的数据;

6、检测用户何时登录和退出 LDAP;

7、根据LDAP特定属性的旧/新值进行微调以忽略细粒度属性;

8、颜色高亮输出显示;

工具要求

1、Python 3;

2、软件包ldap3( pip install ldap3)。如果使用 Slack webhook,则还需要requests软件包 ( pip install requests);

3、用于通知的 Slack Webhook URL(可选);

工具安装

由于该工具基于Python 3开发,因此我们首先需要在本地设备上安装并配置好最新版本的Python 3环境。

安装依赖组件

pip install ldap3


pip install requests


源码获取

广大研究人员可以直接使用下列命令将该项目源码克隆至本地:

git clone https://github.com/MegaManSec/LDAP-Monitoring-Watchdog.git

然后切换到项目目录中,运行工具提供的install.sh脚本即可:

$ sudo ./install.sh "https://hooks.slack.com/services/[...]"ldap-watchdog has been installed, the service is started, and log rotation is set up.

工具配置示例

CONTROL_UUID = 'a71c6e4c-8881-4a03-95bf-4fc25d5e6359' # The entryUUID of an entry in the directory which must always have some type of modification.CONTROL_USER_ATTRIBUTE = '' # Specifically, if this is set, this is the attribute that must have changed.LDAP_SERVER = 'ldaps://ldaps.intra.lan' # The LDAP(S) server.BASE_DN = 'dc=mouse,dc=com' # The basename used by the directory.SEARCH_FILTER = '(&(|(objectClass=inetOrgPerson)(objectClass=groupOfNames)))'SEARCH_ATTRIBUTE = ['*', '+']  # replace with the attributes you want to retrieveREFRESH_RATE = 60 # Refresh the directory every 60 seconds.LDAP_USERNAME = 'Emily'LDAP_PASSWORD = 'qwerty123'USE_SSL = TrueDISABLE_COLOR_OUTPUT = FalseSLACK_BULLETPOINT = ' u2022   ' # Prepend this to each change if sending notifications via Slack.IGNORED_UUIDS = ['e191c564-6e6d-42c1-ae51-bda0509fe846', '8655e0d9-ecdc-46ce-ba42-1fa3dfbf5faa'] # Ignore any changes users with these UUIDs.IGNORED_ATTRIBUTES = ['modifyTimestamp', 'phoneNumber', 'officeLocation', 'gecos'] # Ignore any modifications of these attributes.CONDITIONAL_IGNORED_ATTRIBUTES = {  'objectClass': ['posixAccount'], # Ignore changes to the objectClass attribute if the new or old value is posixAccount.  'memberOf': ['cn=mailing-list-user,ou=Accessgroups,dc=mouse,dc=com', 'cn=interns,ou=Accessgroups,dc=mouse,dc=com'], # Ignore changes to the memberOf attribute if the new or old value is either "cn=mailing-list-user,ou=Accessgroups,dc=mouse,dc=com" or "cn=interns,ou=Accessgroups,dc=mouse,dc=com".  'organizationalStatus': ['researcher'], # Ignore changes to the organizationalStatus attribute if the new or old value is 'researcher'.}SLACK_WEBHOOK = os.getenv('SLACK_WEBHOOK_URL') # Use a Slack webhook, and retrieve it from the environmental value.
工具使用

下列命令将控制工具脚本持续监控LDAP目录,并将报告发送给控制台和Slack:

python3 ldap-watchdog.py
工具运行演示

终端(带颜色高亮)输出

如何使用LDAP-Monitoring-Watchdog实时监控 LDAP 目录中记录修改

Slack输出

如何使用LDAP-Monitoring-Watchdog实时监控 LDAP 目录中记录修改

许可证协议

本项目的开发与发布遵循AGPL-3.0开源许可协议。

项目地址

LDAP-Monitoring-Watchdog

https://github.com/MegaManSec/LDAP-Monitoring-Watchdog

原文始发于微信公众号(FreeBuf):如何使用LDAP-Monitoring-Watchdog实时监控 LDAP 目录中记录修改

 

免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2025年1月28日14:30:50
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   如何使用LDAP-Monitoring-Watchdog实时监控 LDAP 目录中记录修改https://cn-sec.com/archives/3668118.html
                  免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉.

发表评论

匿名网友 填写信息