Commit graph

35 commits

Author SHA1 Message Date
Reedy ed6b393644 captcha.py: Swap x0/x1 and y0/y1 values before d.arc() call
Bug: T354099
Change-Id: I0dfd7dfcb2130d612817b4cf8bd644a7d4eb4e40
(cherry picked from commit a12e5cd5b0)
2024-07-21 10:13:32 +00:00
jenkins-bot ebb8f73ae3 Merge "captca.py: Fix PIL 10 support again" 2024-01-29 19:36:50 +00:00
Reedy cbbe6611b4 FancyCaptcha: Remove deprecated blacklist parameter
Bug: T277936
Depends-On: Ia467c4fb56e9920826a2e4e505e277683ab154b8
Change-Id: Ia64c20bf4638cdba85860dbd2852ee04f9498561
2024-01-27 15:07:32 +00:00
Reedy bdd127a276 captca.py: Fix PIL 10 support again
Bug: T354099
Follows-Up: Ia17157d45995b78c6a73f844dfe7d20d09564748
Change-Id: I9d1fe7ad7f12fd79c960574daf79e558d88cb02c
2024-01-27 14:26:02 +00:00
Reedy 602906527e *.py: Fixup a couple more linting issues
Change-Id: Ic0ba59dc1af1bdefab606a939887752b3b3b3c80
2024-01-16 22:25:27 +00:00
James D. Forrester 5d6a6aaedf *.py: Auto-fix using black
Change-Id: I4645717df655ac570c1fe6e69058082a1fa7ee6b
2024-01-16 12:26:13 -05:00
Reedy 28f297f1f7 Add tox.ini for python linting
Base file from:
c4790b589b/tox.ini

Most failing rules disabled, rather than fixing now

Bug: T355090
Change-Id: Ie0f499809d84b94b95dddac9abd433c8f81e04ce
2024-01-16 15:18:51 +00:00
Kosta Harlan d1bc02e2fb catpcha.py: Use opts.output
Script fails on macOS Python 3.9.2 otherwise, with "name 'output' is not
defined".

Change-Id: Id3df19b4a4dedf69f860f1a41348770ac1207377
2024-01-16 12:56:50 +00:00
jenkins-bot c60beba52d Merge "captcha.py: Increase number and position of random lines in the text" 2024-01-15 21:51:34 +00:00
Amir Sarabadani 172b3b53bf captcha.py: Increase number and position of random lines in the text
The current one doesn't add that many lines, this is making it much
better.

Bug: T141490
Change-Id: I25589457c9f7d5871b86b7c70747074b0ef98170
2024-01-15 21:00:07 +00:00
Reedy 1a305a40ee captcha(-old).py: Fix undefined variables and remove some unused ones
Change-Id: I13b46cceb68a0118274a1fe9d3547b193f62b53d
2024-01-15 19:05:27 +00:00
Amir Sarabadani 69c7a8dbdc Add negative kerning and lines to captcha
This should throw off many off-the-shelf OCRs.

Credit for this patch is Brian Wolff, I just found the code and turned
it into a patch. License: GPL V2.

Examples of output of the patch: T141490#9459799

Bug: T141490
Co-authored-by: Brian Wolff <bawolff+wn@gmail.com>
Change-Id: Ia17157d45995b78c6a73f844dfe7d20d09564748
2024-01-15 14:56:54 +01:00
Reedy fbf8d90063 captcha(-old).py: Support Pillow 10
getsize() function was removed in version 10

Bug: T354099
Change-Id: I019a5a89de4340d73a938c907c0a6f5cc22a659c
2024-01-02 02:56:54 +00:00
Gergő Tisza 3953e838f8
Make badwordlist optional
Follows up I8e758023b38a4d450a0bf02b3bfc0b5033959be7.

Bug: T277936
Change-Id: I20f896f86875c9b11e8a998bca6e08f8c38554c1
2023-07-28 15:03:04 -07:00
Reedy db06ec876b FancyCaptcha: Deprecate and add alternative for blacklist parameter in generation
Bug: T277936
Change-Id: I8e758023b38a4d450a0bf02b3bfc0b5033959be7
2022-07-04 16:16:20 +00:00
Reedy 3b477b543d Update captch(-old)?.py shebang to python 3
Bug: T268468
Change-Id: I9e3918939365a3142772627a192b0d92be7d7000
2020-12-01 14:16:56 +00:00
jenkins-bot 810e6b8598 Merge "Fix characters typo in captcha python scripts" 2020-10-28 22:10:59 +00:00
Reedy b86cc888a5 Fix characters typo in captcha python scripts
Change-Id: I855a43d3bd331974c63b4eacf8178805db6de7c1
2020-10-28 19:45:02 +00:00
Platonides 520e1ab036 Make captcha.py work under python 3
It was just a matter of converting some
divisions to integer ones.

Bug: T263223
Change-Id: Ia04efa1d657bbfa2ee4aed44be504cc3ac0b7196
2020-10-28 19:25:04 +00:00
Reedy 69512c8046 Use floor division (//) when calculating chunks in python
Also remove int() casting from captcha-old.py which was added
in 66152162fe but diverges from
captcha.py

Most of the code should be the same in these two files should
be the same bar the actual image processing...

Bug: T263223
Follows-Up: If4f6bc9048aceacc41538c001255425e848fd8e9
Change-Id: I3062e64fc380022ca9fee793bc522f212eb873d3
2020-09-18 17:18:53 +00:00
Florian Schmidt 66152162fe Add threads parameter to captcha.py for multithread CAPTCHA generation
Bug: T157734
Change-Id: If4f6bc9048aceacc41538c001255425e848fd8e9
2017-06-12 17:11:58 +01:00
Reedy eea24979ed Make captcha python scripts python3 compatible
Remove trailing whitespace

Bug: T157888
Change-Id: I8b2da97c40f8748a1aad5509dddff638a7f3f945
2017-02-12 01:21:52 +00:00
Tim Starling 6f286e52db Add a gradient to FancyCaptcha
This defeats naive thresholding, giving Tesseract break rate of 0 out of
1000, even if a sensible threshold value is hand-chosen. Reduced the
text value and noise to make room for the gradient, but kept an SNR of
1.3, as before, which provides good legibility.

Obviously the gradient can be removed with custom preprocessing -- the
point of these changes is to raise the bar from "unconfigured Tessearct"
to "some small amount of developer effort".

Change-Id: I30ebc904ca59bf29a2aa812f881a077a13493e68
2014-09-26 10:41:26 +10:00
Tim Starling df4806c64c Improve FancyCaptcha resistance to OCR
Tesseract is a popular open source OCR package. Running it on
FancyCaptcha images, with no training or configuration, yielded a 56%
break rate. By restricting the character set, the OCR break rate was
improved to 66%.

So:
* Reduce k, increase wob scale, increase rr fuzz. The net effect of
  these three changes is to more reliably bend the baseline. In the old
  captcha, the baseline would often be bent by chance, but when it
  wasn't bent, it provided a very easy challenge for the OCR engine.
  This reduced the break rate from 66% to around 40%.
* Introduce additive noise, based on a bilinear upscale of a random
  greyscale image. This, combined with the above change, reduces the
  Tesseract break rate to 6%.

Change-Id: I05b5bb6475de9378cd89cce13b1b2f28b32cd405
2014-09-26 08:47:55 +10:00
emufarmers cd7106e0d9 Add a default blacklist for FancyCaptcha.
If a blacklist is not specified using the '--blacklist' command-line option,
captcha.py will use a default blacklist, included in this patch-set.

Bug: 21025
Change-Id: I93eeaead4a86b38cf5aa0049ac5e61e5b4935b58
2013-06-12 20:52:27 -07:00
Aaron Schulz 3b987fb098 Fixed blacklist param for captcha script.
* Also closes the word list file handles.

Change-Id: I4feac2eca6ed29756b6fcbd38acc5e16bc26b2ce
2012-12-18 13:20:42 -08:00
Platonides 1f740061f5 Support generation of random challenges instead of wordlist-based ones.
Change-Id: Ib23dc4c7baab67184d25b15b4dde9b2a1f879924
2012-11-01 16:56:48 +01:00
Platonides 8cfde58450 Allow to generate the challenges from more than 2 wordlist entries.
Change-Id: I94a84e703a4072eb083177158690de190bee53fa
2012-11-01 15:49:37 +00:00
Platonides 008c232ca6 Provide parameters for setting the min/max length of the captcha "word" (challenge).
Change-Id: Ic2968cec884534dfa8ae7479589a1622a4db7de0
2012-11-01 15:48:18 +00:00
Sam Reed 0324318073 Correct the address of the FSF in extension GPL headers
59 Temple Place -> 51 Franklin Street
2010-06-21 13:45:17 +00:00
Alex Z. f81c299c27 Various code cleanups for the captcha generating script
* Use optparse instead of getopt
* Replace deprecated md5 module
* Replace deprecated string module functions with string methods
* More graceful failure
* Allow users to set the font size
* Don't run forever if no valid word combinations can be found
2009-09-08 01:11:52 +00:00
Greg Sabino Mullane 9aafa888c0 Skip words if they don't contain all letters. 2008-01-07 03:28:38 +00:00
Brion Vibber b2e474ebba Optional blacklist for word pair generation 2007-06-29 19:57:01 +00:00
Brion Vibber 74e3c3bb9f Add options to break up the captcha image storage with hash-digit subdirectories to avoid trawling through a giant directory on every hit 2007-02-19 20:09:03 +00:00
Brion Vibber cf1c61a3bd Captcha generating script by Neil Harris
with some tweaks for command-line options
Requires Python Imaging Library, a word list file, and a TrueType font.
2006-01-27 10:22:37 +00:00