https://hackropole.fr/fr/


Challenge Files

Broken RSA Keys

There were 15 incorrect keys to fix. You will see that 10 of them simply had 2 of the values swapped, while the other 5 had 1 incorrect value.

Missing dq

e = pow(dp, -1, p-1)
d = pow(e, -1, (p-1)*(q-1))
dq = d % (q-1)

Missing dp

e = pow(dq, -1, q-1)
d = pow(e, -1, (p-1)*(q-1))
dp = d % (p-1)

Missing iq

iq = pow(q, -1, p)

Missing q

q = pow(iq, -1, p)

Missing p

\[iq \equiv q^{-1} \text{ (mod p)}\] \[iq \cdot q \equiv 1 \text{ (mod p)}\] \[iq \cdot q = 1 + k \cdot p\] \[k \cdot p = iq \cdot q - 1\]
\[dp \equiv d \text{ (mod (p-1))}\] \[dp \equiv e^{-1} \text{ (mod (p-1))}\] \[dp \cdot e \equiv 1 \text{ (mod (p-1))}\] \[dp \cdot e = 1 + l \cdot (p-1)\] \[dp \cdot e = 1 + l \cdot p - l\] \[l \cdot p = dp \cdot e + l - 1\]

Solve kp directly, then since dp*e + l - 1 is 0 mod p, we can use coppersmith to solve l.

Then use l to calculate lp, and we can take the gcd of kp and lp.


import hashlib

p = 123710732789877980710551674977392975780830906608863207436498150239196317560570728784433292761013068095183290251625918973395273980515894845765615109047660989163892509129378114020979533141848210405588460667431162504302370294798995193195406858719797160779003438240368453492856221373608080627122066399823047336279
q = 173444943912248911712819924574162147200284468895796046292566348953202132748163868703395063119626912246353852303177760419599832774319986806486454192519263444446976373982003855693527400670211433586669807420750223627272081167052343512666113221616798414617869814106831821368617596303968203324416286797766065389691
iq = 1183317112933632450303162657109890109050699697733918324780305779886048407610555619884327004264287438864268695648903844242914100843729903495549814381131428032916199892936548205819336192038841477923316783392493236684116244547002671889059392518344974836766414713845240630566048794598942271946598666922473115031
dp = 119763467780841732375141151486231139360623704285280941909923918931447753406387798502087054843957480020348914367675072446196426404670271513584282209638118009453760435796279222112415517001685595334605814718847400125161945305877176913549281150519332634632798247257704318156321086050217258494447397115819499414371
dq = 113932604282279869093282818582615029044492457192361262671786049122695180102531287542945610110743659394040381405107024030824504756743422098483462183945800737530488406709120003114991989524520627543486542214652764098625652847039013605303671501021377402648169755276129115645679113749712390322989846602278655620213
check= "c17c1c3800a6e4b8f2af2052afd10f6b8c271589033816d4081464c8914025d0"

e = pow(dq, -1, q-1)
kp = q * iq - 1
PR.<l> = PolynomialRing(Zmod(kp))
f = dp*e + l - 1 
lp = int(f(f.small_roots(beta=0.5)))
p = max(factor(gcd(lp, kp)))[0]
assert check == hashlib.sha256(f"{p}{q}{iq}{dp}{dq}".encode()).hexdigest()


Full solver:

import hashlib
flag = hashlib.sha256()

# 1
p = 68542786118966972811388530853909495947006156792800247409421497889996772223543464603474133873532734124123861657843649420013534243262244183098756022222670619740685219722055373685553610070708707152471797184421632665779602474233486168373561704212597606378764874153585340916031331835198666976905591276287943544311
q = 90799943929530883972679906031068949220840625070369474122819382686712999459300348010786360216424923541454526761361415529351519811820854888722018460113726698046547617536792433043030731740593028452432825520678631896470096533687965393496523873300721573918185828664629442558163246062238387092090049794084673251683
iq = 45237423923475861099631723912680556785593670387767228256623995210783368597416640845645040965063361258849040436396719342332272578611052053743632286654209646511815990283668455632031896005443449025375832599201202889508487283731298649915836618236043499192551371578860942565015979591702506375624967444111031693077
dp = 92238261119297830072259899019074244794154506948953629067690682420303556914925131445447407640540725062843053973456687749555479277445992457251858162730451752708170921276737151211110068556893888365329273119736823618196478587507632915112446550513663798413802244468198952682052810899037210356002787968351613169909
dq = 94152202755252869805117453420406136812557415204218518611471158908427081555640746836008878525933842171887505332243589417360213552362147360738726668369813032263292472859531224465687668826098760741721072349679869299220861470711667328939786023049445920475822118071716196713088710027039993635668840249369630698131
check = 'b800e5bbd0537a6cc682eeab816743a1fd41a4dffc463ff34315f343572c171b'

p, dq = dq, p
assert check == hashlib.sha256(f"{p}{q}{iq}{dp}{dq}".encode()).hexdigest()
flag.update(f"{p}{q}{iq}{dp}{dq}".encode())


# 2
p = 134876234236759525067182519269574560416836000843173087507256123983996658258710943988866467347394568084717210014440469231040526998463129860664286933650456413903413917155192193948089413435142313200382846031873415472732076247661741792110679798651988421411875288675898299935138062071475411751464306690062551137399
q = 162743501760720934735475236628948723610911940663231521498278027679370846035726934416035070888472239767462931365930994339392296783751599704240067081719317682001920652347607304345738981300654209427924508112176659020930168596495737708850027229118027294097559345554457908463935611739874777795378412661345512767167
iq = 83064328520218253472483138161411635144825787476517600857010413092516049498866876242534255736782570931384017906443102368928610616399244751000307256980279569682970407318099543623489462970636093937027188194688931039761535488016614497488375628037082054513007770118829648417996149072859992962862420905789603107863
dp = 123486435232686591110667831417872201428822830322043728535939881583391756016923926588155275024314702687599896343385714220121382836148757952223127065640002998387200073810595031172164205575894782410358226987398383252211341015713558625220709477671999930551928972611135752691848754562449372652977611562969957687807
dq = 29915198305607167633683202907591206538095446523442948568911913141543855997364212381206058763417797527466522447485214237696725595164758311684757207778008055770170597022963780819889698613661168581118240915594625517754421192743351364313988734197079375568540113873162983346943062246328628060981886123239095318758
check = '47f298e1554f28a76ed979f6308bd496a81d2fee21a0e7e171ab46b46a07454f'

e = pow(dp, -1, p-1)
d = pow(e, -1, (p-1)*(q-1))
dq = d % (q-1)
assert check == hashlib.sha256(f"{p}{q}{iq}{dp}{dq}".encode()).hexdigest()
flag.update(f"{p}{q}{iq}{dp}{dq}".encode())

# 3
p = 134548368367099032365830103412917034865605940837070656337081605239782821559549377755046503914921933800180902409655547064240259700264500189401581728655605587637973021917058228750010732600345623398732699300292384974074527594826283153537506246954735204552851363560471472745696358476655327353374037967675124289573
q = 170650174516481778920197585415376997775984961441349571390497440160355055185995514268655958260836765031894594255203070661265156820782465535818407004109869585447050358593590913770365681123912519466314841564788597779087778014275215152360602428195256341709703620709320479272310590342204185703192534703891773482913
iq = 16890628157606713051110209535424943917862972936813375886271595270329117577745683862818227881689293678870982285621895840731746274809141834714434938394390761278604256380451097149129931278437096071459940678938986810720464358351077823814333510908189885902615951366764225352991947404485375244145109487599635369392
dp = 161116606487752618961924678267723809067520784184585389589675281196754733184309026588313388862084341466543625091694982619122277706767133354538287308534347107844828760306870143530148771182914857184751865839130540938349222580348885452386479420326841013268775673270040923812712653350042978884064509424950555849009
dq = 111156188707139987123039347859315717682981495506380331375773830385246848747823970682186282134499320614562474755684159022404815381815075157593657459032091927244876142029777978792325471646878896576923041554893596294043082445821756799709351172002030134805228239014386726365219620796529065288157214831760334441905
check = 'efe6e6f31d45b7a301a10ff2ca4cd13d64d25cb999c53768eb40ab46943a5e02'

p, q = q, p
assert check == hashlib.sha256(f"{p}{q}{iq}{dp}{dq}".encode()).hexdigest()
flag.update(f"{p}{q}{iq}{dp}{dq}".encode())

# 4
p = 88786249468608301035498374463490218825777885936292861576432042424488385902882931222137146451857405167627469785044181103788477617334943129927184652490492559917700791709796410466694644419412332028774220888614683462887592979971949124485444179708635095423071877179367910056414046206899600792719293898333310058993
q = 124023670702300076686953685310413003746934847768988832563637371719961914995142873460848338027686874584842978856517168646984627745706275985094565948215125856529414084690233912187994268696402619416656696906426534190210568878838045559323336887283124895205829034520372210992559178757946518547321563414123578735567
iq = 148740034485348044773246118869242459123607748430823307814316961809416313898635272020517308288479137539899810862132340887281356947704222058529785421422869805367045708021202834578374081370130185849907209190503525540216604416794335694631633030456119088670097326904440050954661320638482425091873138378084989662413
dp = 46675491265926488969286664664540352949945034106086500911958863386217563481748069067247609547184457563060525680330532348310006037552910767614052174150034399768016570536980919890622117160988870040408684029503108148879596234105520273707958579888059594826562573288461924173100757937686444084829369883766093670589
dq = 60881057216894694808930347317292317198875935808562657796537846027962605297425023807536946987109194554999102071145920727398235821046394670538539364337038944112186783990379405463559281798384302970245225940755402510051713446484227291060244976325730720033283766246829820291566531267961458721112813086294431711039
check = '5079fb2b431d422e086967c5f79f15e25de1b3f3f0ee8d59e083dd42270b7940'

p, iq = iq, p
assert check == hashlib.sha256(f"{p}{q}{iq}{dp}{dq}".encode()).hexdigest()
flag.update(f"{p}{q}{iq}{dp}{dq}".encode())

# 5
p = 127204236367022698191130040742628041942409545229573081946295095307499741620953038385175940244975763353609944288696398059943872392364238932260561846732207067494345261075308666689405683961182447703224116080137610893606631529097862346263035230760434463986372543976110373352698499294424062395650073940292860126731
q = 66147458130399831589444459730262005510370488130146924292979097310258323890280927579961343688683211418852575042062563278845633432537544720418266621202654263143245978777457042223478764677098436752022863623246289442283406049085203986284134889356530682096678200711024170238555275293879532267306644337039630386073
iq = 62394017068651373427476994673251200146305819555212056989923616808692069160173263585173832937688108277819825043711730971530969958058368701098187549337957063790243142300497001571380991574342701778998314979308865292054853170064031097152343837963009053882502707212847412450463150574009333714037151195978796621566
dp = 136899291406677857836839531866284878255692127005405851537162725127740148087079011958517336987262419695341621404084143763715644083152741261142279550905931056505435266036594329878357146117030809404502247840809734909949315101947128804398708765291721371670346565088886104356343928204589292187810822581781072372939
dq = 20457180874947720913867526696462888755292142308277920940735831237859000084748155090293757651583438030829323065120088434983001390533818998552717599381125353091298167049750381236194643695100929238824007164202648035861425637231999787045357018698202910203270035160775469493368515069240317084370636679208183602603
check = 'c0307c34070467e3f01950b6dfbe094dca59962bb6c55e970d50c062cb5becce'

q, dp = dp, q
assert check == hashlib.sha256(f"{p}{q}{iq}{dp}{dq}".encode()).hexdigest()
flag.update(f"{p}{q}{iq}{dp}{dq}".encode())

# 6
p = 169779805174243561783655542008370675722920868349829815602503293437577442207299431786758049214400367477951771249920505441885989642486835546426414143433536927267533701452401802027179146705056747428336744256026742110427844588339375423587106322353964910029116683891107728943928002308637314380846606636800386749039
q = 67637522753290664393460379740085195264108429597141250138514441026789873396401523215264596609424914613322468794115881245513635568939275306561869315994125580645419800630421874593491011677731601282676974322980096016588090430568681967584918066427149059155814436753970912642095640531996305068271165323370242294125
iq = 15889173004664222063527372836605280013022107521844138913672861093430980723377323225051317446150589947029745202654885997711216616273800633323240658039081815674434018913728418861449545340261409866187522670591321283500718184862773554237283306517370814657587305062974765652001158887785692566460043878612383270385
dp = 116435283996567698997914196171037569436015228547894341848001285699797791664682402221176299578202885140624557362076970083713447095416646229758038309434567953486179233728954883947594942785223633742845806853699042317282577046392932404196866378377152889520604266662933260526962507380042162130727911337285430553863
dq = 138007234426965555991675421056822113243760517713447822285094828079053397638498088218251189542026897652535075656064250688511225154243094152054299767014978079401786624334122585081588213904513347827538503225268370397408002033496297861419672626006927758298352570788363370174096757112823349608156856630925929626797
check = '4261d39dcd508ab419534c3c51b86707f5eded5219f1635d0e89f22374c2b431'

q, dq = dq, q
assert check == hashlib.sha256(f"{p}{q}{iq}{dp}{dq}".encode()).hexdigest()
flag.update(f"{p}{q}{iq}{dp}{dq}".encode())

# 7
p = 95514114040640411061927268674647196784831376072324733781996288236868365460926102451052346696673341114962285892372908958175206639495664930849278091153184434981896729314352862648419568726123871259490777946004251589657271746706455371997452903822076216315870123025231968195576329887950049420143834772027595307181
q = 163890314098880387923959377660975239676231365236678324890199388261460798972150513379806253625755277841650186282580338640327143334154059623304707074738163807244915657689459134500044604547136865968948070541590424108356262697273457267411774063907479475183516828593528041456857312393009058154399188799409296311459
iq = 48752529494064252066375955655315965315851343756906662125825574118134196595868000662934942188995886133709127451832410899017502884687488428527520620346663070130746121052440708038249767594768125802295330998761790246571135912945468029430129039836925243226732793246607679296897890630503860080411565361804272409801
dp = 74018082508680086062643883634963370547174148065864074123193939206602875423173477499014177987011527581957540208955258144196416197232877247925980753890396014878220646088677208556474916300362567170644461265386202935692339831184688786421889070959338534369878391198125191682172340820544777164656568067990991381699
dq = 41932413127918371043404068746926792108316738880639525818139088587014117947241037890673454796609185290818177699848274733709482506524568854682275452467933216295247828096494290590011809829850270796156707846502097576738608360843031757991983914696796159306493612508467260102605970317991512275430535034349951247589
check = '81ba0b57b5b7477c26d4f6b08183c7620d76e36c7913014e292915857f279a78'

iq, dq = dq, iq
assert check == hashlib.sha256(f"{p}{q}{iq}{dp}{dq}".encode()).hexdigest()
flag.update(f"{p}{q}{iq}{dp}{dq}".encode())

# 8
p = 110680127029800527940859908921927996212719172377102829833887369549754309933819362835207945283939385214038797754298532362419509957898599938441738610895015308574237281548676603932952957534633930922825506748403490303028138202785007080802275865547579540217224150794222459015809381202826281385392849352649591946349
q = 94952569908022580136515755364385335182434232923385836306243850163214485475621491016832756033064357305961789782996148711870166468224656965591676772467319982608757940681778951704027552538003170192310350429806817741159071518741420391827046500289352130841088958512816682277823186515737586340391458384588233459757
iq = 69627761639922285313905731293878245059096385993562225917985888390966491072698147336954323703765162035228275042237858792351344012267190818547385641564180719451169948163241999399091071985135979698061444739806958105783059918484018078761605401360168797066225930595821513103705145572304917203667386646120699107643
dp = 53629729261265933891068175785465332936792479494280640127741648333290197395663334196065169217350576597288718807998535692835956585397178028196140717249678472318590193538177524049283842472983828693095378363799982946141108965728810019512091919500187735333544460315345282868431830584644430709352036304816146510778
dq = 32237203977655985871008584489095555735310193748295566432510845045241617225309625389717805566885508895703815334039166154274598210845761889459539601726715955715316280984354758434402829867563726107677081650765119720371406833303235997519032046913339442744815494567956125378697725107366620884529274342113229914271
check = 'a97de43e5323889ad47479fa49e060064d238d2f59ee6fb77871d6ea13d997a3'

iq, dp = dp, iq
assert check == hashlib.sha256(f"{p}{q}{iq}{dp}{dq}".encode()).hexdigest()
flag.update(f"{p}{q}{iq}{dp}{dq}".encode())

# 9
p = 160107522138753897566723452539720009118488225449182426294961356635896500349542603289377810195222530796891658134433658789308197535880394354875762124160550189648141689430013425118075004212478117374954220109784201964995212473717035187349949721261730472268993876668461201951086685864772191653841107150630723195071
q = 156424008432208650567918397894535828254945073290907392886468574613641091638741467836580757497378551374739658560560879249734970684819166791979233130108657078144848206087278055217197492284150557215227730156640841984305994104556664763276437463563489700847429204761057909367710466042994313487433992254093482385029
iq = 90914778956737832097880179912167194554569597882594880254379795430077431748609067543368085101642784348081637753846898094250086605376002424465771703081731703111192669386319407948167387359447218350081945961349815130865118916801697973834967597290794014724513492510587467942873094440013007356826953342733799340705
dp = 106326916036171670362854762651233278439266412617252526282470931838104050590081032281126535465718175859473915065901893564861567578275731658940584329287188478234972933442855928576956965631053632357362915119242299749539706516103967980519320627567463055224399919300675937754346473742880180583649343195856803023557
dq = 135404030269182026552863666597286806843944580866577936304602479659765944370528797807707583150513793369897128870477107566933218962089541459144991727824968003387992897245777717031705330947420473338816886829757935032769128478815730188191489733784795901941042231499582485676276477882864754358206755778992397043381
check = '8d3d76350b5d5870a0a01bef412a07a932e3c0ab79909e47548dc1beff9c6f2b'

dp, dq = dq, dp
assert check == hashlib.sha256(f"{p}{q}{iq}{dp}{dq}".encode()).hexdigest()
flag.update(f"{p}{q}{iq}{dp}{dq}".encode())

# 10
p = 155281681544487641877568246548644481225005718842484192216650478072290837602315450531867970405447288521379061301328023353854537057334852953681934951233981848780913302875545973027122865741319703370140706874915548018442215690620074038652534778079908046942006755868285830475933823784664418880495113275322026868447
q = 117746986572041821319208009650904710191970235550381283434061730395959494036738360141126301058687609810197943074363868885108261921529657146474084157431904764917098869361116943681240301331869895006974379988282015853766663920271917749728007662165401322735719516978031283273379327594932505901754730902880583279399
iq = 37541767945997011630313759160061631239794125769383541261761452467987925235053249792018259264821007192558002321348597100769231535867653679799788572377677107419816566410780821197725724386563642026882361561201723651485433291940890898833377220836105919759192520055826503235046145637624413283502826666768452120062
dp = 24513810265674002251253699129697817026956155807309013791278761817193345676465938455629842095067731203099601544547621516210953146361699152213735176968627115373116715673216947169695480144463353333184062115240860555381582685924360380513383739381904421238044398718872440968850485064203021233580397694238202093260
dq = 86564684099522157602416378762642983127732664172194781640774755325992474989583442607814572349641070480448729960590903404598409562325998597996933582873606115897550574941832223298370827052824834819688274299184759815827588445221177051894719050139300391551399592927819175119735400974375161755740157885522544667827
check = '4de9370412f6a972bdea02957eb2bea9ae3244627e775fd9e66be36ef8d3ab6c'

e = pow(dq, -1, q-1)
d = pow(e, -1, (p-1)*(q-1))
dp = d % (p-1)
assert check == hashlib.sha256(f"{p}{q}{iq}{dp}{dq}".encode()).hexdigest()
flag.update(f"{p}{q}{iq}{dp}{dq}".encode())

# 11
p = 123710732789877980710551674977392975780830906608863207436498150239196317560570728784433292761013068095183290251625918973395273980515894845765615109047660989163892509129378114020979533141848210405588460667431162504302370294798995193195406858719797160779003438240368453492856221373608080627122066399823047336279
q = 173444943912248911712819924574162147200284468895796046292566348953202132748163868703395063119626912246353852303177760419599832774319986806486454192519263444446976373982003855693527400670211433586669807420750223627272081167052343512666113221616798414617869814106831821368617596303968203324416286797766065389691
iq = 1183317112933632450303162657109890109050699697733918324780305779886048407610555619884327004264287438864268695648903844242914100843729903495549814381131428032916199892936548205819336192038841477923316783392493236684116244547002671889059392518344974836766414713845240630566048794598942271946598666922473115031
dp = 119763467780841732375141151486231139360623704285280941909923918931447753406387798502087054843957480020348914367675072446196426404670271513584282209638118009453760435796279222112415517001685595334605814718847400125161945305877176913549281150519332634632798247257704318156321086050217258494447397115819499414371
dq = 113932604282279869093282818582615029044492457192361262671786049122695180102531287542945610110743659394040381405107024030824504756743422098483462183945800737530488406709120003114991989524520627543486542214652764098625652847039013605303671501021377402648169755276129115645679113749712390322989846602278655620213
check = 'c17c1c3800a6e4b8f2af2052afd10f6b8c271589033816d4081464c8914025d0'

p = 148776188849158638853446531073720315012910499863051597875993106438738019662340728645994401882383803556738824918521744442096160191659638669139405681539253417041605022539125813804977835590125154503013888907220655777438740953230943112551304451238689298807877211246693367620949977615271504569981059694760990469053
assert check == hashlib.sha256(f"{p}{q}{iq}{dp}{dq}".encode()).hexdigest()
flag.update(f"{p}{q}{iq}{dp}{dq}".encode())

# 12
p = 134665494493852268006997236367690358709787743598088608142647235543182664732042842040302740975621876681820714470444874455023632854019215341040830682639969488972185756693410420344396907241038668873154276775399723233912287458814572110240305807879017401685719052867434020712593958009652775816852759677973511945347
q = 33735364798050871352470787716986701209681455030821066145766900356233383482770181825486316654168888937839972696825115995980493947306160213735436425097789774175604084670010089867274822485778260755442047375959807440459528629272714326226338712385278167975214487231771400865201612683369551903278381643979684494931
iq = 148053479670073017098430657948246455271192520605584453308825976055435478458263258456858495444657719321192890372046537764037068003156176804709112551313120308491261483656117868541267691283344480883322369302054249891034977818065867404817893125846151446145761435895283844516368173910376726009141800020807390320511
dp = 26332121296384452687939869979153914347324265611230356810851537438409955253214818432038212693225039163537380134482654171931370086376088558681867312738951805803970249664023596038305892859489130838613106383049313482693188118022699932790711569497083459645286525702792854921560780603477790537710332932391937738769
dq = 67588830902432769696132589442522478032268963632798289646977788252542949303070663869796395520927476700774448013550258657948073380860775080905637945706728006388115569891071613681424276866754444296113517174034136048667732094603096084836320088208691481607529087881976898678097231831730777575388249137527656882433
check = '7f4dd60cb52303d572561fc8d0fffd4cea717ff0710cf14b3fc3f8664709ad32'

q, iq = iq, q
assert check == hashlib.sha256(f"{p}{q}{iq}{dp}{dq}".encode()).hexdigest()
flag.update(f"{p}{q}{iq}{dp}{dq}".encode())

# 13
p = 57507391688902374196030580275987115194947769485315451211074555687680978978057971414302943917042077872441220398065605607396780454930865116410632598153630370024568508673174119284254602445805929612728341190622258765672362801589765432333495863188839758094618031596800871809033302126387085193385608748978425810741
q = 127103494320968397816171633533822708048915543488336058151529814593038881567881806653055129651288499985356609334388400915807298363595223235553914256860992011406250867040516294621145551865919868243014464439913318593307951608954439743798908942252207340788744374297779837868293697938650512315071433408037936388293
iq = 58829850181044950186332009431409206846358457287038293835616061186616844607811708844158058158391108606635608263422679862780542465936552117534677568082486748371539741202348148858348903439784495128328203933091305188180276066607073757489446664177268840124807097039631436206913844724410735482662201063641026768795
dp = 144276755949872275651747606117065669654685685522781600769308381739739297095586800388994892244038946027043252496780124507800401524394061817281574988345427801313974252674184826350915563895315018518173891802155170292094876804260100334297604323518993520518919387133072268518799601000300951105178148365551448469553
dq = 52553707396696504242654859946815865927486368387961237535314902683589578769940478489452807912167115642625729655553867155326684357185168415166908914893338832637491477141331693283550239376338614568000268679726053843995050884201975861137552148655813049912783429357386817754775285761148481750276561385124840352029
check = 'ac71b81d51b85329103039a9ff18f4405a3ad4cd960bea829f9ab07b6e7181a4'

p, dp = dp, p
assert check == hashlib.sha256(f"{p}{q}{iq}{dp}{dq}".encode()).hexdigest()
flag.update(f"{p}{q}{iq}{dp}{dq}".encode())

# 14
p = 162212155091224027380357591310178977679196400365780636344078104989353809464389989330309454105948483132772790139036763779020794416528457272033751256761549628694803932931999983677857482158791011417275413436352546064734951418296380734889443193502674452866042281027969275842359976170924226671182030700843256297353
q = 135395150050899392813957843559073461069731610224925585193268651102414183378179562966318101510026566306059362725047755327602662248372029268426318157470517872122878525990180981831054756539273845823917373899119155703379193118368008123589998594276649275672814383996740522355893284197911604936719605483176696280353
iq = 77674345271831450904575195531528355926065714948946479679385682380489126089908044345197240657305563314478855868587180447049173792391472396300600637261272061755074085313636445151322695417689157742846085439595538998434376258479503635861377129622796952216935943284862469774725570515674600470030072668288984498761
dp = 7445267729922416389595410126602208469463551726610121432439382346499586208666306884005852014485352282854238593440457152806838358791993652373134945504691397600355004355153693400260676521174813506547117980374941440471847008627891189340357127476774756848360789107065060441061752248733758843184256185975790524163
dq = 43027635592316132081621413313604025781099082991300642984376599969504992886720952825370586030328879116115089697767628825465919335742626099916207847602110097531486191278911892797120660941568512171865775178509253263342280318235564982072271305324153643929905657445098197091457561434496224927621259314203635019067
check = 'd2e75a4c770237d514e4d843003f3d0e28f1f2f73f188d1b645398d984b2db72'

iq = pow(q, -1, p)
assert check == hashlib.sha256(f"{p}{q}{iq}{dp}{dq}".encode()).hexdigest()
flag.update(f"{p}{q}{iq}{dp}{dq}".encode())

# 15
p = 176498917711722606963547794429462584408563586776641755035627700256693427785248755551102380203693465119144267727288940102057403879107254095187028003478931382398261347315256327072258408257299356622482517524011865800466849717528633584859717025256392912460453489286004546568522512368757979051327384737248394714423
q = 162514356134191165470582287266887711313783983539919826277761227531055876435402278784654652867387727711299595474633942102478553664459110999314016946784769483091521629443717438363024396954751926736682978530840025128159034032298825828020893980770522874406344330469108931152624814743606352073998696094044481144789
iq = 133615531300890473814301666196493218616079177226924803219124478116221344476701023694742789723760028354411546352665846270412977885604485226454236913640467729544113615195656214232731061208256639582872949774653787487430964318996366693763333633979286698328163532261779602846430980167947132347320858634216148203518
dp = 56752467171351637899003515586262269157835260800351753746087785433852529360462743190403770080269523511739590783143557148944352879575318966616082734927460871579791470147289445788180819207000074771724391371598647049448018911049614629146302567175129059740062500415707886452794936255133901051233640594619677018141
dq = 147315410164733962068455895859630090524657512481118517742459601509853627640906565536418994611679815738223096297894361536744530380788797428511167242195945250292546776130325594115387346671474465783117294017151042176016055195953683595940172758540441811482667229935632935973885136814245476350207428971191728847873
check = 'd91917afcafb9522ec317bfa07239fc76aa1552ace00a81356323b9c7163a6c9'

q = pow(iq, -1, p)
assert check == hashlib.sha256(f"{p}{q}{iq}{dp}{dq}".encode()).hexdigest()
flag.update(f"{p}{q}{iq}{dp}{dq}".encode())


print("FCSC{" + flag.hexdigest() + "}")
# FCSC{ebf1596ec5f211d91c840898ad3bceb184e7143a3d02710271df584f18561247}


AdveRSArial Crypto (Baby)

from Crypto.Util.number import *
from binteger import Bin

n = 179770685017248789197537661565815269934203562120851089179122414399064734715990794430000078278988633398024403072323955508476586487162411822366599111412534539430740137196265242371128714558362082882520001747685222655863817125733693411058452743768818267918688593648334613756045157321491607233744902053478170361857
e = 65537
c = 0x000c307feca4371acecab2690800586b967909e12ec3e80184666ca161129f86c6cd87e276127a1f9b672b66ba3d715321b24f7d660a928d829c154dcdc0634b99f51e281c2e138f77a04694ff7aeec25c938cf769fbd7d3f2968f0b96fc5d38a8f742f6a46e70d7eae8280ed61f0328df36497f0cb6251b0e13a2bc5adce6344a

ba = Bin(n).list
P.<x> = PolynomialRing(ZZ)
fn = P(ba[::-1])
fp, fq = [c[0] for c in fn.factor()]
p = int(fp(2))
q = int(fq(2))
print(long_to_bytes(pow(c, pow(e, -1, (p-1)*(q-1)), n)))
# FCSC{0224e979da8a6069869ccfc040abb680ffd35e3ba61bcc0e0683662c33fa81c0}


Fruit salad

https://math.stackexchange.com/questions/4217163/find-all-n-in-mathbbq-such-that-x3-y3-n-has-at-least-one-and-only

def get_selmer_point(n, P):
    """Here P = (x, y) is a point on y² = x³ - 432n²"""
    x, y = P.xy()
    X, Y = (36*n - y)/6/x, (36*n + y)/6/x
    denom = gcd(X.denominator(), Y.denominator())
    return (X*denom, Y*denom, denom)

n = 94
E = EllipticCurve(QQ, [0, -432*n^2])
print(f'E = {E}')

G = E.gens()[0]
for i in range(1, 99999999999999999999999):
    a, b, c = get_selmer_point(n, G*i)
    if a>1 and b > 1 and c>1:
        print(a, b, c)
        break


from itertools import count
from hashlib import sha256

#for pineapple in count(start = 1):
#  for strawberry in range(1, pineapple + 1):
#    for banana in range(1, pineapple + 1):
pineapple = 5838029425998642036519121386766237934443985371712628493866262802675611337745332163898432961240106270481701083644830663378675493757512360711588260537548344410361717772825990984832688854346492124099165831823104743551511236792247436196331973417983047967998588147284427165684321624144744763482111480138223123116789062981203069167757719302484743085332337963086108197977736185589403289931423637507107778287502927763625087383617218165325045803292348657514858771172134531042650131983986335338104219586684625893401220714474638519831965046743552916194004391766472139979796569194772427444065418854924655324074099085710733629720240324970327539888796898419928894549064951165988240377204917430163823613150689446507374954363006503625866185678870352642426810130325439462677497986496968756540651840100222679906509738322823556238901994223912013974297010154093142434697514104988355699415976770809936297195997499785647630578992294300430478317869106922160198824989765018210446193387652795657898763923856557233581181937666124912044317142384056579396851929319098997381629962563737880642242185348648252693616827951750783377991668333402660952105078632353664473113427365172657211603238218187336980036947879631581986949259800534182102622386811906071268082421777187401960852549631756341734866681812420745618318144789752428940082377377215609933418896605642204379296457459597922047486276069206283465101026874516372063869071587189597315184159364969951781913858172733676265962251269417894937843589334235462829077780907357771950210680441024778019267655776709594011393228717778066136780996042801316935666963007479467995437558075470510975344106938530350734753976272079327791857953686843109153157364180149064780289677452184201015747312000085265635971008610364740312047696850062179606954035059641243127937135957516916383417388753979889985842492345633183944959802210364669821354320916179436239943420934744102985618629995477553812458411574733978116203321324251962132347145347318440435288422058542577
strawberry = 722730855291655570648364472593373207301669838049128815802761555003158908543253757834189350276048574266183923889135513672633473584694081901380483327183472605986005893477598234010608532875471169750420689753187442309142141540669072675511172446418744039599418122283859332429195327691565961568113715598402411728408888182041019180214299384446721005644177762524261614733670609710306299627844060849966169695398318980200744035564604747773686799037662773743200849806460369368664514681958958027477957126929470650023248059150241071592923363906553836975177255615410880029757369894921463446538060162912454672181738883460531563471016097039810948230523264063602751576712338013809066911021712371791514206050165484611035527765162646989873801879018621381682249742626037276515916270313847223404355635361816812172273353834097669921058498420586771308931795540008459109778446094144175383372362004281964367892229490650216882924749425120152434832758028821842062339224782679736797735356704500011443682086767648233530001243751145522130024765624553613542788795754581791742436489619581871928399046728848504093078738408281811664097499867488308463303073753480076218684981885464841735452384061137076205274357932902465079699906008610902088834722210098687428808891893999087493036776637864564222212691611598981837538054793135524218888716422536668527434761357541273208518954456825030260690381762014955519980355711371787120232530300165587458379955613207547038597521942968262926934787384069284071783756022158583060963949517206151505243441873761869370357506659168176512097981140513863503036746399395984826941623261463791566763580767150876124797055371329828424430673982408327940686851033986711038811746337269665015778961886856113296245766355293607981333917080212181532904764400470316426171920265899604036487932759360360402325402273366581691372199109231273749220585342442785054661501181846698669892991508475833969933601317590044439109187196625919847750156853352373212068952397966943844278004644207423
banana = 1284787770466747714214463308674513623822926372114908566468479478290930421154475905257855042608379517001345895836571922831019219960076589350494709967265234749739593440020425071515369858596573419172416921450292553675556200241364124372778378009407483220717623841656057014455872843067578444266191644173890107493561115462880829471903682697103710017275721258133575141386919729904952547572322880577697812560004096729511480191539876713447688218462013326864481518018980085439510020245603299796987787026747085068246942823483155176744176984940588090328219055261726881663762636064519564504530342638845828290148354407250458132172073751256948957492049546255729177214683016783611250043627056236160532218032551770132382409941214538875688889836254147167095679585095592933136757110517310929331115520731839126680436646840096258000192002957516677617442976797467214810171121101193424094289620379664018211608816183365917541288808799814022860741643966463653081179010980493172510299974966934123887257030154911221451270828480795653112311577071572889270495122430941642346728707912937712029923078926454526311867287560092941833856229882667302754302199642064236052165354325804530898689379390996818003875460560630973033843039733127758595531547058058685605627269981349800993306454972781056201486033523543726104638829295418452731011945348944226383300112907389544874605362315758175482045942424045175555053576214273219909652720360148138441970437684909762723167423625601562427925003482830522566935351037596166953501925896226538370435559220633718295971706728712339899286181647926751020146565992265117699419351479373739070693022307154341520480810492552207121603555460575535033719354032696081265468772433457335111989981309754715592647440894475862809326662955050205889059831968321107725463551633107019599799720777025772991803297749847052492559931491294312543895073996602048895989408887901610561953827815924021997585268776414663325796185115147042984696391503710578409567605819451537087627601685885550

if pineapple ** 3 + strawberry ** 3 == 94 * banana ** 3:
    h = sha256(str(banana).encode()).hexdigest()
    print(f"FCSC}")

# FCSC{2c69e5056f2a80af36c0880a2395472e51b448730a1c5c06b2b0d8e0a3b466b6}


Share a sausage

The weakness is the coefficients are too small, solveable with LLL:

from Crypto.Cipher import AES
from out import data

P = 931620319462745440509259849070939082848977
shares = data['shares']
iv = bytes.fromhex(data['iv'])
flag_enc = bytes.fromhex(data['flag_enc'])

load('https://gist.githubusercontent.com/Connor-McCartney/952583ecac836f843f50b785c7cb283d/raw/5718ebd8c9b4f9a549746094877a97e7796752eb/solvelinmod.py')
ps = [var(f"p_{i}") for i in range(17)]
eqs = []
for x, y in shares:
    xx = [x**j for j in range(17)]
    eqs.append((y == sum(x_*p_ for x_, p_ in zip(xx, ps)), P))
bounds = {p:2**128 for p in ps}
sol = solve_linear_mod(eqs, bounds)
recovered_secret = bytes.fromhex(f"{list(sol.values())[0]:02x}")

E = AES.new(recovered_secret, mode = AES.MODE_CBC, iv = iv)
flag = E.decrypt(flag_enc).decode().strip()
print(flag)