Math CAPTCHA Script !!

Started on the old forum in January 2011 · view the original in the archive · old links redirect here

8 replies · 2,163 views · started 15 years ago · 1 min read

7 participants
tkreturns Developer · 98 posts #1
index.php:
<form method="POST" action="cc.php"> 
<img src="captcha.php"> <br>
<input type="text" size="10" name="check"> <br> 
<input type="submit" name="submit" value="submit"> 
</form>

captcha.php:
<?php session_start(); 
$img = imagecreatefrompng('black.png'); 
//value 1
$numeroa = rand(1, 9);
//value2
$numerob = rand(1, 9);
$numero = $numeroa + $numerob;
$display = $numeroa . '+' . $numerob;
$_SESSION['check'] = $numero; 
//The function imagecolorallocate creates a 
//color using RGB (red,green,blue) format.
$white = imagecolorallocate($img, 255, 255, 255); 
imagestring($img, 10, 8, 3, $display, $white);
 header ("Content-type: image/png"); imagepng($img); 
?>
cc.php
<?php  
session_start();   
//Sessions in PHP are started by using the   
//session_start() function.    
//Like the setcookie( ) function,   
//the session_start function must come before any HTML,   
//including blank lines, on the page.session_start();   
//Check if the security code and   
//the session value are not blank   
//and if the input text matches the stored text  
if(isset($_SESSION['check']) && (md5($_POST['check']) == md5($_SESSION['check']))) {   
echo 'Input OK';  
}else{   
echo 'Input Wrong';          
}

ASK FOR HELP

Attachments: black.png
bigboss Developer · 110 posts #2

Where is is case break? If wrote wrong code then how can we will se code error?

firemax Developer · 221 posts #3

this cpatha code is useless if spammer did not use the your site forum to submit data.

Update: cc.php:

 
<?php 
session_start();  
//Sessions in PHP are started by using the  
//session_start() function.   
//Like the setcookie( ) function,  
//the session_start function must come before any HTML,  
//including blank lines, on the page.session_start();  
//Check if the security code and  
//the session value are not blank  
//and if the input text matches the stored text 
if(isset($_SESSION['check']) && (md5($_POST['check']) == md5($_SESSION['check']))) {  
echo 'Input OK'; 
}else{  
echo 'Input Wrong';         
}

External image (may be gone) Free Mobile Web Scripts by me: Free Youtube Downloader, Tweets Reader, Facebook Wall Posts Reader PHP Tutorials: [How to Secure Your PHP Script (PHP SECURITY)](http://coding-talk.com/f14/how-to-secure-you…

tkreturns Developer · 98 posts #4

thnx bro 🙂

ASK FOR HELP

haraldl Junior · 33 posts #6

Spammers use triggers to define an url... examples :

(index\.php\?PHPSESSID=[a-z0-9]{1,250}&action=verificationcode;rand=[a-z0-9]{1,250}) 
(index\.php\?PHPSESSID=[a-z0-9]{1,250}&action=verificationcode;vid=register;rand=[a-z0-9]{1,250}) 

a database handling urls sends captcher images to a captcher solving server, but the top soft cracks even recapctha, so spammers dont need a solving server. To avoid? it depends on script how you block. If you want to avoid spam try htaccess.

RewriteEngine On
RewriteCond %{REQUEST_METHOD} POST
RewriteCond %{REQUEST_URI} .register.php*
RewriteCond %{HTTP_REFERER} !.coding-talk.com [OR]
RewriteCond %{HTTP_USER_AGENT} ^$
RewriteRule (.*) http://google.com/ [R=301,L]

spammers use a direct url.A real user would come from coding-talk.com and not directly without a referer.

frostymarvelous Senior · 266 posts #8

Using that htaccess, you will only hurt your users. Some users don't send referers due to proxies or browser setup. A spammer can easily send a referer. Eg curl setopt referer can be simply used. You need to research before using certain techniques.

Perfection comes at a cost

I accept liberty!

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close