Pwntools Usage Example
rctf
python
pwntools
solving
remote server
data processing
x value
This Python script utilizes pwntools to tackle a RCTF problem. It establishes a connection with a remote server, processes data received, and outputs values Q, T, U, and NUM. The script employs frequency analysis on the data to identify the most frequently occurring positions of a specific x value, ultimately cracking it.
I created a script for solving a simple problem on RCTF.
from pwn import *
= "190.92.234.114"
ip = 23334
port =lambda l0: l0.decode().split("=")[1].strip()
mclean = lambda T: [int(x) for x in T.replace("[","").replace("]", "").replace(" ","").strip().split(",")]
mlist = remote(ip, port)
r = r.recvline()
l0 # print('first line?', l0) # great man!
= mclean(l0)
q = int(q)
q # but notice you will not like to be fucked up. use safe eval? ast?
= r.recvline()
l1 # print('second line?', l1)
= mclean(l1)
T = mlist(T)
T = r.recvline()
l2 = mlist(mclean(l2))
U # print("third line?", l2)
print("Q?", q)
print()
print("T?", len(T))
print()
print("U?", len(U))
# now crack the x. please observe the original code?
# the shift does not matter so much?
= {}
mpos_x for i in range(90):
= T[i]
t = U[i]
u = u//t+1
pos_x 0)+1})
mpos_x.update({pos_x:mpos_x.get(pos_x,= [(key, elem) for key, elem in mpos_x.items()]
mfinalPos =lambda x: -x[1])
mfinalPos.sort(keyprint("NUM?",mfinalPos[0])
print("COUNT?",mfinalPos[0][1])
# import pyperclip
=str(mfinalPos[0][0])
data # pyperclip.copy(data)
# r.interactive()
r.sendline(data.encode())=r.recvline() #EOFERROR?
flagprint("FLAG?",flag)
# now answer the shit?