s = s.split("\n") l = [] flag = '' for i in range(len(s)): x = s[i].split(" ")[1] l.append(x) for i in range(0, len(l), 4): x = l[i:i + 4] p = int(x[1] + x[0], 16) flag += chr((((p - 30) ^ 0x4d) - 20) // 80) print(flag)
from pwn import * #context.log_level='debug' target=b'congratulationstoyoucongratulationstoy' defcompare(s1,s2): cnt=0 for i inrange(len(s1)): if s1[i]==s2[i]: cnt += 1 return cnt model='flag{78bace5989660ee38f1fd980xxxxxxxx}' now=6+24 for i inrange(38): if model[i]!='x':continue for k inrange(0x21,0x7f): flag=model[:i]+chr(k)+model[i+1:] p=process('./gdb_debug') p.sendlineafter("Please enter the flag string (ensuring the format is 'flag{}' and the total length is 38 characters).",flag) p.recvline() p.recvline() s=p.recvuntil('Error')[:-6] if compare(s,target)==now+1: model=model[:i]+chr(k)+model[i+1:] now+=1 print(model) p.shutdown() break p.shutdown() #flag{78bace5989660ee38f1fd980a4b4fbcd}
function main() { Java.perform(function () { var jni = Java.use("com.example.re11113.jni"); jni.getkey.overload().implementation = function () { var key = this.getkey(); var iv = this.getiv(); console.log("Key:", key); console.log("iv:", iv); sead("Key:", key);
import random import gmpy2 as gp from Crypto.Util.number import * import hashlib,binascii l=64 mask=(1<<64)-1 dict={} for a inrange(256): x = 0 x=(x^(a<<7))&mask x = ((x * 1000003) ^ a) & mask for b inrange(256): x2=((x*1000003)^b)&mask for c inrange(256): x3=((x2*1000003)^c)&mask dict[x3]=bytes([a,b,c]) ni=inverse(1000003,1<<64) r=7457312583301101235 for a inrange(256): print(a) r1=((r^a)*ni)&mask for b inrange(256): r2=((r1^b)*ni)&mask for c inrange(256): r3 = ((r2 ^ c) * ni) & mask for d inrange(256): r4 = ((r3 ^ d) * ni) & mask if r4 indict.keys(): print(dict[r4]+bytes([d,c,b,a])) exit(0)
n = 111922722351752356094117957341697336848130397712588425954225300832977768690114834703654895285440684751636198779555891692340301590396539921700125219784729325979197290342352480495970455903120265334661588516182848933843212275742914269686197484648288073599387074325226321407600351615258973610780463417788580083967 e = 37059679294843322451875129178470872595128216054082068877693632035071251762179299783152435312052608685562859680569924924133175684413544051218945466380415013172416093939670064185752780945383069447693745538721548393982857225386614608359109463927663728739248286686902750649766277564516226052064304547032760477638585302695605907950461140971727150383104 c = 14999622534973796113769052025256345914577762432817016713135991450161695032250733213228587506601968633155119211807176051329626895125610484405486794783282214597165875393081405999090879096563311452831794796859427268724737377560053552626220191435015101496941337770496898383092414492348672126813183368337602023823
rr = e//n kk = rr-2 xx = sympy.symbols('xx') s = (kk+rr)*xx*xx +(rr*n+rr+65538-e)*xx + rr*n xx = sympy.solve(s,'xx') print(int(xx[1]))
n = 111922722351752356094117957341697336848130397712588425954225300832977768690114834703654895285440684751636198779555891692340301590396539921700125219784729325979197290342352480495970455903120265334661588516182848933843212275742914269686197484648288073599387074325226321407600351615258973610780463417788580083967 e = 37059679294843322451875129178470872595128216054082068877693632035071251762179299783152435312052608685562859680569924924133175684413544051218945466380415013172416093939670064185752780945383069447693745538721548393982857225386614608359109463927663728739248286686902750649766277564516226052064304547032760477638585302695605907950461140971727150383104 c = 14999622534973796113769052025256345914577762432817016713135991450161695032250733213228587506601968633155119211807176051329626895125610484405486794783282214597165875393081405999090879096563311452831794796859427268724737377560053552626220191435015101496941337770496898383092414492348672126813183368337602023823 pbar = 9915449532466780441980882114644132757469503045317741049786571327753160105973102603393585703801838713884852201325856459312958617061518425294700379906584666 kbits = 100 PR.<x> = PolynomialRing(Zmod(n)) f = x + pbar x0 = f.small_roots(X=2^kbits, beta=0.4)[0] # find root < 2^kbits with factor >= n^0.4 p = x0 + pbar print("p:", p) q = n // int(p) print(p*q==n)
成功分解 p 和 q 之后,就是正常的 RSA 解密算法。
1 2 3 4 5 6 7 8 9 10 11 12 13
from Crypto.Util.number import * n = 111922722351752356094117957341697336848130397712588425954225300832977768690114834703654895285440684751636198779555891692340301590396539921700125219784729325979197290342352480495970455903120265334661588516182848933843212275742914269686197484648288073599387074325226321407600351615258973610780463417788580083967 e = 37059679294843322451875129178470872595128216054082068877693632035071251762179299783152435312052608685562859680569924924133175684413544051218945466380415013172416093939670064185752780945383069447693745538721548393982857225386614608359109463927663728739248286686902750649766277564516226052064304547032760477638585302695605907950461140971727150383104 c = 14999622534973796113769052025256345914577762432817016713135991450161695032250733213228587506601968633155119211807176051329626895125610484405486794783282214597165875393081405999090879096563311452831794796859427268724737377560053552626220191435015101496941337770496898383092414492348672126813183368337602023823 p = 9915449532466780441980882114644132757469503045317741049786571327753160105973102603393585703801838713884852201325856459312958617061522496169870935934745091 q = n//p rr = e//n kk = rr-2
e = 65537 + kk * p + rr * ((p+1) * (q+1)) + 1 d = inverse(e,(p-1)*(q-1)) c = 14999622534973796113769052025256345914577762432817016713135991450161695032250733213228587506601968633155119211807176051329626895125610484405486794783282214597165875393081405999090879096563311452831794796859427268724737377560053552626220191435015101496941337770496898383092414492348672126813183368337602023823 print(long_to_bytes(pow(c,d,n)))