软件系统安全赛复现

LinX Lv1

re1

拿到题目后讲Loader放到ida中,搜索字符串发现base64的表
alt text
点进去发现长字符串但是不知到是什么意思,根据形式(末尾有=)推测是base64加密
先把Loader和video放在linux环境中运行
alt text
得到了一个stager.pyc
但是发现它是空的
放到010中可以看到它是delete的base64解码
alt text
推测另一大段也是pyc,先把它用在线工具解码一下,
发现它的前几位是420D0D0A,符合pyc特征,
把它们编译成.pyc文件,用反编译后得到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
54
55
56
57
58
59
# Decompiled with PyLingual (https://pylingual.io)
# Internal filename: 'Payload_To_PixelCode_video.py'
# Bytecode version: 3.7.0 (3394)
# Source timestamp: 2026-01-04 04:02:18 UTC (1767499338)

from PIL import Image
import math
import os
import sys
import numpy as np
import imageio
from tqdm import tqdm
def file_to_video(input_file, width=640, height=480, pixel_size=8, fps=10, output_file='video.mp4'):
if not os.path.isfile(input_file):
return None
file_size = os.path.getsize(input_file)
binary_string = ''
with open(input_file, 'rb') as f:
for chunk in tqdm(iterable=iter(lambda: f.read(1024), b''), total=math.ceil(file_size / 1024), unit='KB', desc='读取文件'):
binary_string += ''.join((f'{byte:08b}' for byte in chunk))
xor_key = '10101010'
xor_binary_string = ''
for i in range(0, len(binary_string), 8):
chunk = binary_string[i:i + 8]
if len(chunk) == 8:
chunk_int = int(chunk, 2)
key_int = int(xor_key, 2)
xor_result = chunk_int ^ key_int
xor_binary_string += f'{xor_result:08b}'
else:
xor_binary_string += chunk
binary_string = xor_binary_string
pixels_per_image = width // pixel_size * (height // pixel_size)
num_images = math.ceil(len(binary_string) / pixels_per_image)
frames = []
for i in tqdm(range(num_images), desc='生成视频帧'):
start = i * pixels_per_image
bits = binary_string[start:start + pixels_per_image]
if len(bits) < pixels_per_image:
bits = bits + '0' * (pixels_per_image - len(bits))
img = Image.new('RGB', (width, height), color='white')
for r in range(height // pixel_size):
row_start = r * (width // pixel_size)
row_end = (r + 1) * (width // pixel_size)
row = bits[row_start:row_end]
for c, bit in enumerate(row):
color = (0, 0, 0) if bit == '1' else (255, 255, 255)
x1, y1 = (c * pixel_size, r * pixel_size)
img.paste(color, (x1, y1, x1 + pixel_size, y1 + pixel_size))
frames.append(np.array(img))
with imageio.get_writer(output_file, fps=fps, codec='libx264') as writer:
for frame in tqdm(frames, desc='写入视频帧'):
writer.append_data(frame)
if __name__ == '__main__':
input_path = 'payload'
if os.path.exists(input_path):
file_to_video(input_path)
else:
sys.exit(1)

根据脚本可知,它把程序写在了视频里
用ffmpeg抽帧后得到一些图片,根据0对应白色,1对应黑色,然后和10101010异或
写出解密脚本

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
from PIL import Image
import numpy as np
import glob
import os

frame_paths = sorted(glob.glob(os.path.join("frames", "frame_*.png")))
bits_all = []

for fp in frame_paths:
img = Image.open(fp).convert("L")
arr = np.array(img)
bw = (arr > 128).astype(np.uint8)
h, w = bw.shape
H = h // 8
W = w // 8
cells = bw[:H * 8, :W * 8].reshape(
H, 8, W, 8
).mean(axis=(1, 3))
bits = 1 - (cells > 0.5).astype(np.uint8)
bits_all.extend(bits.flatten().tolist())

out = bytearray()

for i in range(0, len(bits_all), 8):
chunk = bits_all[i:i+8]
if len(chunk) < 8:
break

value = 0
for b in chunk:
value = (value << 1) | int(b)

value ^= 0xAA
out.append(value)

with open("111.elf", "wb") as f:
f.write(out)

得到一个elf,运行它说每个哈希对应一个ascii码
用在线工具cmd5一个一个算一下
alt text
得到flag:

dart{2ab1fb8a-b830-45e7-8830-66c7e3b3e05a}

re2

拿到文件后用die查壳,然后它说”like upx”
放进010里打开
alt text
感觉是魔改,但是修改了文件头之后还是不能用upx解包
于是用xdbg手动脱壳
alt text
发现它先在这里断下,往上看会看见几个pop,在最后一个pop断一下观察一下,重新运行该程序,发现还是现在ret处停下,继续运行后才在pop处停下,程序又回到这里,继续追踪
alt text
有一个无条件跳转,说明该程序的入口点就为4014e0
用dump出来
有一个坑是
alt text一直以为是自己没脱成功,没想到是程序里有一个条件判断输出这句话
把jz改成jnz即可
发现该程序的原理是让我们输入一串字符然后再我们某个目录下生成一个exe文件
alt text
alt text
找到该文件
在字符串里找到enter the key
在字符串里面找到.mydata和.hello但是点进去是乱码
于是动调一下,发现hello这里变成了可读汇编,把他们全部反汇编重定义成函数
alt text

404ef0就变成了函数
alt text
发现了aes的s盒
定位到mydata里存的是存的是key,iv,和密文
因为aes是对称加密,所以我们可以让密文再走一遍404ef0的函数
在xdbg里进行patch,
alt text
把栈顶在内存窗口查看即可看到flag

  • Title: 软件系统安全赛复现
  • Author: LinX
  • Created at : 2026-03-19 21:59:35
  • Updated at : 2026-03-19 22:07:18
  • Link: https://redefine.ohevan.com/2026/03/19/软件系统安全赛复现/
  • License: This work is licensed under CC BY-NC-SA 4.0.
Comments
On this page
软件系统安全赛复现