前言
这篇文章用代码审计的方式给大家讲解一些sql的绕过技巧。
关键字过滤
部分waf会对关键字进行过滤,我们可以用大小写或者双写关键字来绕过。
源代码分析
<?php
require 'db.php';
header('Content-type:text/html;charset=utf8');
$username=dl($_POST['username']);
$password=dl($_POST['password']);
$dl="SELECT * FROM xs WHERE username='$username' and password='$password'"; //登录界面后台处理
$ck=mysqli_query($db,$dl);
$row = mysqli_fetch_array($ck);
if($_POST['login']){
if($row) {
echo"你的密码".$row['username'];
}else{
echo"登录失败";
}
}
function dl($gl){
$gl=str_replace(array("union","UNION"),"","$gl");
$gl=str_replace(array("select","SELECT"),"","$gl");
$gl=str_replace(array("database","DATABASE"),"","$gl");
$gl=str_replace(array("sleep","SLEEP"),"","$gl");
$gl=str_replace(array("if","IF"),"","$gl");
$gl=str_replace("--","","$gl");
$gl=str_replace("order","","$gl");
return $gl;
}
分析一下代码,首先获取了数据,加载dl函数以后带入了数据库中执行,然后if判定是否有提交,是否登录成功,登录成功后回显用