域渗透之ldap协议

LDAP(Light Directory Access Protocal)是一个基于X.500标准的轻量级目录访问协议,LDAP是支持跨平台的Internet协议,只需要通过LDAP做简单的配置就可以与服务器做认证交互。可以大大降低开发的成本。
windows Active Diretcory就是一个支持LDAP的微软产品。

活动目录是指域环境中提供目录服务的组件,它用于存储网络对象信息(用户、组、打印机等)。

把活动目录理解成一个可扩展的,撞门为了查询、浏览、搜索优化的特殊数据库,就像windows文件目录的结构一样。目录数据库与MySQL这种关系型数据库相比,具有优异的可读性,但是可写性能很差,而且没有备份还原这样的功能。

信息收集:操作系统、权限、用户、ip段、杀软、端口、进程、服务、补丁、计划任务、共享、会话

利用LDAP进行信息收集
前提是能够访问DC的389端口,且已经知道域内的一个账号密码,假设我们已经知道域内用户test1的密码时admin@123,DC的ip是192.168.190.130

1.使用ldapsearch获取信息
该工具只能在域环境下使用,因此一般当获得shell后,挂socks代理,在本地进行操作查询。
参数说明:
-x:进行简单认证
-H:服务器地址
-D:用来绑定服务器的DN
-w:绑定DN的密码
-b:指定要查询的根节点
•获取所有信息
•ldapsearch.exe -x -H ldap://192.168.17.133:389 -D "CN=test1,CN=Users,DC=hacker,DC=test" -w Asdfqwer.. -b "DC=hacker,DC=test"
•查询用户
•ldapsearch.exe -x -H ldap://192.168.17.133:389 -D "CN=test1,CN=Users,DC=hacker,DC=test" -w Asdfqwer.. -b "DC=hacker,DC=test" "(&(objectClass=user)(objectCategory=person))" | grep ^cn
•查询计算机名
•ldapsearch.exe -x -H ldap://192.168.17.133:389 -D "CN=test1,CN=Users,DC=hacker,DC=test" -w Asdfqwer.. -b "DC=hacker,DC=test" "(&(objectCategory=computer)(objectClass=computer))" | grep ^cn
•查询域内组
•ldapsearch.exe -x -H ldap://192.168.17.133:389 -D "CN=test1,CN=Users,DC=hacker,DC=test" -w Asdfqwer.. -b "DC=hacker,DC=test" "(&(objectCategory=group))" | grep ^cn

2.使用PowerSploit工具搜索信息
•模块目录
•$env:PSModulePath
•更改策略
•set-executionpolicy remotesigned
•加载模块
•Import-Module -name 路径
•下载地址:
https://github.com/PowerShellMafia/PowerSploit

$uname="test1"
$pwd=ConvertTo-SecureString "Asdfqwer.." -AsPlainText -Force
$cred=New-Object System.Management.Automation.PSCredential($uname,$pwd)

•查询用户
Get-NetUser -Domain hacker.test -DomainController 192.168.17.133 -ADSpath "LDAP://DC=hacker,DC=test" -Credential $cred | fl cn
•查询计算机名
Get-NetComputer -Domain hacker.test -DomainController 192.168.17.133 -ADSpath "LDAP://DC=hacker,DC=test" -Credential $cred | fl cn
•查询域内组
Get-NetGroup -Domain hacker.test -DomainController 192.168.17.133 -ADSpath "LDAP://DC=hacker,DC=test" -Credential $cred | fl cn

3.sharpview获取信息
•查询所有用户
•SharpView.exe Get-NetUser -Domain hacker.test -Server 192.168.17.133 -Credential test1@hacker.test/Asdfqwer.. | findstr cn
•模块
•Get-DomainController
•Get-NetUser
•Get-DomainComputer

•下载地址
https://github.com/tevora-threat/SharpView

posted @ 2020-11-21 13:51  micr067  阅读(1525)  评论(0编辑  收藏  举报