2025冬季挑战:构建对称自输出的ELF二进制文件(Quinindrome)

本文介绍了一项名为“Quinindrome”的冬季安全挑战,要求参与者创建一个同时满足回文对称和自输出(Quine)属性的极小化ELF可执行文件,深入探讨了ELF文件头操作和x86指令布局的优化技术。

2025冬季挑战:Quinindrome

自Synacktiv夏季挑战结束、初雪飘落以来,几个月已经过去。该活动深受欢迎,甚至有一位参与者在解题过程中发现了一个0day漏洞!该漏洞尚未公开,但将在Synacktiv网站的未来文章中介绍。随着冬天的到来,现在是向大家介绍Synacktiv冬季挑战的时候了!尝试在这个代码高尔夫挑战中与其他参与者一较高下,并在1月1日之前提交您的解决方案🏌️。

🎁 奖项

以下是排名前三的奖品:

  • 第一名:优秀的iFixit工具套装以及一个焊接铁,用于修复您的所有电子设备。
  • 第二名:Netgear 8端口PoE+可管理交换机,非常适合您的家庭网络。
  • 第三名:Yubikey 5C NFC,确保您无风险的认证!

🏆 挑战

目标是设计一个“Quinindrome”,即满足以下两个属性的ELF二进制文件:

  1. 是一个回文,即完全对称。
  2. 是一个字节级的自输出程序(Quine):执行时在标准输出上打印自身文件内容。

当然,进程必须正常结束而不出现段错误,并且返回码必须定义为0。

上一届挑战的参与者会认出这个主题,但请不要误解:您将需要构思非常不同的技术来最大限度地优化您的解决方案。这次,您将需要操作ELF文件的头部,并找到构成您程序的x86指令的最佳布局!

以下是测试脚本:

 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash

##### Argument checks #####
# Check if binary path is provided
if [ $# -ne 1 ]; then
    echo "[+] Usage: $0 <binary_path>"
    exit 1
fi

binary=$1

# Check if file exists and is readable
if [ ! -f "$binary" ] || [ ! -r "$binary" ]; then
    echo "[!] Error: File '$binary' does not exist or is not readable."
    exit 1
fi


##### First check: byte-wise palindrome #####
reversed_file=$(mktemp)
size=$(wc -c < "$binary")

# Read the file byte by byte in reverse order (in a very efficient way)
for ((i = size - 1; i >= 0; i--)); do
    dd if="$binary" bs=1 skip=$i count=1 2>/dev/null
done > "$reversed_file"

if cmp -s "$binary" "$reversed_file"; then
    echo "[+] First check passed: binary is a byte-wise palindrome."
    rm "$reversed_file"
else
    echo "[!] First check failed: binary is not a byte-wise palindrome."
    rm "$reversed_file"
    exit 1
fi


##### Build a scratch Podman image with the binary to test #####
# Create the containerfile
image_name="quinindrome_test"
containerfile=$(mktemp)

cat > "$containerfile" <<EOF
FROM scratch
COPY $binary /binary
CMD ["/binary"]
EOF

# Build the image
if ! podman build . -t "$image_name" -f "$containerfile" >/dev/null; then
    echo "[!] Failed to build Podman test image."
    rm "$containerfile"
    exit 1
fi
rm "$containerfile"


##### Second check: quine property #####
output_file=$(mktemp)
max_run_time=120

# Run the binary in the scratch container and capture output & return code
timeout "$max_run_time" podman run --rm "$image_name" > "$output_file"
return_code=$?

if [ $return_code -ne 0 ]; then
    echo "[!] Second check failed: binary execution returned non-zero status: $return_code."
    rm "$output_file"
    exit 1
fi

if cmp -s "$binary" "$output_file"; then
    echo "[+] Second check passed: binary is a true quine, its output matches itself."
    rm "$output_file"
else
    echo "[!] Second check failed: Is that a quine? Binary output does not match itself."
    rm "$output_file"
    exit 1
fi

echo "[+] Both checks passed: your binary is a very nice quinindrome!"
echo "[+] Your score: $size"

📩 参与方式

解决方案接收截止时间为UTC+1时间12月31日23:59。 要提交您的方案,请发送至邮箱 winter-challenge@synacktiv.com

您已经明白,获胜者将是能够通过上述测试脚本获得最小分数的人。 如果出现平局,将根据收到解决方案的日期来决定名次。 挑战将在12月进行,技术总结(write-up)将于2026年初发布。 您可以在进展过程中随时提交您的解决方案。 您可以向我们发送任意数量的解决方案,但每天限提交一次。这意味着如果您在12月31日上午发送了一个二进制文件,之后您将没有额外的提交机会。 一旦您的提案被接收并通过验证,总排名将被更新。但是,为了保持悬念,分数将不会公布。 如果您对规则有任何疑问,请随时通过邮件联系我们。

🖥️ 测试虚拟机

以下是用于验证您解决方案的测试脚本将运行的虚拟机描述:

  • 操作系统:Debian 13,Linux内核版本为 6.12.57+deb13-amd64。
  • 架构:x86_64,因此您的二进制文件必须使用32位或64位的x86头部和指令集。
  • 已安装 podman 版本 5.4.2。
  • 虚拟机无法访问互联网。
  • 虚拟机配置为4个vCPU和8GB RAM。

🥷🏼 额外挑战

我们这边已经开发了一个相当有效的解决方案。您能击败Synacktiv吗? 这是我们二进制文件的sha256sum值:8af9fdd50a4b5df623d59b4fde2d8c01d88c27a9badb09e2fdb1b24ca475e111。 此解决方案将在挑战的技术总结中发布和解释。

祝好运,并祝节日快乐!

🏅 临时排名

#1 Cortex - 2025年12月2日 晚上8:45

comments powered by Disqus
使用 Hugo 构建
主题 StackJimmy 设计