Viva la Revloution!
~# cat Question
Viva la Revolution my friend! we shall overtake the government!
FILES: code.py, output.txt
The question involves RSA
encryption and decryption. The modulus 'N'
is determined by two prime numbers, p
and q
. Euler's totient function is used to calculate φ(n) as (p - 1) * (q - 1)
, which is crucial for finding the private exponent d
for decryption. The code calculates φ(n)
and d
, then decrypts the ciphertext c
to reveal the plaintext message.
from Crypto.Util.number import long_to_bytes
n = 709872443186761582125747585668724501268558458558798673014673483766300964836479167241315660053878650421761726639872089885502004902487471946410918420927682586362111137364814638033425428214041019139158018673749256694555341525164012369589067354955298579131735466795918522816127398340465761406719060284098094643289390016311668316687808837563589124091867773655044913003668590954899705366787080923717270827184222673706856184434629431186284270269532605221507485774898673802583974291853116198037970076073697225047098901414637433392658500670740996008799860530032515716031449787089371403485205810795880416920642186451022374989891611943906891139047764042051071647203057520104267427832746020858026150611650447823314079076243582616371718150121483335889885277291312834083234087660399534665835291621232056473843224515909023120834377664505788329527517932160909013410933312572810208043849529655209420055180680775718614088521014772491776654380478948591063486615023605584483338460667397264724871221133652955371027085804223956104532604113969119716485142424996255737376464834315527822566017923598626634438066724763559943441023574575168924010274261376863202598353430010875182947485101076308406061724505065886990350185188453776162319552566614214624361251463
e = 65537
c = 629271983449087386446961777226000321301965870312268398599537506669889858431379374906494296262823402090165227192809111893224606970248911616802028035824987039758150234145646950316322005917474636606496760673729672877002608909114340000560089382147053953497890425960082938638440486160548358091173635652928750306045154085730654646167452781305825773417471803769668239857212901719807563350263208536312605971444393234367833720622959963977050546213067508180350287625419333696057738845791937756157824897000414535803260716698665471511297275350084086399088067700298956804368564280578335182224349924975014694277663995364772869936436502300717488901891536212232968857135985390616783859464598493974870234747547813904771647692801165365159558462391151691581705494934125275439820607134163339059648948867915041128078971358771970872214113376374091958948592191250934718456852476334122838759940448929560767338089319006528956581832032011095329631491681996100670689605557676862157732327246519546078814025082400486986107558240662048291393341276255527289862573558742702810857731050943492472716395524546584287344269852366782811711970063630718331036466657419817862510398563073262391748024443696817977266765498844400643169098599629738131271505532820548939256243247
p = 20365029276121374486239093637518056591173153560816088704974934225137631026021006278728172263067093375127799517021642683026453941892085549596415559632837140072587743305574479218628388191587060262263170430315761890303990233871576860551166162110565575088243122411840875491614571931769789173216896527668318434571140231043841883246745997474500176671926153616168779152400306313362477888262997093036136582318881633235376026276416829652885223234411339116362732590314731391770942433625992710475394021675572575027445852371400736509772725581130537614203735350104770971283827769016324589620678432160581245381480093375303381611323
q = 34857423162121791604235470898471761566115159084585269586007822559458774716277164882510358869476293939176287610274899509786736824461740603618598549945273029479825290459062370424657446151623905653632181678065975472968242822859926902463043730644958467921837687772906975274812905594211460094944271575698004920372905721798856429806040099698831471709774099003441111568843449452407542799327467944685630258748028875103444760152587493543799185646692684032460858150960790495575921455423185709811342689185127936111993248778962219413451258545863084403721135633428491046474540472029592613134125767864006495572504245538373207974181
euler = (p - 1) * (q - 1)
d = pow(e, -1, euler)
flag = pow(c, d, n)
print(long_to_bytes(flag))
Flag: LNC24{pR1m3s_4eva!}
Last updated