from pwn import * import json from sympy.ntheory.modular import crt from sympy.simplify.simplify import nthroot from Crypto.Util.number import long_to_bytes
io = remote('94.237.53.58', 52665)
c = [] pub = [] e = 5 for i inrange(3): io.sendlineafter('Welcome to Qubit Enterprises. Would you like your own time capsule? (Y/n)', 'Y') data = io.recvline() data = json.loads(data) cipher = int(data['time_capsule'], 16) n = int(data['pubkey'][0], 16) c.append(cipher) pub.append(n)
flag = crt(pub, c, check=True) flag = long_to_bytes(nthroot(flag[0], e)) print(flag)
io.close()
$ python exp.py [+] Opening connection to 94.237.53.58 on port 52665: Done HTB{t3h_FuTUr3_15_bR1ghT_1_H0p3_y0uR3_W34r1nG_5h4d35!}
The Last Dance
题目描述:
To be accepted into the upper class of the Berford Empire, you had to attend the annual Cha-Cha Ball at the High Court. Little did you know that among the many aristocrats invited, you would find a burned enemy spy. Your goal quickly became to capture him, which you succeeded in doing after putting something in his drink. Many hours passed in your agency’s interrogation room, and you eventually learned important information about the enemy agency’s secret communications. Can you use what you learned to decrypt the rest of the messages?
题目中的source.py内容如下:
from Crypto.Cipher import ChaCha20 from secret import FLAG import os
defwriteData(data): withopen("out.txt", "w") as f: f.write(data)
if __name__ == "__main__": message = b"Our counter agencies have intercepted your messages and a lot " message += b"of your agent's identities have been exposed. In a matter of " message += b"days all of them will be captured"
defxor(message, p1, p2): p1_bytes = bytes.fromhex(p1) p2_bytes = bytes.fromhex(p2) xor1 = bytes(a ^ b for a,b inzip(message, p1_bytes)) xor2 = bytes(a ^ b for a,b inzip(xor1, p2_bytes)) return xor2
message = b"Our counter agencies have intercepted your messages and a lot " message += b"of your agent's identities have been exposed. In a matter of " message += b"days all of them will be captured"
from sympy.simplify.simplify import nthroot from Crypto.Util.number import long_to_bytes
flag = "05c61636499a82088bf4388203a93e67bf046f8c49f62857681ec9aaaa40b4772933e0abc83e938c84ff8e67e5ad85bd6eca167585b0cc03eb1333b1b1462d9d7c25f44e53bcb568f0f05219c0147f7dc3cbad45dec2f34f03bcadcbba866dd0c566035c8122d68255ada7d18954ad604965" flag = int(flag, 16)
flag = long_to_bytes(nthroot(flag, 3)) print(flag)