Bad CAPTCHA, I’m a robot.
For this, I knew I had to use some sort of OCR that was smart enough to handle the graphic changing and inputting a raw image.
Tesseract it is!
import pytesseract
import requests
import cv2
from lxml import html
import hashlib
def image1():
s = requests.session()
pytesseract.pytesseract.tesseract_cmd = r'F:\Program Files\Tesseract-OCR\tesseract.exe'
url = "http://progimage.ctf.issessions.ca:15000/"
page = s.get(url)
tree = html.fromstring(page.content)
htmlimg = tree.xpath('///img[@alt="captch challenge graphic"]/@src')
imgfile = requests.get(url + htmlimg[0])
file = open("prog1.gif", "wb")
file.write(imgfile.content)
file.close()
img = cv2.VideoCapture("prog1.gif")
ret, frame = img.read()
text = (pytesseract.image_to_string(frame)).strip()
print(text)
resp = s.get(url + "?answer=" + text)
print(resp.content)
This python code works as follows: