Products Forum Forum Index Products Forum
Use this forum for questions and discussion about our products
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Updated code to use MD5!

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Products Forum Forum Index -> Support questions & how to use/enhance Vorras Antibot
View previous topic :: View next topic  
Author Message
navigator
Guest





PostPosted: Thu Oct 27, 2005 11:11 am    Post subject: Updated code to use MD5! Reply with quote

My host had removed SHA, which was deprecated (replaced) due to security concerns. This caused Antibot to stop working, but I have finally figured out how to get it to use MD5. The changes are below. My code is based on perlreply.cgi.

In png.py, make these changes near the top of the file...

old:
import sys
import os, sha
import struct

new:
import sys
import os, md5
import struct

And near the end of the file...

old:
s = sha.new(seqstr)
image=encodePNG(ImagePath+'/test'+s.hexdigest()+'.png',NumberOfChars*WidthOfChars+comb.extrawidth,HeightOfChars+12)
image.IDAT = comb.filedata
image.create()
image.close()
h = createHtml(s.hexdigest())

new:
s = md5.new(seqstr)
image=encodePNG(ImagePath+'/test'+s.hexdigest()+'.png',NumberOfChars*WidthOfChars+comb.extrawidth,HeightOfChars+12)
image.IDAT = comb.filedata
image.create()
image.close()
h = createHtml(s.hexdigest())

For perlreply.cgi, I included the code as a subroutine in another file. I have posted the sub here; it may help others incorporate Antibot into their code.

old (partial):
$seq = $q->param("sequence");
$realseq = $q->param("realsequence");
$context = new SHA;
$context->reset();
$seq = $context->hexhash($seq);

new:
sub addit {
#------------------------------------------
# This makes sure the security code they entered is correct.

use Digest::MD5;

if ($in{'sequence'}) {
$seq = ($in{'sequence'});
$realseq = ($in{'realsequence'});
$context = Digest::MD5->new;
$context->add($seq);

$seq = $context->hexdigest;
if ($realseq eq $seq) {
&process_form;
}
else {
&site_html_add_failure("You entered the wrong security code.") and return;
}
}
else {
&site_html_add_failure("You did not enter the security code.") and return;
}
} #end sub addit

Hope this helps others use Antibot, which is a great way to stop spammers!
Back to top
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Products Forum Forum Index -> Support questions & how to use/enhance Vorras Antibot All times are GMT + 6.5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group

Copyright © 2005 Vorras Corporation. All rights reserved.