Skip to content

Instantly share code, notes, and snippets.

@bcoles

bcoles/decaptcha.sh

Last active Feb 13, 2016
Embed
What would you like to do?
Cracks rudimentary CAPTCHA. Requires tesseract.
#!/bin/sh
# decaptcha.sh - Cracks rudimentary CAPTCHA. Requires tesseract.
# ---
image="$1"
output=`mktemp`
charset="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
command -v tesseract >/dev/null 2>&1 || { echo "Tesseract is not installed - (apt-get install tesseract-ocr) - Aborting." >&2; exit 1; }
if [ -z $image ]; then
echo "Usage: ./decaptcha.sh <FILE>"
exit 1
fi
echo "(*) Processing $image..."
echo "tessedit_char_whitelist $charset" | tesseract "$image" "$output" -psm 7 /dev/stdin > /dev/null && cat "$output.txt" && rm "$output.txt"
rm "$output"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment