less17-

less17的注入过滤

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
function check_input($value)
{
if(!empty($value))
{
// truncation (see comments)
$value = substr($value,0,15);
}

// Stripslashes if magic quotes enabled
if (get_magic_quotes_gpc())
{
$value = stripslashes($value);
}

// Quote if not a number
if (!ctype_digit($value))
{
$value = "'" . mysql_real_escape_string($value) . "'";
}

else
{
$value = intval($value);
}
return $value;
}

substr($value,0,15);首先截取前16个字符

magic_quotes_gpc()函数在php中作用是判断用户提供数据,如包括有:post,get,cookie过来的数据增加转义字符“\”,以确保这些数据不会引起程序的错误

ctype_digit()判断是不是纯的数字

mysql_real_escape_string()调用mysql库的函数 mysql_real_escape_string,在以下字符前添加反斜杠:\x00,\n,\r,,‘,”,和\x1a,默认字符集。

QQ浏览器截图20211110212406.png

只截取前16个字符,的同时注释(\)单引号

但是它对密码部分没做注入过滤,所以只要有正确的账号就可以尝试在passwd=后面进行注入

UPDATEXML (XML_document, XPath_string, new_value)函数

XML_document是string格式,为XMl文档对象的名称

XPath_string(Xpath格式的字符串)

new_value为string格式,替换查找符合条件的数据

该函数用于改变文档中符合条件的节点的值,意为改变XML_document中符合XPATH_string的值

利用concat()函数只是将其拼接成字符串格式,来利用UPDATEXML (XML_document, XPath_string, new_value)函数报错出XPath_string的值

select updatexml(1,concat(0x7e,(database())),1);

select updatexml(1,concat(0x7e,(select schema_name from information_schema.schemata limit 0,1)),1);

select updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table.schema=’security’ limit 0,1)),1);

补充(2022 01 29):常用floor函数的报错注入

floor函数:向下取整

rand函数:随机取数,诺有参数x,则使每一个x对应一个固定的值,如果连续多次执行会变化,但是可以预测。

floor(rand(0)*2)产生的随机数序列为011011.。。。

报错注入原理

利用数据库主键不能重复的原理,使用group by 分组,产生主键重复而导致报错

详见csdn dalao的文章

因为发现好像lesson5,6也可以用报错来注入所以就在这里补充了