1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| from Crypto.Util.number import * import gmpy2 from pwn import * from tqdm import *
def dec(n,e1,e2,c1,c2): t = gmpy2.gcd(e1,e2) if t == 1: s,x,y = gmpy2.gcdext(e1,e2) m = (pow(c1,x,n)*pow(c2,y,n))%n flag = long_to_bytes(m) return flag else: s,x,y = gmpy2.gcdext(e1,e2) k = 0 while 1: m = gmpy2.iroot((pow(c1,x,n)*pow(c2,y,n)+k*n)%n,t) if m[1]: print(long_to_bytes(m[0])) break else: k += 1 sh = remote("host",port)
for i in trange(666): data = sh.recvuntil(b" y0u J01n In th3 NSS t3am?\n py?\n") n = eval(sh.recvline().decode().strip().split("=")[-1]) e1 = eval(sh.recvline().decode().strip().split("=")[-1]) e2 = eval(sh.recvline().decode().strip().split("=")[-1]) c1 = eval(sh.recvline().decode().strip().split("=")[-1]) c2 = eval(sh.recvline().decode().strip().split("=")[-1])
flag = dec(n,e1,e2,c1,c2) sh.sendlineafter(b"[+] Pl Give Me flaag :",flag) sh.interactive()
|