Captcha PHP: sample script

Captcha PHP is a program used to verify that a person, not a computer, enters data. CAPTCHAs are usually displayed at the end of online forms and ask the user to enter text with a distorted image. The text in the image can be masked by a distorted font, wave and zigzag lines, and the automatic recognition program cannot detect it. Some Captcha PHP include an audio pronunciation feature. Captcha tests can stop 90% of hacker attacks by blocking the robot software and restricting the sending of online requests.

captcha php

Definition

Captcha PHP is a call response system designed to differentiate people and robotic programs. CAPTCHA is used as security checks to prevent spammers and hackers from using forms on web pages to insert malicious code.

Specification

CAPTCHA is a type of security measure known as request-response authentication. This solution helps protect the user from decrypting spam and password by asking them to perform a simple test that proves that this is a person, not a computer trying to break into a password-protected account.

The captcha test consists of two simple parts: a random sequence of letters or numbers that appear as a distorted image, and a text field. To pass the test and prove your human identity, simply enter the characters that you see in the image into the text box.

History

The need for Captcha PHP was born back in 1997. At that time, the AltaVista search engine was looking for a way to block the automatic placement of URLs on a platform that distorted search engine ranking algorithms. To solve this problem, Andrey Broder, AltaVista's chief scientist, developed an algorithm that randomly generated an image of printed text. Although computers could not recognize the image, people could read a message containing the image and responding accordingly. Broder and his team received a patent for this technology in April 2001.

plugins captcha recaptcha recaptcha php

In 2003, Nicholas Hopper, Manuel Bloom, Louis von Ahn of Carnegie Mellon University and IBM John Langford of IBM developed the algorithm and coined the term Captcha. The name means a completely automated Turing test for public use to differentiate people from machines.

Php

PHP is a scripting language and interpreter that is freely available and is mainly used on Linux web servers. PHP runs on the server, and a comparable JavaScript alternative runs on the client. This programming language is an alternative to Microsoft Active Server Page (ASP) technology. Like ASP, the Captcha PHP script is embedded in the web page along with the HTML code. Before sending the page to the user, the web server calls PHP to interpret and execute the operations called in the script.

An HTML page containing a PHP script is usually assigned the suffix of the .php file name - β€œ.php7” or β€œ.phtml”. PHP can be thought of as β€œdynamic HTML pages,” because the content will depend on the outcome of the script interpretation.

The language is free and is used under an open source license.

Most of the syntax is borrowed from other languages, but PHP has a number of unique and special functions, for example, <plugins Captcha reCaptcha reCaptcha PHP>. PHP is great for building database driven websites.

google captcha php

How Captcha works in PHP

Captcha is a kind of Turing test. The bottom line is that end users are invited to perform some tasks that the software bot will not be able to perform. Tests are often associated with JPEG or GIF images, because although bots can identify the presence of an image by reading the source code, they cannot recognize the contents of the image. Because some images are difficult to interpret, users are usually given the opportunity to request a new test.

Classification

The most common type is text, which requires the user to view a distorted string of alphanumeric characters in an image and enter characters in an attached form. Captcha text can also be streamed to MP3 audio recordings to meet the needs of the visually impaired. As with images, bots can detect the presence of an audio file, but only humans can hear and recognize the information contained in the file.

Captcha image recognition in PHP, which is also widely used, asks users to identify a subset of images in a large set of images. For example, a user may be presented with a set of icons, and is invited to click on all those that have cars.

Other types of Captcha include:

  • Math Captcha - requires the user to solve a basic mathematical problem, such as adding or subtracting two numbers.
  • 3D Super Captcha - here the user must identify the image displayed in 3D.
  • I'm Not a Robot - in this type of captcha, the user must check the box.
  • Marketing - requires the user to enter a specific word or phrase related to the brand of the sponsor.

CAPTCHA bypass: overview of the latest extensions

Users can use extensions from browser add-ons that allow users to bypass captcha input. Popular browser add-ons include AntiCapture, Captcha Be Gone, and Rumola.

php image captcha

The automatic AntiCaptcha plugin for Chrome and Firefox automatically finds the captins captcha recaptcha recaptcha php plugins on the web page and processes it for the user. The application is not free: at the time of this writing, the cost of the service starts at $ 0.70 per 1000 Captcha images. The Captcha Be Gone extension detects captcha on web pages, processes it and copies the result to the user's clipboard. The utility is currently available for Firefox, Chrome, and Internet Explorer for a subscription of $ 3.50 per month.

The Rumola app for Firefox, Chrome, and Safari automatically searches for Captcha on the web pages the user visits. Currently, the cost is $ 0.95 for 50 captcha images or $ 1.95 for 150 solutions. This developer also has a JavaScript bookmarklet that can be used for devices that connect to the Internet.

Since captcha bypass add-ons are created by third parties, end-users should be aware that the browser extension may show browsing activity to untrusted sources and compromise user data. Another reason not to use CAPTCHA bypass is that the performance of the extensions and the level of CAPTCHA creation are incompatible. This is primarily due to the fact that, as bots become more intelligent, methods for creating captcha also develop, and installed plugins can stop coping with their task.

plugins captcha recaptcha recaptcha php how to open

How to open Captcha PHP: example

The code below shows how to create simple Captcha graphics with random strings and numbers and how to include it in an HTML form to prevent the automatic submission of malicious scripts. It will also help answer the question: how to open plugins captcha recaptcha recaptcha php?

The following code needs to be saved as a separate PHP file (we call it Captcha / php). This file creates a PNG image containing a series of five digits. It also stores these numbers in a session variable so that other scripts can know what the correct code is and verify that the input is correct.

Captcha PHP script example

<? PHP

// google captcha php php image captcha

// Adapted for The Art of Web: www.the-art-of-web.com

// Please acknowledge use of this code by including this header.

?>

The result of this script looks like a picture with a random selection of numerical values ​​that the user must enter in the input field.

The image obtained as a result of processing the script (Captcha PHP ajax) should be difficult for the "robots", but as simple as possible for people. If you wish, you can complicate the graphics by adding colors or textures, or using different fonts and the rotation effect.

captcha php example

Alternative schemes

Due to the fact that varieties of captcha based on text distortion are vulnerable to attacks, some researchers have proposed alternative solutions, including image recognition, which require users to identify simple objects in pictures. The argument in favor of these schemes is that the task of recognizing objects is more difficult to perform than text recognition, therefore, the resistance to attacks in this category of captcha is higher. Here are some of the noteworthy alternative schemes:

  • Chew published its work at the 7th International Conference on Information Security ISC'04, proposing three different versions of CAPTCHA pattern recognition, and confirmed this hypothesis using user research.
  • Datta published its work at the ACM Multimedia '05 conference, entitled IMAGINATION, offering a systematic way to capture Captcha images. Pictures are distorted in such a way that modern approaches to image recognition (which are potential attack technologies) do not recognize them.
  • Microsoft IT giant engineers (Jeremy Elson, John R. Duser, John Howell, and Jared Saul) have developed animal access image recognition (ASIRRA) that asks users to distinguish between cats and dogs. Microsoft had a beta version of this solution for use by websites. Tests showed that people successfully recognized images in 99.6% of cases in 30 seconds. This decision was described in a 2007 paper for the 14th ACM Conference on Computer and Communications Security (CCS).

What is the difference between Captcha and reCaptcha?

Captcha is an identity verification test (usually blurred letters that need to be decrypted) used by many sites to prevent spam.

ReCaptcha is the reverse of Captcha. The same test, which is used not only to prevent spam, but also to help with a digital publishing project. In other words, Recaptcha tests are not a meaningless combination of words, but excerpts from books, while Captcha uses several methods of verification of identity, including mathematical or general questions, visual and chess puzzles.

ReCaptcha is currently the most popular implementation.

captcha php script

Application

Although captcha is not an absolute means of authentication, its use can be very effective in the following cases:

  • Enumerations (registration or password reset forms are often vulnerable to malicious attacks - without Captcha, a hacker can get valid usernames, phone numbers or any other confidential information in a short time).
  • Automatically send many GET / POST requests in a short time when it is not desirable (for example, receiving SMS / MMS / email). In this case, Captcha provides a speed limit function.
  • Automatically create an account that should only be used by people (for example, creating email accounts, stopping spam).
  • Automatically post to blogs, forums, and wikis.
  • Any automatic attacks that massively receive or misuse confidential information from the application.

Using Captcha as protection against cross-site request forgery is not recommended, as there are stronger countermeasures.

Source: https://habr.com/ru/post/K21175/


All Articles