freeBuf
主站

分类

漏洞 工具 极客 Web安全 系统安全 网络安全 无线安全 设备/客户端安全 数据安全 安全管理 企业安全 工控安全

特色

头条 人物志 活动 视频 观点 招聘 报告 资讯 区块链安全 标准与合规 容器安全 公开课

点我创作

试试在FreeBuf发布您的第一篇文章 让安全圈留下您的足迹
我知道了

官方公众号企业安全新浪微博

FreeBuf.COM网络安全行业门户,每日发布专业的安全资讯、技术剖析。

FreeBuf+小程序

FreeBuf+小程序

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

如何使用LDAP-Monitoring-Watchdog实时监控 LDAP 目录中记录修改
Alpha_h4ck 2025-01-15 12:41:21 77735
所属地 广西

关于LDAP-Monitoring-Watchdog

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

该工具提供了一种机制来跟踪和可视化用户和组条目的修改、添加和删除,使用户可以将预期更改与实际更改关联起来并识别潜在的安全事件。它是为 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 retrieve

 

REFRESH_RATE = 60 # Refresh the directory every 60 seconds.

 

LDAP_USERNAME = 'Emily'

LDAP_PASSWORD = 'qwerty123'

USE_SSL = True

 

DISABLE_COLOR_OUTPUT = False

SLACK_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

工具运行演示

终端(带颜色高亮)输出

Slack输出

许可证协议

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

项目地址

LDAP-Monitoring-Watchdog:【GitHub传送门

参考资料

https://joshua.hu/ldap-watchdog-openldap-python-monitoring-tool-realtime-directory-slack-notifications

# 跟踪 # LDAP # 威胁监测 # 安全监测 # 安全监控
免责声明
1.一般免责声明:本文所提供的技术信息仅供参考,不构成任何专业建议。读者应根据自身情况谨慎使用且应遵守《中华人民共和国网络安全法》,作者及发布平台不对因使用本文信息而导致的任何直接或间接责任或损失负责。
2. 适用性声明:文中技术内容可能不适用于所有情况或系统,在实际应用前请充分测试和评估。若因使用不当造成的任何问题,相关方不承担责任。
3. 更新声明:技术发展迅速,文章内容可能存在滞后性。读者需自行判断信息的时效性,因依据过时内容产生的后果,作者及发布平台不承担责任。
本文为 Alpha_h4ck 独立观点,未经授权禁止转载。
如需授权、对文章有疑问或需删除稿件,请联系 FreeBuf 客服小蜜蜂(微信:freebee1024)
被以下专辑收录,发现更多精彩内容
+ 收入我的专辑
+ 加入我的收藏
Alpha_h4ck LV.10
好好学习,天天向上
  • 2359 文章数
  • 1020 关注者
Tetragon:一款基于eBPF的运行时环境安全监控工具
2025-01-21
DroneXtract:一款针对无人机的网络安全数字取证工具
2025-01-21
CNAPPgoat:一款针对云环境的安全实践靶场
2025-01-21
文章目录