2025冬季挑战:构建一个自反回文ELF二进制程序

本文介绍Synacktiv公司发起的2025冬季挑战赛,要求参与者构建一个既是字节级回文又能打印自身内容的ELF二进制文件,涉及ELF文件结构、x86指令集优化和二进制黑客技术。

2025 Winter Challenge: Quinindrome

距离Synacktiv夏季挑战赛结束已有数月,第一片雪花已然飘落。该赛事取得了成功,甚至有一位参与者在开发解决方案时发现了一个零日漏洞!虽然尚未公开,但Synacktiv网站将在后续文章中专门介绍。随着冬季来临,现在是时候推出Synacktiv冬季挑战赛了!加入这场代码高尔夫竞赛,与其他参与者一较高下,并在1月1日前向我们提交你的解决方案🏌️。

🎁 奖项

前三名参赛者将获得以下奖品:

  • 第一名:一套出色的IFixIt工具包和一个电烙铁,用于修理你的所有电子设备。
  • 第二名:一个完美的8端口PoE+ Netgear交换机,非常适合你的家庭网络。
  • 第三名:一个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
#!/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"

📩 如何参与

提交解决方案的截止时间为12月31日UTC+1时区晚上11:59。 请将你的解决方案发送至 winter-challenge@synacktiv.com。 你可能已经猜到,获胜者将是使用上述测试脚本获得最低分的人。 挑战将在12月进行,技术文章将于2026年初发布。 你可以在过程中随时提交解决方案。 提交次数不限,但每天最多提交一次。这意味着如果你在1月4日上午提交了一个二进制文件,当天将没有再次提交的机会。 一旦你的提交被接收并验证,总体排名将会更新。但为了保持悬念,具体分数不会公开。 如果你对规则有任何疑问,请随时通过电子邮件联系我们。

🖥️ 测试虚拟机

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

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

🥷🏼 彩蛋

我们已经提出了一个相当有效的解决方案。你能超越Synacktiv吗? 为了避免透露该方案的结果,这里提供一个文本文件的哈希值,该文件显示了我们的得分:c4f704d883bdfdd3d4963bb74054af9abd3d78c35b85812dc8a5d2e9cc2df060。 该文件将在本次挑战的技术文章中公布。 祝你好运,节日快乐!

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