about captcha.py image generator

classic Classic list List threaded Threaded
4 messages Options
Fxp
Reply | Threaded
Open this post in threaded view
|

about captcha.py image generator

Fxp
Don't expect too much from a guide for dummies made by a dummy.
For windows.

About the captcha.py generator.

TABLE OF CONTENT
- what it does ?
- where to find it ?
- how it works ?
- The image generator
- "No module named image" error
- "empty range" error
- credits


1) WHAT IT DOES ?

The captcha system written by Brion Vibber and published under GNU
licence (unlike most of the captcha system to be found in php on the net
which are copyrighted) doesn't build the captcha images on the fly.
Instead, you have to produce a bunch of images.

The generator take a word in a wordlist.
Creates an image with the word on it.
It encrypts the word using a key.
Stores the image in a directory, with the encrypted as filename (png image)


2)WHERE TO FIND IT ?

in the ConfirmEdit extension:

http://cvs.sourceforge.net/viewcvs.py/wikipedia/extensions/ConfirmEdit/
(for the html access)

http://www.mediawiki.org/wiki/Download_from_CVS
(for indications on the cvs access, I intend to create a tutorial on
using CVS with Eclipse)

Download the three files:
ConfirmEdit.php
FancyCaptcha.php
captcha.py


3)HOW IT WORKS ?
(only as much as I understand)

Apart from the explanations provided in the php files itself, you can
find some indications in the post from Brion:
http://article.gmane.org/gmane.org.wikimedia.mediawiki/10179/match=fancycaptcha

Mainly, you have to fill some of the variables in the fancycaptha.php
file, with :

$wgCaptchaClass = 'SimpleCaptcha'
becomes
$wgCaptchaClass = 'FancyCaptcha';

$wgCaptchaDirectory the directory where the images are stored at your
webhost (NO EXAMPLE yet)

$wgCaptchaSecret by the key used to encrypt the words of your list
ex:
$wgCaptchaSecret='turtle';



4)THE IMAGE GENERATOR

The file captcha.py is a file written in python to produce the images,
encrypt them and store them with the encrypted filename.

As it is written in python, you will need a python interpreter. You
might already have one installed with some Apache-Mysql-php kits. Check
your Apache folder, and your c:\ folder. Search your computer for the
file python.exe

If not found, download and install a brand new one from:
http://www.python.org/download/

You might use this opportunity to get a newer one if yours is too old,
because we will have to add some "plugin" which can't use python
versions prior to 2.1

The command line I used is (can be used as .bat):

c:\python24\python.exe C:\pytest\captcha.py --wordlist C:\pytest\w.txt
--output C:\pytest\ --key turtle --count 10 --fill 2 --font Arial

Where:
c:\python24\python.exe is the newer interpreter I installed (there is an
older one attached to my apache, and if I just call python.exe on
command line, the old one comes up. To check which one you are using,
type: python -v )

C:\pytest\captcha.py is the path to the captcha.py file I downloaded
from the ConfirmEdit extension. As you can notice, to avoid problems
with space in windows paths like "my document", I created a filed called
"pytest" (less than 8 letters) directly at the root of my system.

--wordlist C:\pytest\w.txt is the path to a text file I created with a
list of words. Each word on a line, which means: I type a word, and I
hit Enter. On my first attempt, I created only five of them. This might
be too short. Use a longer list: 10 to 20

--output C:\pytest\ path to the directory I want the images to be
stored. Not sure if the ending \ is necessary. It worked with it.

--key turtle  this is the key used to encrypt the words. It has to be
the same as the $wgCaptchaSecret variable in the fancycaptcha.php file,
otherwise it won't be able to decrypt it. Just use a secret word: be
creative.

--count 10 really, I haven't got a clue what it is, and how it must be
set up. I tried 3, it didn't work. Hopefully, someone will tell us if
there is a minimum and a max for this

--fill 2 same as before, no idea what it is for and what the inferior
and superior limits are

--font Arial At first I didn't use this parameter. I tried this, and
maybe it helped this working...



5) NO MODULE NAMED IMAGE error

At first, you might get this error:

Traceback (most recent call last):
  File "C:\pytest\captcha.py", line 26, in ?
    import Image
ImportError: No module named Image

DIAGNOSIS: you don't have the image module, which can be found in a
library for python.

SOLUTION
Download and install PIL from the middle of this page:
http://www.pythonware.com/products/pil/

Beware, you have to choose the PIL corresponding to your version of python


6) EMPTY RANGE error

After you have installed the PIL, something can again be wrong:

Traceback (most recent call last):
  File "C:\pytest\captcha.py", line 145, in ?
    word1 = words[random.randint(0,len(words)-1)]
  File "c:\python24\lib\random.py", line 216, in randint
    return self.randrange(a, b+1)
  File "c:\python24\lib\random.py", line 192, in randrange
    raise ValueError, "empty range for randrange() (%d,%d, %d)" % (istart,
, width)
ValueError: empty range for randrange() (0,0, 0)


As long as I tried, I believe this is due to an error in the --fill or
--count parameters of the command line.

And in the end: IT WORKED FOR ME

image_e920d182_6ea824a00198ed4f.png
image_b18fd5f0_bb1e8e848697c902.png
image_0206469a_889d0b2dab698f4d.png
image_d360bf03_ab8400fd4dfc4b9d.png
image_7ae15d3e_aca3a3ea9d4c36a4.png
image_ccc4294b_e9db09ebf2dd58d7.png
image_b00e56fb_bd1657b6488424dc.png

7) CREDITS

Thank you very much to Brion Vibber for developing extensions for
"advanced dummies" like me, only able of rewarding him by grinning about
having to understand python and finding out by themselves what on earth
the parameters for command line might be. Ingratitude has no depth :-)

Hope this will help. please do tell me what is missing. Hopefully, there
will soon be a page created in mediawiki for this extension (no search
on meta.mediawiki came up with something like fancycaptha). As soon as
the creator puts it on, I might add this participation to it. Be free to
add what I omitted, and correct where I was wrong or unclear.

François

_______________________________________________
MediaWiki-l mailing list
[hidden email]
http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
Reply | Threaded
Open this post in threaded view
|

Re: about captcha.py image generator

Richard Wade
A captcha system is a much needed extension for MediaWiki, so thanks to
those working on it. My experience so far with automated or "undesirable"
edits is that they could be stopped by turning off anonymous edits and
using a captcha system for user registration.

Is it anticipated to use the MediaWiki captcha extension for all edits, or
will the option be available to use them only for user registration? I
understand that security comes at a price in terms of usability, but
entering a captcha string for every edit may be too cumbersome for
prolific editors.

How about having a 'level of trust', where certain users can be flagged to
bypass the captcha system for their edits? Therefore, new editors will
need to input a captcha string for each edit, but those who have been
flagged by the admins will not need to do so? I suppose this would work
for small Wikis, but not for anything as busy as Wikipedia.
--
rik

On Wed, February 8, 2006 08:44, FxParlant wrote:

> Don't expect too much from a guide for dummies made by a dummy.
> For windows.
>
> About the captcha.py generator.
>
> TABLE OF CONTENT
> - what it does ?
> - where to find it ?
> - how it works ?
> - The image generator
> - "No module named image" error
> - "empty range" error
> - credits
>
>
> 1) WHAT IT DOES ?
>
> The captcha system written by Brion Vibber and published under GNU
> licence (unlike most of the captcha system to be found in php on the net
> which are copyrighted) doesn't build the captcha images on the fly.
> Instead, you have to produce a bunch of images.
>
> The generator take a word in a wordlist.
> Creates an image with the word on it.
> It encrypts the word using a key.
> Stores the image in a directory, with the encrypted as filename (png
> image)
>
>
> 2)WHERE TO FIND IT ?
>
> in the ConfirmEdit extension:
>
> http://cvs.sourceforge.net/viewcvs.py/wikipedia/extensions/ConfirmEdit/
> (for the html access)
>
> http://www.mediawiki.org/wiki/Download_from_CVS
> (for indications on the cvs access, I intend to create a tutorial on
> using CVS with Eclipse)
>
> Download the three files:
> ConfirmEdit.php
> FancyCaptcha.php
> captcha.py
>
>
> 3)HOW IT WORKS ?
> (only as much as I understand)
>
> Apart from the explanations provided in the php files itself, you can
> find some indications in the post from Brion:
> http://article.gmane.org/gmane.org.wikimedia.mediawiki/10179/match=fancycaptcha
>
> Mainly, you have to fill some of the variables in the fancycaptha.php
> file, with :
>
> $wgCaptchaClass = 'SimpleCaptcha'
> becomes
> $wgCaptchaClass = 'FancyCaptcha';
>
> $wgCaptchaDirectory the directory where the images are stored at your
> webhost (NO EXAMPLE yet)
>
> $wgCaptchaSecret by the key used to encrypt the words of your list
> ex:
> $wgCaptchaSecret='turtle';
>
>
>
> 4)THE IMAGE GENERATOR
>
> The file captcha.py is a file written in python to produce the images,
> encrypt them and store them with the encrypted filename.
>
> As it is written in python, you will need a python interpreter. You
> might already have one installed with some Apache-Mysql-php kits. Check
> your Apache folder, and your c:\ folder. Search your computer for the
> file python.exe
>
> If not found, download and install a brand new one from:
> http://www.python.org/download/
>
> You might use this opportunity to get a newer one if yours is too old,
> because we will have to add some "plugin" which can't use python
> versions prior to 2.1
>
> The command line I used is (can be used as .bat):
>
> c:\python24\python.exe C:\pytest\captcha.py --wordlist C:\pytest\w.txt
> --output C:\pytest\ --key turtle --count 10 --fill 2 --font Arial
>
> Where:
> c:\python24\python.exe is the newer interpreter I installed (there is an
> older one attached to my apache, and if I just call python.exe on
> command line, the old one comes up. To check which one you are using,
> type: python -v )
>
> C:\pytest\captcha.py is the path to the captcha.py file I downloaded
> from the ConfirmEdit extension. As you can notice, to avoid problems
> with space in windows paths like "my document", I created a filed called
> "pytest" (less than 8 letters) directly at the root of my system.
>
> --wordlist C:\pytest\w.txt is the path to a text file I created with a
> list of words. Each word on a line, which means: I type a word, and I
> hit Enter. On my first attempt, I created only five of them. This might
> be too short. Use a longer list: 10 to 20
>
> --output C:\pytest\ path to the directory I want the images to be
> stored. Not sure if the ending \ is necessary. It worked with it.
>
> --key turtle  this is the key used to encrypt the words. It has to be
> the same as the $wgCaptchaSecret variable in the fancycaptcha.php file,
> otherwise it won't be able to decrypt it. Just use a secret word: be
> creative.
>
> --count 10 really, I haven't got a clue what it is, and how it must be
> set up. I tried 3, it didn't work. Hopefully, someone will tell us if
> there is a minimum and a max for this
>
> --fill 2 same as before, no idea what it is for and what the inferior
> and superior limits are
>
> --font Arial At first I didn't use this parameter. I tried this, and
> maybe it helped this working...
>
>
>
> 5) NO MODULE NAMED IMAGE error
>
> At first, you might get this error:
>
> Traceback (most recent call last):
>   File "C:\pytest\captcha.py", line 26, in ?
>     import Image
> ImportError: No module named Image
>
> DIAGNOSIS: you don't have the image module, which can be found in a
> library for python.
>
> SOLUTION
> Download and install PIL from the middle of this page:
> http://www.pythonware.com/products/pil/
>
> Beware, you have to choose the PIL corresponding to your version of python
>
>
> 6) EMPTY RANGE error
>
> After you have installed the PIL, something can again be wrong:
>
> Traceback (most recent call last):
>   File "C:\pytest\captcha.py", line 145, in ?
>     word1 = words[random.randint(0,len(words)-1)]
>   File "c:\python24\lib\random.py", line 216, in randint
>     return self.randrange(a, b+1)
>   File "c:\python24\lib\random.py", line 192, in randrange
>     raise ValueError, "empty range for randrange() (%d,%d, %d)" % (istart,
> , width)
> ValueError: empty range for randrange() (0,0, 0)
>
>
> As long as I tried, I believe this is due to an error in the --fill or
> --count parameters of the command line.
>
> And in the end: IT WORKED FOR ME
>
> image_e920d182_6ea824a00198ed4f.png
> image_b18fd5f0_bb1e8e848697c902.png
> image_0206469a_889d0b2dab698f4d.png
> image_d360bf03_ab8400fd4dfc4b9d.png
> image_7ae15d3e_aca3a3ea9d4c36a4.png
> image_ccc4294b_e9db09ebf2dd58d7.png
> image_b00e56fb_bd1657b6488424dc.png
>
> 7) CREDITS
>
> Thank you very much to Brion Vibber for developing extensions for
> "advanced dummies" like me, only able of rewarding him by grinning about
> having to understand python and finding out by themselves what on earth
> the parameters for command line might be. Ingratitude has no depth :-)
>
> Hope this will help. please do tell me what is missing. Hopefully, there
> will soon be a page created in mediawiki for this extension (no search
> on meta.mediawiki came up with something like fancycaptha). As soon as
> the creator puts it on, I might add this participation to it. Be free to
> add what I omitted, and correct where I was wrong or unclear.
>
> François
>
> _______________________________________________
> MediaWiki-l mailing list
> [hidden email]
> http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
>
>


_______________________________________________
MediaWiki-l mailing list
[hidden email]
http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
Reply | Threaded
Open this post in threaded view
|

Re: about captcha.py image generator

Terry Auspitz
I would hope that if a captcha system were added to MediaWiki, it would
be strictly optional?

I have concerns about accessibility, and a captcha use would actually be
illegal in some installations.

~Terry

Rik Wade wrote:

>A captcha system is a much needed extension for MediaWiki, so thanks to
>those working on it. My experience so far with automated or "undesirable"
>edits is that they could be stopped by turning off anonymous edits and
>using a captcha system for user registration.
>
>Is it anticipated to use the MediaWiki captcha extension for all edits, or
>will the option be available to use them only for user registration? I
>understand that security comes at a price in terms of usability, but
>entering a captcha string for every edit may be too cumbersome for
>prolific editors.
>
>How about having a 'level of trust', where certain users can be flagged to
>bypass the captcha system for their edits? Therefore, new editors will
>need to input a captcha string for each edit, but those who have been
>flagged by the admins will not need to do so? I suppose this would work
>for small Wikis, but not for anything as busy as Wikipedia.
>  
>
_______________________________________________
MediaWiki-l mailing list
[hidden email]
http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
Reply | Threaded
Open this post in threaded view
|

Re: about captcha.py image generator

Rob Church
I would imagine that if it were added to the core code, it would be
configurable.


Rob Church

On 08/02/06, Terry Auspitz <[hidden email]> wrote:

> I would hope that if a captcha system were added to MediaWiki, it would
> be strictly optional?
>
> I have concerns about accessibility, and a captcha use would actually be
> illegal in some installations.
>
> ~Terry
>
> Rik Wade wrote:
>
> >A captcha system is a much needed extension for MediaWiki, so thanks to
> >those working on it. My experience so far with automated or "undesirable"
> >edits is that they could be stopped by turning off anonymous edits and
> >using a captcha system for user registration.
> >
> >Is it anticipated to use the MediaWiki captcha extension for all edits, or
> >will the option be available to use them only for user registration? I
> >understand that security comes at a price in terms of usability, but
> >entering a captcha string for every edit may be too cumbersome for
> >prolific editors.
> >
> >How about having a 'level of trust', where certain users can be flagged to
> >bypass the captcha system for their edits? Therefore, new editors will
> >need to input a captcha string for each edit, but those who have been
> >flagged by the admins will not need to do so? I suppose this would work
> >for small Wikis, but not for anything as busy as Wikipedia.
> >
> >
> _______________________________________________
> MediaWiki-l mailing list
> [hidden email]
> http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
>
_______________________________________________
MediaWiki-l mailing list
[hidden email]
http://mail.wikipedia.org/mailman/listinfo/mediawiki-l