1 2 3 You get more information! [main.py] [output.txt]
Writeup Both challenges didn’t really have a description, and each had a main.py
and output.txt
file attached. I suck at math so I honestly just threw the info given in the main.py
file into z3 script and it solved it for me. Just putting these solves here for future reference.
main.py :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 from Crypto.Util.number import *from flag import flagp = getPrime(512 ) q = getPrime(512 ) n = p*q p = p + q e = 0x10001 extra_information = p + q ptxt = bytes_to_long(flag) c = pow (ptxt, e, n) with open ('output.txt' , 'w' ) as f: f.write(f"n: {n} \nc: {c} \ne: {e} \nextra_information: {extra_information} " )
output.txt :
1 2 3 4 n: 83790217241770949930785127822292134633736157973099853931383028198485119939022553589863171712515159590920355561620948287649289302675837892832944404211978967792836179441682795846147312001618564075776280810972021418434978269714364099297666710830717154344277019791039237445921454207967552782769647647208575607201 c: 55170985485931992412061493588380213138061989158987480264288581679930785576529127257790549531229734149688212171710561151529495719876972293968746590202214939126736042529012383384602168155329599794302309463019364103314820346709676184132071708770466649702573831970710420398772142142828226424536566463017178086577 e: 65537 extra_information: 26565552874478429895594150715835574472819014534271940714512961970223616824812349678207505829777946867252164956116701692701674023296773659395833735044077013
solve.py :
1 2 3 4 5 6 7 8 9 10 11 12 13 from z3 import *p = Int('p' ) q = Int('q' ) s = Solver() s.add(p * q == 83790217241770949930785127822292134633736157973099853931383028198485119939022553589863171712515159590920355561620948287649289302675837892832944404211978967792836179441682795846147312001618564075776280810972021418434978269714364099297666710830717154344277019791039237445921454207967552782769647647208575607201 ) s.add(p + q + q == 26565552874478429895594150715835574472819014534271940714512961970223616824812349678207505829777946867252164956116701692701674023296773659395833735044077013 ) print (s.check())print (s.model())
Output:
1 2 [q = 8128979845892982561867353232387733688040820165501281055994560204992985831326225951788922087412585314864187432126945670029964128100746510232539453211798711, p = 10307593182692464771859444251060107096737374203269378602523841560237645162159897774629661654952776237523790091862810352641745767095280638930754828620479591]
Flag: amateursCTF{harder_than_3_operations?!?!!}
(Extra Information 1)
main.py :
1 2 3 4 5 6 7 8 9 10 11 12 13 from Crypto.Util.number import *from flag import flagp = getPrime(512 ) q = getPrime(512 ) n = p*q e = 0x10001 extra_information = (n**2 )*(p**3 + 5 *(p+1 )**2 ) + 5 *n*q + q**2 ptxt = bytes_to_long(flag) c = pow (ptxt, e, n) with open ('output.txt' , 'w' ) as f: f.write(f"n: {n} \nc: {c} \ne: {e} \nextra_information: {extra_information} " )
output.txt :
1 2 3 4 n: 95593382112797270045497836514999308524326160650345266525670495575191979116591752182138270308274446464071024826510473429700676303637674960212123982700153540490805215151070356646141514736282385755143090035980011032465519861526291865888128545478530962058792257703950616556136479933021373472378679162332202365371 c: 92084942302809419329882275131365664619817865820237979575321652348851871468885232665120732298048355621943772250718055278615366362227084559410831820721620242260588398786014654743749734106956509345330468686120026908164376320923131751798117799981744551407234489862207435686504148347452579942637697333568788391594 e: 65537 extra_information: 18247071175606431398122118602371784578875472790915317892207044424588309397797319375039984309368393267673885302107217184699052743790470091033147110959310433418937324145720036262540098007724458652548486534453030546582214242131458903058169536052488501597969216020092796160475487905223265691093061136660574497410399108890645909789835984721231354187679269066357591297035974333220513134895660609801438138623213711900681512310067292949714127564635579383633589101296120704659647911638787823818973909534106275908594589830353183557722172234952579827423906720754070119865452363350814918812923981729393142874903734028229195885438296963982680724071663211427931391032589901737528717167662646147224323491202696402122261699504048973334902281462240308032014697804531871922566779026958815207465755155123070196922127199447785648102152027431894178737946151518726929361221425189695069653652163012000609320105988830299015364692678902927254273154427301473090465612473379114039284029813071586214536353994345527805408387636097772645156970939979500155578289301143563369142329343932852167241705090287661795
solve.py :
1 2 3 4 5 6 7 8 9 10 11 12 13 from z3 import *p = Int('p' ) q = Int('q' ) s = Solver() s.add(p * q == 95593382112797270045497836514999308524326160650345266525670495575191979116591752182138270308274446464071024826510473429700676303637674960212123982700153540490805215151070356646141514736282385755143090035980011032465519861526291865888128545478530962058792257703950616556136479933021373472378679162332202365371 ) s.add((95593382112797270045497836514999308524326160650345266525670495575191979116591752182138270308274446464071024826510473429700676303637674960212123982700153540490805215151070356646141514736282385755143090035980011032465519861526291865888128545478530962058792257703950616556136479933021373472378679162332202365371 **2 )*(p**3 + 5 *(p+1 )**2 ) + 5 *95593382112797270045497836514999308524326160650345266525670495575191979116591752182138270308274446464071024826510473429700676303637674960212123982700153540490805215151070356646141514736282385755143090035980011032465519861526291865888128545478530962058792257703950616556136479933021373472378679162332202365371 *q + q**2 == 18247071175606431398122118602371784578875472790915317892207044424588309397797319375039984309368393267673885302107217184699052743790470091033147110959310433418937324145720036262540098007724458652548486534453030546582214242131458903058169536052488501597969216020092796160475487905223265691093061136660574497410399108890645909789835984721231354187679269066357591297035974333220513134895660609801438138623213711900681512310067292949714127564635579383633589101296120704659647911638787823818973909534106275908594589830353183557722172234952579827423906720754070119865452363350814918812923981729393142874903734028229195885438296963982680724071663211427931391032589901737528717167662646147224323491202696402122261699504048973334902281462240308032014697804531871922566779026958815207465755155123070196922127199447785648102152027431894178737946151518726929361221425189695069653652163012000609320105988830299015364692678902927254273154427301473090465612473379114039284029813071586214536353994345527805408387636097772645156970939979500155578289301143563369142329343932852167241705090287661795 ) print (s.check())print (s.model())
Output:
1 2 3 sat [p = 12592515782077404137849236994955837609500154464782855076585955501637937872493619036975469814859697874798733737517472127306855726944300236711447248402640349, q = 7591285472030363593819309149475285775894683777302616308552541051471117604695830085885971123084425024738819800112718432254917427153283662301475561286492279]
Flag: amateursCTF{omg_it's_my_favorite_epic_thing_where_it_looks_like_a_binomial!!}
(Extra Information 2)