免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 4077 | 回复: 4
打印 上一主题 下一主题

请问做提交表单的验证码是什么思路? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-03-11 09:10 |只看该作者 |倒序浏览
如题。就是随表单生成一个验证码,输出在图片里,然后提交表单时验证。我不太有思路不知道怎么做,望指教。
我想我的意思清楚了吧?

论坛徽章:
0
2 [报告]
发表于 2008-03-11 09:32 |只看该作者
生成表单页面的程序生成验证码的同时,把验证码存在session里面.
用户提交表单后,把用户提交的验证码与session里面的内容比较.相同就成功,不同就返回错误提示.
生成验证码图片的程序网上应该可以找得到,实在找不到可以下载雷傲bbs的代码.
看看它里面注册那块生成验证码的图片是怎么写的.

论坛徽章:
0
3 [报告]
发表于 2008-03-11 16:48 |只看该作者
多谢!不过我还期望能绕过session呢……生成图片倒不是问题。
LeoBBS没有做验证码啊?

论坛徽章:
0
4 [报告]
发表于 2008-03-11 21:38 |只看该作者
破解图片验证, 主要是图像识别/对比, CPAN有模块

论坛徽章:
0
5 [报告]
发表于 2008-03-14 14:07 |只看该作者
纯PERL 实现四位数字图片的生成
   摘自 中国Perl协会 用户推广组   dhs789520  2006-10-24 17:15
http://bbs.perlchina.org/ccb/index.cgi
#==============================================================
# bmpnum usage: $img=bmpNum(1234); #用于生成四位验证码程序,做网页的一定知道这个东东了返回一个图片
#==============================================================
sub bmpNum{
my $verifynum=shift;
#BMP图片生成
local @n0 = ("3c","66","66","66","66","66","66","66","66","3c");
local @n1 = ("1c","0c","0c","0c","0c","0c","0c","0c","1c","0c");
local @n2 = ("7e","60","60","30","18","0c","06","06","66","3c");
local @n3 = ("3c","66","06","06","06","1c","06","06","66","3c");
local @n4 = ("1e","0c","7e","4c","2c","2c","1c","1c","0c","0c");
local @n5 = ("3c","66","06","06","06","7c","60","60","60","7e");
local @n6 = ("3c","66","66","66","66","7c","60","60","30","1c");
local @n7 = ("30","30","18","18","0c","0c","06","06","66","7e");
local @n8 = ("3c","66","66","66","66","3c","66","66","66","3c");
local @n9 = ("38","0c","06","06","3e","66","66","66","66","3c");

for (my $i = 0; $i < 10; $i++)
{
for (1 .. 6)
{
my $a1 = substr("012", int(myrand(3)), 1) . substr("012345", int(myrand(6)), 1);
my $a2 = substr("012345",int(myrand(6)),1) . substr("0123", int(myrand(4)), 1);
int(myrand(2)) eq 1 ? push(@{"n$i"}, $a1) : unshift(@{"n$i"},$a1);
int(myrand(2)) eq 0 ? push(@{"n$i"}, $a1) : unshift(@{"n$i"},$a2);
}
}

my @bitmap = ();

for (my $i = 0; $i < 20; $i++)
{
for (my $j = 0; $j < 4; $j++)
{
my $n = substr($verifynum, $j, 1);
my $bytes = ${"n$n"}[$i];
my $a = int(myrand(15));
$a eq 1 ? $bytes =~ s/9/8/g : $a eq 3 ? $bytes =~ s/c/e/g : $a eq 6 ? $bytes =~ s/3/b/g : $a eq 8 ? $bytes =~ s/8/9/g : $a eq 0 ? $bytes =~ s/e/f/g : 1;
push(@bitmap, $bytes);
}
}
for ($i = 0; $i < 8; $i++)
{
my $a = substr("012", int(myrand(3)), 1) . substr("012345", int(myrand(6)), 1);
unshift(@bitmap, $a);
push(@bitmap, $a);
}

my $image = '424d9e000000000000003e0000002800';
$image .= "00002000000018000000010001000000";
$image .= "00006000000000000000000000000000";
$image .= "00000000000000000000FFFFFF00";
$image .= join('', @bitmap);
$image = pack ('H*', $image);

return $image;
}
#===============================================================
###########################
##made by MR.WATER QQ:175 785 113 #
## 抄于雷傲论坛代码 #
###########################



来源:http://bbs.perlchina.org/ccb/top ... 4171524&page=40
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP