Skip to content

Commit

Permalink
feat(ppc/leet-machine): 添加题解脚本
Browse files Browse the repository at this point in the history
  • Loading branch information
13m0n4de committed Oct 18, 2024
1 parent 93d1ca2 commit 0341fe5
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions challenges/ppc/leet_machine/writeup/solve.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from pwn import *

context.log_level = "debug"

io = remote("localhost", 1337)

LEET_DICT = {"a": "4", "e": "3", "g": "6", "i": "1", "o": "0", "s": "5", "t": "7"}


def convert_to_leet(sentence):
return "".join(LEET_DICT.get(char, char) for char in sentence.lower())


# 等待并通过初始提示
io.recvuntil("按下回车键开始系统修复...".encode())
io.sendline(b"")

for i in range(100):
io.recvuntil("输入文本: ".encode())
sentence = io.recvline().decode().strip()

leet_sentence = convert_to_leet(sentence)

io.sendlineafter("输出 LEET 文本 > ".encode(), leet_sentence.encode())

response = io.recvline().decode()
if "转换成功" not in response:
log.failure(f"转换失败: {response}")
break

io.interactive()

0 comments on commit 0341fe5

Please sign in to comment.