微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

jquery – Qaptcha – 是否有效?

看到JQuery Qaptcha的演示 – http://www.myjqueryplugins.com/QapTcha/demo

它需要你滑动滑块解锁,并证明你是人类。我已经阅读了所有关于如何设置随机字段值并擦除它们,但是并不是所有这些都通过javascript调用完成?如果是这样,那么机器人不会只需要运行javascript方法,那么qaptcha是坏的?

帮助我了解这是如何安全的

解决方法

不幸的是,这并不是一个安全的验证码。

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

快速猜测它是如何在成功和失败的基础上工作的:

>您在其页面上加载表单,创建PHP会话,大概没有数据。
>加载了一个生成qaptcha_key并附加到表单的JS脚本。
>此键由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

在结果输出。你可以在代码中看到,我只是一遍又一遍地使用相同的键。关键是什么,因为客户端通知服务器的密钥,并且当您提交表单时,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/',$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,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;
}

我希望能够清楚地回答你的问题。

原文地址:https://www.jb51.cc/jquery/182258.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐