wk13 - crypto
Theme: RSA attack, pseudo-random number generation: LSFR
RSA 1 (100)
import gmpy2
from libnum import *
n = 533605186777306193639508819403689854723168800416077570877556814561974510650703933663552187967375851050646208128209568481683355229899167319112490973880299837120480018922986799636227477834771362913279292487850421999350777708001020329795709138334610780730597034260153640234480722366154979291024335986198570593451145386096041441694142303029951422457927053482922346932059407588856162775465207822285341789134878903971960839160948713769933790271069617086233644676520577331376568114692462625908315402532488462606571660357054531551286020401012508969452459284862627743043345321322925499920088688010914314443609388063914697750619842677930595246081958644122784948962984865394846362143230320583771665384591443721852392466330803543470550877599287392221654219595175889497614399302890343580420367364874038398080995808471132855542861664243296681960132955542020152839237160011164613078369333074195496802962856580473719775240389129028230147531833572933406563330750479771719014642826021391325452781708286449850887680856359748290195973831842764130014972291220789121217726533156605699949176771067317787613639174247701763343887308493679345260109576954599452655522660349242730700233496465587203398595170125932170987424508237647032302254684786567416411326169
c = 732466032403203463374878220140059105091651520977480015886219080123117189578708190919121654951682498149506672860608479885524740049575872017474671777421674377373429605767981432727119392556710499513482246717540914707181450967175025879049618458016661818671901159528808525779690169558386717353946747527285065825894006369625446593132198572253701519060895642563024420339887430552270587095668123446780708158342136739722982418780290340903335556259510360452596819062050805330143163954781773797707204334359165792123048164936391973508948725609734174349
e = 5
# m = c ^ (1/e) assuming m^e < n (here it is the case; e is very small (=5))
secret_msg, is_exact = gmpy2.iroot(c, e)
print(f"The {e}-th root is: {secret_msg}")
print(f"Is the root exact? {'Yes' if is_exact else 'No'}")
print("Flag: ", n2s(int(secret_msg))) # convert number to packed string
# Output: Flag: b'flag{n0_f4ct0r1ng_r3qu1r3d!_9cd6a1b5e826ceb9}'Linear (200)
Last updated