Writeup
Pwn
Chinese
FlyDragon
nc lotuxctf.com 10000
或查看server.py
可以發現這題要求你通過兩道關卡。
題目說明要在一分鐘內通過兩道關卡,可知手動輸入是不可行的。
使用pwntools
就可以輕鬆解決這道題目。
from pwn import *
r = remote("lotuxctf.com", 10000)
第一關猜測數字後,會告訴你太小或太大,根據這個特性可以使用二分搜尋法找到答案。
while not number_found:
#檢查數字太小或太大,調整左右邊界
if("lower" in response):
high_num = int(guess)
elif("higher" in response):
low_num = int(guess)
#猜測左右邊界的中間值
guess = str((high_num+low_num) // 2)
print(guess)
r.sendline(guess.encode())
#猜到正確答案就跳出迴圈
response = r.recvline().decode()
print(response, end='')
if "clear" in response:
number_found = True
第二關要回答數學問題,使用for
迴圈可以輕鬆解決。
for i in range(101):
question = r.recvuntil(b'=')[:-1].decode()
ans = eval(question)
print(f"Question{i+1}:"+question+f"={ans}")
r.sendline(str(ans).encode())
from pwn import *
r = remote("lotuxctf.com", 10000)
print(r.recvline().decode())
low_num = 0
high_num = 10000000
guess = 0
number_found = False
response = ""
while not number_found:
if("lower" in response):
high_num = int(guess)
elif("higher" in response):
low_num = int(guess)
guess = str((high_num+low_num) // 2)
print(guess)
r.sendline(guess.encode())
response = r.recvline().decode()
print(response, end='')
if "clear" in response:
number_found = True
print(r.recvline().decode(), end='')
for i in range(101):
question = r.recvuntil(b'=')[:-1].decode()
ans = eval(question)
print(f"Question{i+1}:"+question+f"={ans}")
r.sendline(str(ans).encode())
print(r.recvline().decode())
r.close()
[name=FlyDragon]
May 28, 2025[name=FlyDragon]
May 28, 2025在 LoTuX 平台上取得 2000 分以上
Apr 4, 2025[name=FlyDragon] Step.1 By observing output.txt and executing the code, it can be inferred that the program flag.exe will output the flag after shuffling it. Step.2 By examining main() using Ghidra, it can be discovered that this program reads in the contents of flag.txt and outputs them after performing specific swaps in a particular order. order = [5, 13, 0, 12, 1, 16, 3, 2, 8, 7, 15, 4, 6, 17, 11, 10, 9]
Nov 1, 2023or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up