#!/usr/bin/env python3 from secret import flag assert flag.startswith(b'hgame{') and flag.endswith(b'}') m = int.from_bytes(flag, byteorder='big') p = 681782737450022065655472455411 q = 675274897132088253519831953441 e = 13 c = pow(m, e, p*q) assert c == 275698465082361070145173688411496311542172902608559859019841
exp如下
1 2 3 4 5 6 7 8 9 10 11
import gmpy2 from Crypto.Util.number import long_to_bytes p = 681782737450022065655472455411 q = 675274897132088253519831953441 e = 13 phi = (p-1)*(q-1) d = gmpy2.invert(e,phi) n = p*q c = 275698465082361070145173688411496311542172902608559859019841 print long_to_bytes(pow(c,d,n)) # hgame{t3Xt6O0k_R5A!!!}
TABLE = 'zxcvbnmasdfghjklqwertyuiop1234567890QWERTYUIOPASDFGHJKLZXCVBNM' MOD = len(TABLE) #这一步求A和B flag = "hgame" for A in range(0xff): for B in range(0xff): cipher = '' for b in flag: i = TABLE.find(b) ii = (A*i+B)%MOD cipher += TABLE[ii] if(cipher=='A8I5z'): print A, B, cipher break A = 13 B = 14 c = 'zxcvbnmasdfghjklqwertyuiop1234567890QWERTYUIOPASDFGHJKLZXCVBNM' flag = '' cipher = "A8I5z{xr1A_J7ha_vG_TpH410}" for b in cipher: o = TABLE.find(b) if o==-1: flag += b continue for x in c: i = TABLE.find(x) ii = (A*i+B)%MOD now = TABLE[ii] if now==b: flag+=x break print flag
not_One-time
题目
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import os, random import string, binascii, base64 from secret import flag assert flag.startswith(b'hgame{') and flag.endswith(b'}') flag_len = len(flag)
import base64,string from pwn import * context.log_level = 'debug' cipher = [] for i in range(40): p = remote("47.98.192.231","25001") s = p.recv(500) cipher.append(s) p.interactive()
t = (string.ascii_letters + string.digits).encode() res = (string.printable).encode() for i in range(len(base64.b64decode(cipher[0]))): l = set() for c1 in cipher: for c2 in cipher: d1 = base64.b64decode(c1) d2 = base64.b64decode(c2) if d1==d2: continue re = set() tmp1 = d1[i]^d2[i] for j in range(len(t)): for k in range(len(t)): if j==k: continue tmp2 = t[j]^t[k] #找到了c1 c2 m1 m2都是可见字符,把符合条件的k放进去 if tmp1==tmp2: re1 = int(d2[i]^t[j]).to_bytes(1,'big') re2 = int(d2[i]^t[k]).to_bytes(1,'big') if res.find(re1)!=-1: re.add(re1) if res.find(re2)!=-1: re.add(re2) if(l==set()): l = re else: tmp = l.intersection(re) if tmp!=set(): l.intersection_update(re) else: l.update(re) print i,''.encode().join(l) #hgame{r3us1nG+M3$5age-&&~rEduC3d_k3Y-5P4Ce}
评论