diff --git a/captchasolver/README.md b/captchasolver/README.md new file mode 100644 index 000000000..7e29b4552 --- /dev/null +++ b/captchasolver/README.md @@ -0,0 +1,22 @@ +# Captcha Solver +A simple python script for solving simple captchas + +## Modules Used + +- pytesseract +- sys +- os +- PIL + +## Requirements + +- tesseract +`You can download tesseract from https://tesseract-ocr.github.io/tessdoc/Home.html` +- pytesseract +`pip install pytesseract` + +- After you install tesseract replace with your tesseract location in csolver.py + +## How to use +`python csolver.py captcha_image` + diff --git a/captchasolver/csolver.py b/captchasolver/csolver.py new file mode 100644 index 000000000..b1d7d2fb4 --- /dev/null +++ b/captchasolver/csolver.py @@ -0,0 +1,33 @@ +import pytesseract +import sys +import os +from PIL import Image + +# Set Tesseract location +pytesseract.pytesseract.tesseract_cmd = "" + +# Image +im = sys.argv[1] + + +def resize_image(img): + img = Image.open(img) + img = img.resize((1000, 500), Image.NEAREST) + img.save("resized.png") + + +def solve(img): + resize_image(img) + cr = pytesseract.image_to_string("resized.png") + os.remove("resized.png") + # First resize captcha and try to read it. + if cr != "\x0c": + print(cr) + else: + # If it cant read try to read in normal size + cr = pytesseract.image_to_string(im) + print(cr) + + +# Run +solve(im) diff --git a/captchasolver/requirements.txt b/captchasolver/requirements.txt new file mode 100644 index 000000000..9528f4962 --- /dev/null +++ b/captchasolver/requirements.txt @@ -0,0 +1 @@ +pytesseract diff --git a/captchasolver/samples/c1.png b/captchasolver/samples/c1.png new file mode 100644 index 000000000..4c49b609d Binary files /dev/null and b/captchasolver/samples/c1.png differ diff --git a/captchasolver/samples/c2.png b/captchasolver/samples/c2.png new file mode 100644 index 000000000..8bffef59f Binary files /dev/null and b/captchasolver/samples/c2.png differ diff --git a/captchasolver/samples/c3.png b/captchasolver/samples/c3.png new file mode 100644 index 000000000..2836c7c60 Binary files /dev/null and b/captchasolver/samples/c3.png differ diff --git a/captchasolver/samples/c4.png b/captchasolver/samples/c4.png new file mode 100644 index 000000000..53e620a15 Binary files /dev/null and b/captchasolver/samples/c4.png differ diff --git a/captchasolver/samples/c5.gif b/captchasolver/samples/c5.gif new file mode 100644 index 000000000..5c03c0db8 Binary files /dev/null and b/captchasolver/samples/c5.gif differ diff --git a/captchasolver/samples/c6.png b/captchasolver/samples/c6.png new file mode 100644 index 000000000..d6890d389 Binary files /dev/null and b/captchasolver/samples/c6.png differ