2024RCTF

2024_RCTF

MISC

Logo: Sign in

app.py

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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
from RestrictedPython import compile_restricted, safe_builtins
from RestrictedPython.Eval import default_guarded_getitem
from RestrictedPython.Guards import full_write_guard
from pywebio import *
from pywebio.input import *
from pywebio.output import *
from string import printable
import os
from RCTF import ROIS_LOGO

SIGNIN_FLAG = os.environ.get("SIGNIN_FLAG", "RCTF{fake_flag1}")
BONUS_FLAG = os.environ.get("BONUS_FLAG", "RCTF{fake_flag2}")

def task():
source_code = textarea(
"RCTF2024 - signin",
rows=24,
code={"mode": "python", "theme": "darcula"},
help_text="Help ROIS draw a logo! Extra bonus flag for code that's storage-efficient!",
).strip()

if not all(c in printable for c in source_code):
popup("ERROR", [put_error("Bad code")])
return
loc = {}
try:
exec(
compile_restricted(source_code, "<inline>", "exec"),
{
"__builtins__": safe_builtins,
"_getitem_": default_guarded_getitem,
"_write_": full_write_guard,
},
loc,
)
except Exception as e:
popup("ERROR", [put_error(e)])
return

FLAG1 = SIGNIN_FLAG if "logo" in loc and loc["logo"].strip() == ROIS_LOGO else None
FLAG2 = BONUS_FLAG if FLAG1 and len(source_code) < len(ROIS_LOGO) * .2024 else None
if "logo" in loc:
popup(
"RESULT",
[
put_code(loc["logo"].strip()),
put_table([["FLAG1", FLAG1], ["FLAG2", FLAG2], ["CODE SIZE", len(source_code)]]),

],
size="large",
)

start_server(task, 8088, "0.0.0.0", debug=True)

RCTF.py

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
ROIS_LOGO = """
####################################################################################################
############################ # #####################################################################
#### ## ########### ## ## ########### ######## ######
#### ## ######### ########## ###### ###
#### ######## ######## ########################## ############# ############ ##
#### ########### ###### ########### ############## ############ ###################
### ############# ##### ########### ############# ############ ###################
### ############## #### ############# ############# ############# ###################
### ############## ### ############# ############ ############## #################
### ############## ### ############### ############ ############### ###############
### ############## #### ############### ############ ################# #############
### ############# #### ############### ########### #################### ##########
### ############ ##### ############### ########### ###################### #########
### #### ###### ############## ########### ######################## #######
### #### ######## ############# ########### ########################## ######
### ######### ######### ############# ############ ########################## ######
### ########## ######## ########### ############# ########################## ######
### ########### ######## ######### ############# ############# ######### ######
### ############ ######### ###### ############ ############### #### #######
### ############## ########### ############ ######### #########
#### ############################### ############################################## ############
####################################################################################################
""".strip()

大体思路就是画个logo出来

FLAG 1

直接画个logo即可

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
logo='''
####################################################################################################
############################ # #####################################################################
#### ## ########### ## ## ########### ######## ######
#### ## ######### ########## ###### ###
#### ######## ######## ########################## ############# ############ ##
#### ########### ###### ########### ############## ############ ###################
### ############# ##### ########### ############# ############ ###################
### ############## #### ############# ############# ############# ###################
### ############## ### ############# ############ ############## #################
### ############## ### ############### ############ ############### ###############
### ############## #### ############### ############ ################# #############
### ############# #### ############### ########### #################### ##########
### ############ ##### ############### ########### ###################### #########
### #### ###### ############## ########### ######################## #######
### #### ######## ############# ########### ########################## ######
### ######### ######### ############# ############ ########################## ######
### ########## ######## ########### ############# ########################## ######
### ########### ######## ######### ############# ############# ######### ######
### ############ ######### ###### ############ ############### #### #######
### ############## ########### ############ ######### #########
#### ############################### ############################################## ############
####################################################################################################
'''

s1ayth3sp1re

一个java写的游戏题

题目描述

Score>3000 to obtain a flag

jadx 反编译 全局搜索 3000 查找可能输出flag的逻辑

跟进查看

一个简单的异或 尝试输出数据 发现是flag

另一个异或是flag四个字符

WindowsKeycodes.VK_F16 Keyboard.KEY_NUMPADEQUALS 等跟进查看发现分别为 127 141

1
2
3
4
5
6
int = [164, 158, 95, 107, 4, 215, 108, 115, 5, 8, 25, 57, 41, 236, 231, 17, 85]
int2 = [246, 221, 11, 45, 127, 148, 45, 36, 70, 73, 78, 8, 98, 141, 140, 112, 40]

for i in range(len(int)):
print(chr(int[i] ^ int2[i]), end="")

FindAHacker

内存取证题

vol3 扫了 filescan 发现一系列 吾爱破解系列exe

![](/img/Untitled 3.png)

总之密密麻麻都是

dump下来部分可能的 exe 扔 ida 里没发现有什么东西 (实际上是什么都看不懂

看了其他常规 无果

注意到ida进程 猜测是在 ida 里进行了不可告人的 flag隐藏工作

根据参考文章

https://w00tsec.blogspot.com/2015/02/extracting-raw-pictures-from-memory.htmlhttps://segmentfault.com/a/1190000018813033#item-2-2

dump下来进程内存 利用gimp 查看内存数据 (十分抽象

这里vol3 好像都没 memdump的插件了 用vol dump idaq64.exe PID 为 2172

u1s1 vol2 和3 一对比 属实是有亿点点慢

dump下来转为 data 扔到 gimp里

总之你就调吧 一调一个不吱声

调了一百年的参数

发现ida数据

脑洞大开 拿去异或 发现都是可见字符

而且正好 32位对应32 位

ord处理下数据 最后还没有flag头 抽象

1
2
3
4
5
6
7
int = [0x35, 0x3F, 0x4E, 0x2B, 0x56, 0x6B, 0x74, 0x6A, 0x5D, 0x6D, 0x6F, 0x73, 0x6C, 0x77, 0x38, 0x68, 0x59, 0x6E, 0x20, 0x21, 0x3C, 0x71, 0x4F, 0x9, 0x36, 0x7D, 0x55, 0x72, 0x51, 0x32, 0x27, 0x66]
# print(ord("3"))

int2 = [0x0C, 0x0F, 43, 72, 48, 93, 70, 83, 100, 89, 89, 75, 95, 71, 91, 91, 107, 95, 0x15, 0x16, 93, 0x12, 118, 107, 7, 0x1B, 51, 74, 103, 7, 0x11, 0]

for i in range(len(int)):
print(chr(int[i] ^ int2[i]),end='')

sec-image

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
'''
光栅 可以看 github 项目
https://github.com/AabyssZG/Raster-Terminator?tab=readme-ov-file

以下为 shenghuo2 的脚本
'''
import numpy as np
import os
from PIL import Image

for filename in [_ for _ in os.listdir() if _.startswith('flag')]:# ctfer 式写法
# 拿到 所有flag{}.png
img = Image.open(filename)
img_array = np.array(img)
# 图片转化为np数组
new_img_array = np.zeros((400, 400, 3), dtype=np.uint8)
# 400 * 400 * 3 的三维 表示图片的像素*像素 和 rgb三色
# dtype=np.uint8 表示 无符号8位整数 用来表示 0-255 即 像素
for index, (a, b) in enumerate([(0, 0), (0, 1), (1, 0), (1, 1)]):
# enumerate 返回元素的索引和值
new_img_array[:, :, :] = img_array[a::2, b::2, :]
# 这里每行/列 指 一个像素
# 0::2 从第一行/列 0 开始 每二行/列 选择一行/列 也就是偶数行/列
# 1::2 从第二行/列 1 开始 每二行/列 选择一行/列 也就是奇数行/列
# 按奇偶 切片图片的宽高 存到新图片
new_img = Image.fromarray(new_img_array)
new_img.save(f"2/{filename[:5]}_{index}.png")