一、验证码绕过(on server)

直接抓包可以看到(vcode=edo)存在逻辑判断。
拿到源码分析:
if(isset($_POST['submit'])) {
// 检查用户名是否为空
if (empty($_POST['username'])) {
$html .= "<p class='notice'>用户名不能为空</p>";
} else {
// 检查密码是否为空
if (empty($_POST['password'])) {
$html .= "<p class='notice'>密码不能为空</p>";
} else {
// 检查验证码是否为空
if (empty($_POST['vcode'])) {
$html .= "<p class='notice'>验证码不能为空哦!</p>";
} else {
// 验证验证码是否正确
if (strtolower($_POST['vcode']) != strtolower($_SESSION['vcode'])) {
$html .= "<p class='notice'>验证码输入错误哦!</p>";
// 应该在验证完成后,销毁该$_SESSION['vcode']
} else {
// 用户名、密码和验证码均合法,进行数据库查询
$username = $_POST['username'];
$password = $_POST['password'];
$vcode = $_POST['vcode'];
$sql = "select * from users where username=? and password=md5(?)";
$line_pre = $link->prepare($sql);
$line_pre->bind_param('ss', $username, $password);
// 执行查询
if($line_pre->execute()){
$line_pre->store_result();
// 检查是否有匹配的记录
if($line_pre->num_rows()==1){
$html.='<p> login success</p>';
}else{
$html.= '<p> username or password is not exists~</p>';
}
}else{
$html.= '<p>执行错误:'.$line_pre->errno.'错误信息:'.$line_pre->error.'</p>';
}
}
}
}
}
}
if (strtolower($_POST['vcode']) != strtolower($_SESSION['vcode'])) {
$html .= "<p class='notice'>验证码输入错误哦!</p>";
// 应该在验证完成后,销毁该$_SESSION['vcode']
验证码正确正常传参,由于在验证完成后SESSION['vcode']并未销毁,我们于是就有了很明显的思路,确保验证码的正确值,对账户账号密码进行爆破。
漏洞利用:
用burpsuite抓包,将vcode的验证码固定:
再进行暴力破解:(这里随便写了几个弱口令,主要为了演示)

验证一下:
拿下!
文章详细描述了一个PHP代码中的验证码验证逻辑漏洞,通过直接抓包和源码分析发现,验证码未在验证后及时销毁,导致攻击者可以重复使用。作者展示了如何利用Burpsuite抓包并进行暴力破解的过程。
8446

被折叠的 条评论
为什么被折叠?



