### 简要描述:
ThinkPHP 默认配置导致验证码暴力破解
### 详细说明:
最近用Thinkphp时发现,验证码类默认的check函数在检查完验证码是否正确后,并未重置session,导致可被暴力破解。
[<img src="https://images.seebug.org/upload/201504/26153920b700a19a58bb51ff670552b3ee65abd8.png" alt="QQ截图20150426153925.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201504/26153920b700a19a58bb51ff670552b3ee65abd8.png)
写这样的代码,再看看Verify类的check函数,
```
public function check($code, $id = '') {
$key = $this->authcode($this->seKey).$id;
// 验证码不能为空
$secode = session($key);
if(empty($code) || empty($secode)) {
return false;
}
// session 过期
if(NOW_TIME - $secode['verify_time'] > $this->expire) {
session($key, null);
return false;
}
if($this->authcode(strtoupper($code)) == $secode['verify_code']) {
$this->reset && session($key, null);
return true;
}
return false;
}
```
配置里的reset是在验证码正确的情况下才重置session,验证码错了并不会重置session。这样只要用burp intruder就可以暴力破解验证码。
相信很多开发者都忽略了这一点,
从TP官网的案例随便找几个TP开发的列子试试吧
http://oa.0796z.com/index.php/Oa/Login/index
[<img src="https://images.seebug.org/upload/201504/26154916995a3fb26d700375967b04dad88f894b.png" alt="QQ截图20150426154918.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201504/26154916995a3fb26d700375967b04dad88f894b.png)
http://www.jz07.cn/Home/Index/index.html
[<img src="https://images.seebug.org/upload/201504/2615573206d5530f0034cf0efdcd32f63de72542.png" alt="QQ截图20150426155712.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201504/2615573206d5530f0034cf0efdcd32f63de72542.png)
可以看到验证码都成了鸡肋。
### 漏洞证明:
从TP官网的案例随便找几个TP开发的列子试试吧
http://oa.0796z.com/index.php/Oa/Login/index
[<img src="https://images.seebug.org/upload/201504/26154916995a3fb26d700375967b04dad88f894b.png" alt="QQ截图20150426154918.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201504/26154916995a3fb26d700375967b04dad88f894b.png)
http://www.jz07.cn/Home/Index/index.html
[<img src="https://images.seebug.org/upload/201504/2615573206d5530f0034cf0efdcd32f63de72542.png" alt="QQ截图20150426155712.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201504/2615573206d5530f0034cf0efdcd32f63de72542.png)
暂无评论