Add security/p5-Authen-Captcha, a Perl module to verify the human

element in transactions.
This commit is contained in:
Anton Berezin 2004-05-10 12:56:22 +00:00
parent 46e973b143
commit 78b16c78f3
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=108836
6 changed files with 169 additions and 0 deletions

View File

@ -213,6 +213,7 @@
SUBDIR += openvpn
SUBDIR += osiris
SUBDIR += outguess
SUBDIR += p5-Authen-Captcha
SUBDIR += p5-Authen-Krb5
SUBDIR += p5-Authen-PAM
SUBDIR += p5-Authen-Radius

View File

@ -0,0 +1,36 @@
# New ports collection makefile for: Authen-Captcha
# Date created: Mon May 10 13:27:28 CEST 2004
# Whom: tobez@FreeBSD.org
#
# $FreeBSD$
#
PORTNAME= Authen-Captcha
PORTVERSION= 1.023
CATEGORIES= security perl5
MASTER_SITES= ${MASTER_SITE_PERL_CPAN}
MASTER_SITE_SUBDIR= Authen
PKGNAMEPREFIX= p5-
MAINTAINER= perl@FreeBSD.org
COMMENT= Perl module to verify the human element in transactions
BUILD_DEPENDS= ${SITE_PERL}/${PERL_ARCH}/GD.pm:${PORTSDIR}/graphics/p5-GD
RUN_DEPENDS= ${BUILD_DEPENDS}
PERL_CONFIGURE= yes
MAN3= Authen::Captcha.3
.include <bsd.port.pre.mk>
.if ${PERL_LEVEL} < 500800
BUILD_DEPENDS+= ${SITE_PERL}/${PERL_ARCH}/Digest/MD5.pm:${PORTSDIR}/security/p5-Digest-MD5
RUN_DEPENDS+= ${SITE_PERL}/${PERL_ARCH}/Digest/MD5.pm:${PORTSDIR}/security/p5-Digest-MD5
.endif
.if ${PERL_LEVEL} <= 500600
BUILD_DEPENDS+= ${SITE_PERL}/File/Spec.pm:${PORTSDIR}/devel/p5-File-Spec
RUN_DEPENDS+= ${SITE_PERL}/File/Spec.pm:${PORTSDIR}/devel/p5-File-Spec
.endif
.include <bsd.port.post.mk>

View File

@ -0,0 +1,2 @@
MD5 (Authen-Captcha-1.023.tar.gz) = 7c20090844dd2406e4ef6a894c66348b
SIZE (Authen-Captcha-1.023.tar.gz) = 98986

View File

@ -0,0 +1,70 @@
--- Captcha.pm.orig Mon May 10 10:58:05 2004
+++ Captcha.pm Mon May 10 11:06:24 2004
@@ -65,6 +65,7 @@ sub new
my $keep_failures = (defined($opts{keep_failures}) && $opts{keep_failures})
? 1 : 0;
$self->keep_failures($keep_failures);
+ $self->secret($opts{secret} || "");
# create a random seed if perl version less than 5.004
if ($] < 5.005)
@@ -193,6 +194,18 @@ sub data_folder
}
}
+sub secret
+{
+ ref(my $self = shift) or croak "instance variable needed";
+ if (@_)
+ { # it's a setter
+ $self->{_secret} = $_[0];
+ return $self->{_secret};
+ } else {
+ return $self->{_secret};
+ }
+}
+
sub check_code
{
@@ -214,7 +227,7 @@ sub check_code
# they could be confused with (o) and (l), so we swap them in
$code =~ tr/01/ol/;
- my $md5 = md5_hex($code);
+ my $md5 = md5_hex($code . $self->secret);
# pull in current database
warn "Open File: $database_file\n" if($self->debug() >= 2);
@@ -490,7 +503,7 @@ sub generate_code
my $length = shift;
my $code = $self->generate_random_string($length);
- my $md5 = md5_hex($code);
+ my $md5 = md5_hex($code . $self->secret);
my ($captcha_data_ref,$output_filename);
if ($self->type() eq 'image')
@@ -625,6 +638,7 @@ See the method descriptions for more det
height => 35, # optional. default 35
images_folder => '/some/folder', # optional. default to lib dir
keep_failures => 0, # optional, defaults to 0(false)
+ secret => "", # optional, defaults to ""
debug => 0, # optional. default 0
=back
@@ -694,6 +708,14 @@ Optional. Number of pixels wide for the
=item C<$captcha-E<gt>keep_failures( [0|1] );>
Optional. Defaults to zero. This option controls whether or not the captcha will remain valid after a failed attempt. By default, we only allow one attempt to solve it. This greatly reduces the possibility that a bot could brute force a correct answer. Change it at your own risk.
+
+=item C<$captcha-E<gt>secret( "SuperSecret" );>
+
+Optional. Defaults to an empty string. This option is meant to prevent
+brute-force captcha circumvention by calculating md5 sum of multiple
+valid codes and comparing them with the image file name. Obviously, the
+secret should be the same for creating and checking the captcha. It is a
+good idea to set it to something else than the default.
=item C<$captcha-E<gt>debug( [0|1|2] );>

View File

@ -0,0 +1,13 @@
Authen::Captcha provides an object oriented interface to captcha file
creations. Captcha stands for Compl etely Automated Public Turning test
to tell Computers and Humans Apart. A Captcha is a program that can
generate and grade tests that:
- most humans can pass
- current computer programs can't pass
The most common form is an image file containing distorted text, which
humans are adept at reading, and co mputers (generally) do a poor job.
This module currently implements that method.
WWW: http://search.cpan.org/search?module=Authen::Captcha

View File

@ -0,0 +1,47 @@
%%SITE_PERL%%/%%PERL_ARCH%%/auto/Authen/Captcha/.packlist
%%SITE_PERL%%/Authen/Captcha.pm
%%SITE_PERL%%/Authen/Captcha/images/8.png
%%SITE_PERL%%/Authen/Captcha/images/s.png
%%SITE_PERL%%/Authen/Captcha/images/a.png
%%SITE_PERL%%/Authen/Captcha/images/l.png
%%SITE_PERL%%/Authen/Captcha/images/z.png
%%SITE_PERL%%/Authen/Captcha/images/5.png
%%SITE_PERL%%/Authen/Captcha/images/b.png
%%SITE_PERL%%/Authen/Captcha/images/9.png
%%SITE_PERL%%/Authen/Captcha/images/4.png
%%SITE_PERL%%/Authen/Captcha/images/6.png
%%SITE_PERL%%/Authen/Captcha/images/background2.png
%%SITE_PERL%%/Authen/Captcha/images/c.png
%%SITE_PERL%%/Authen/Captcha/images/g.png
%%SITE_PERL%%/Authen/Captcha/images/v.png
%%SITE_PERL%%/Authen/Captcha/images/y.png
%%SITE_PERL%%/Authen/Captcha/images/u.png
%%SITE_PERL%%/Authen/Captcha/images/q.png
%%SITE_PERL%%/Authen/Captcha/images/p.png
%%SITE_PERL%%/Authen/Captcha/images/3.png
%%SITE_PERL%%/Authen/Captcha/images/background4.png
%%SITE_PERL%%/Authen/Captcha/images/d.png
%%SITE_PERL%%/Authen/Captcha/images/h.png
%%SITE_PERL%%/Authen/Captcha/images/background3.png
%%SITE_PERL%%/Authen/Captcha/images/n.png
%%SITE_PERL%%/Authen/Captcha/images/o.png
%%SITE_PERL%%/Authen/Captcha/images/f.png
%%SITE_PERL%%/Authen/Captcha/images/Thumbs.db
%%SITE_PERL%%/Authen/Captcha/images/2.png
%%SITE_PERL%%/Authen/Captcha/images/j.png
%%SITE_PERL%%/Authen/Captcha/images/x.png
%%SITE_PERL%%/Authen/Captcha/images/background5.png
%%SITE_PERL%%/Authen/Captcha/images/k.png
%%SITE_PERL%%/Authen/Captcha/images/7.png
%%SITE_PERL%%/Authen/Captcha/images/e.png
%%SITE_PERL%%/Authen/Captcha/images/i.png
%%SITE_PERL%%/Authen/Captcha/images/w.png
%%SITE_PERL%%/Authen/Captcha/images/m.png
%%SITE_PERL%%/Authen/Captcha/images/r.png
%%SITE_PERL%%/Authen/Captcha/images/t.png
%%SITE_PERL%%/Authen/Captcha/images/background1.png
@dirrm %%SITE_PERL%%/%%PERL_ARCH%%/auto/Authen/Captcha
@dirrm %%SITE_PERL%%/Authen/Captcha/images
@dirrm %%SITE_PERL%%/Authen/Captcha
@unexec rmdir %D/%%SITE_PERL%%/%%PERL_ARCH%%/auto/Authen 2>/dev/null || true
@unexec rmdir %D/%%SITE_PERL%%/Authen 2>/dev/null || true