import sys n = 21330417178780935607595719214966827164644168031404808123536422759093290654986186984779986124674065535048698564789683549387167734567494889727987768739933498971678349576980075810141539382624850797422925386849362264170297518281202626097673334149478517144240971291329443074078694959582725468708457447227839639349739044957816203295007779137952520903181880849153195328904024436481380759376233482818364767325923234064373968475435356362671946576770311758272451460209156772844600601230737225146598490484466829882102241353232243507831156969904841311483482713169909455550241947379796131122370013667777700889353607394579316593337 b = 4274002068103948012295387261296335276534073099764911383581636052340425889440119093475654911229956990021631007428441154157488056344547798620430529214277349041556790618161818511718309258066165521737172848433908748817848729247750213762385803511709610067956121318100202349530582525469139473585392121695567345902964897960223290717588859618755925022435736111212827999806208118196354069344934214573621995398144326767926165385982457100721541082427906774921027937051188323956769161245937772677935416740908446109687284184167848833056958122757276420732909968798176993295703107673527878962729869775179872093620480326690502360060225746120709770398780596068972997252921802475252256298127206044515826804621134200506775625727572326491067277587238664390729960100760636873864974010711754477446449874404297642031752514960431071947785961355012326922543953525772263663656039674021384773721028596399395432038078499373199101030427802797539825191247312297534690911344198747877700456549139900318709109177682768506176815700058636552412798079875260358961926808393450246166788216002272206242946956531722642459995465913686099572185124990781625988846246571306218717850012963928755864429892128097648825866032216862551404588257473250541131565067641080675004580693003553639459436345670000298447491578375883597811206113993332600777868226211055469567433660584476778635254554601006981400456808021357182570178949212462624967529291993282905870149678556609277335627148523389403901209573539193268092883458751447495920686293774234611629921988506226058722069224304453045240777225585575100737004281922392152844890518453502704869327667163246938161462708361897147119495750035205280406081502619321955117600454339048434848118834158938718872053038798540173249401542094363960755013616353935754932738696143370355302715096550112203371006534034453360853914946702897035445067615544765766094384280099673 c = 1313107055057950889307246874834282057796234858584841034116794626165722915548321096288352912266127849525302349162648294622656183904161468685960139363269275869256980163410813173917558346579222752242035463610071956859229359412389739876928832683492363852309619828748080876783596406890654906838878078524446527746824635074501263977485142198597177933002571851122614699284621724742192568428042549822917952073765289139545916107402308221320367813722900920527074762317970197470648785805169869097124930596613880361126245068232142054744643629840280759560511993618458008673926939940350125286138346243627616381829970641311056124602 e = 65537 P = PolynomialRing(ZZ, 'x') x = P.gen()
print("[*] Starting Loop: Recover REDROCK and solve for p simultaneously...")
target_ratio = b / (n**3) convergent_gen = target_ratio.continued_fraction().convergents()
final_p = None final_q = None
for frac in convergent_gen: k = frac.numerator() a = frac.denominator() # Pruning based on bit length of 'a' if a.nbits() > 500: break if k == 0: continue num = a * b - 1 if num % k == 0: candidate_rr = num // k # Loose check for REDROCK size if candidate_rr.nbits() == (n**3).nbits(): poly_p = (x - 82) * (x + 69) * (x - 68) poly_q_scaled = (n - 79*x) * (n + 67*x) * (n - 75*x) equation = poly_p * poly_q_scaled - candidate_rr * x**3 # Find integer roots roots = equation.roots(ring=ZZ) for root, multiplicity in roots: if root > 0:
if n % Integer(root) == 0: final_p = Integer(root) print(f"[+] Found valid p: {final_p}") break if final_p: break
if final_p: final_q = n // final_p print("[*] Decrypting Flag...") phi = (final_p - 1) * (final_q - 1) d = inverse_mod(e, phi) m = power_mod(c, d, n) try: from Crypto.Util.number import long_to_bytes flag_bytes = long_to_bytes(m) print(f"\nFLAG: {flag_bytes.decode()}") except Exception as e: print(f"Decrypted integer m: {m}") else: print("[-] Failed to find p. The attack assumptions might need adjustment.")
call1ng小秘密
brainfuck解码->base64->凯撒
1
Redrock{call1ng_have_28G_dictionary}
call1ng的中秘密
非常简单的RSA,e很小,直接开三次方
1 2 3 4 5 6 7 8 9 10 11 12 13
import gmpy2 from Crypto.Util.number import long_to_bytes
n = 10034458838192354450378996730371090139959078700304989320970470791827709774544051882909504284747432298412371995402769326066736060976548710999109630755854407549444549549735676445234518002317773499031649501473534060667165388944224036836209439279426386442400055821547280683413687958060329873738954349378987874163700505368918514568579218481284408157322593226120835440877748917765905930070492425758131612847519821028911314119892661965475651465106785480609441944785711632658843514760244120843987753943553073160041136621713048017335259479885274605968936731308517402206644004257673190155024729770535761903206196764797956566111 e = 3 c = 68807479857484550806391729758389898946524397942903876441962404719735555961923931034661024216721542983397545329074866058914183624766171319161545208892994234066410868707164031462060599514857031187502908132566888262717583311222196599554744857363781871367156348354921061
m, exact = gmpy2.iroot(c, e)
if exact: flag = long_to_bytes(m) print(f"Flag: {flag.decode()}") Redrock{small_e_result_unsafe_crypto}
import gmpy2 from Crypto.Util.number import long_to_bytes, inverse
n=146878380672316479844233362984600788617001005000700546389849745722524341147552213667146186984492489560397763953538282392357582139086230280528214619997606710607835035864019737700412495664719912477884474199745634668955688629916059945763451519948914271697365026194364957932899444033424783323792417895778485099887 leak = 13540197005808548845902702735228302994696830807899853068206422250846583733448650182954108972228505726534212241510860240159257900755349768731987949236031727091 c = 17405194878769636711554530344040439720869538513184746376304045485984506994708824523612003951121869844739857062451829939183649941345311339367098657051233834613079988477691524343367426775786269578239693839245978327652865130514195139909469827703498554031898270404859625383620481870707744905898798154346552830793 e = 65537
A = 1024 B = -leak C=n
delta= gmpy2.mul(B, B) - 4 * A * C sqrt_delta= gmpy2.iroot(delta, 2)[0]
p = (-B + sqrt_delta) // (2 * A) q = n // p
phi = (p - 1) * (q - 1) d = inverse(e, phi) m = pow(c, d, n)
# 3. 解码+提取flag flag = "" for part in leak.split('.'): if'0x'in part: try: flag += p64(int(part,16)).decode(errors='ignore') except: continue final_flag = re.search(r"(flag|call1ng)\{[^}]+\}", flag) print(f"Flag: {final_flag.group(0) if final_flag else flag}")