{"id":1155,"date":"2025-11-07T16:09:36","date_gmt":"2025-11-07T08:09:36","guid":{"rendered":"https:\/\/www.youvii.site\/?p=1155"},"modified":"2025-11-07T16:09:36","modified_gmt":"2025-11-07T08:09:36","slug":"buuctf-cryptorsarsa","status":"publish","type":"post","link":"https:\/\/www.youvii.site\/index.php\/archives\/buuctf-cryptorsarsa","title":{"rendered":"BUUCTF-Crypto\uff1arsarsa"},"content":{"rendered":"<h1>rsarsa<\/h1>\n<p>\u9898\u76ee\uff1a<\/p>\n<blockquote>\n<p>Math is cool! Use the RSA algorithm to decode the secret message, c, p, q, and e are parameters for the RSA algorithm. Use RSA to find the secret message<br \/>\n\u6570\u5b66\u5f88\u9177!\u4f7f\u7528RSA\u7b97\u6cd5\u89e3\u7801\u8fd9\u4efd\u5bc6\u4fe1\uff0cc\u3001p\u3001q\u3001e\u90fd\u662fRSA\u7b97\u6cd5\u7684\u53c2\u6570\uff0c\u4f7f\u7528RSA\u627e\u5230\u5bc6\u94a5\uff01<\/p>\n<\/blockquote>\n<p>p =  9648423029010515676590551740010426534945737639235739800643989352039852507298491399561035009163427050370107570733633350911691280297777160200625281665378483<br \/>\nq =  11874843837980297032092405848653656852760910154543380907650040190704283358909208578251063047732443992230647903887510065547947313543299303261986053486569407<br \/>\ne =  65537<br \/>\nc =  83208298995174604174773590298203639360540024871256126892889661345742403314929861939100492666605647316646576486526217457006376842280869728581726746401583705899941768214138742259689334840735633553053887641847651173776251820293087212885670180367406807406765923638973161375817392737747832762751690104423869019034<\/p>\n<p>(N,d)\u662f\u79c1\u94a5\uff0c(N,e)\u662f\u516c\u94a5\uff0c\u516c\u94a5\u52a0\u5bc6\uff0c\u79c1\u94a5\u89e3\u5bc6\uff0cc\u662f\u5bc6\u6587\uff0c\u6c42\u660e\u6587<\/p>\n<p>p , q \u662f\u4efb\u9009\u5927\u7d20\u6570<\/p>\n<p>n=p<em>q   <strong>\u03c6(n)<\/strong> =(p-1)<\/em>(q-1)<\/p>\n<p>e*d=1mod<strong>\u03c6(n)     (e*d)mod\u03c6(n)=1<\/strong><\/p>\n<p><strong>\u52a0\u5bc6\uff1aSig(x)=x^e mod n<\/strong><\/p>\n<p><strong>\u89e3\u5bc6\uff1ax=Sig(x)^d mod n<\/strong><\/p>\n<p>\u7b2c\u4e00\u6b65\uff1a\u6c42n\uff0cn=p*q<\/p>\n<p>N=114573516752272714750064227635008832737477859608443481000717283425702025029279291376859256856603741797722497252841363753834114679306784379319341824813349417007577541466886971550474580368413974382926969910999462429631003527365143148445405716553105750338796691010126879918594076915709977585368841428779903869581<\/p>\n<p>\u7b2c\u4e8c\u6b65\uff1a\u6c42\u03c6(n)\uff1a\u03c6(n) = (p &#8211; 1) * (q &#8211; 1)<\/p>\n<p>\u03c6=114573516752272714750064227635008832737477859608443481000717283425702025029279291376859256856603741797722497252841363753834114679306784379319341824813349395484310674476074262867516991704330586676279176131878754135601460783229276940745427904455048854467754090254652258775177617277116136508905378817444751921692<\/p>\n<p>\u7b2c\u4e09\u6b65\uff1a\u6c42\u79c1\u94a5\u6307\u6570\uff08d\uff09\uff1a(e*d)mod\u03c6(n)=1<\/p>\n<p>d=56632047571190660567520341028861194862411428416862507034762587229995138605649836960220619903456392752115943299335385163216233744624623848874235303309636393446736347238627793022725260986466957974753004129210680401432377444984195145009801967391196615524488853620232925992387563270746297909112117451398527453977<\/p>\n<p>\u7b2c\u56db\u6b65\uff1a\u89e3\u5bc6\u6d88\u606f\uff08M\uff09\uff1aM = c^d mod n<\/p>\n<p>m=5577446633554466577768879988<\/p>\n<pre class=\"prettyprint linenums\" ><code class=\"language-python\"># RSA\u89e3\u5bc6\np = 9648423029010515676590551740010426534945737639235739800643989352039852507298491399561035009163427050370107570733633350911691280297777160200625281665378483\nq = 11874843837980297032092405848653656852760910154543380907650040190704283358909208578251063047732443992230647903887510065547947313543299303261986053486569407\ne = 65537\nc = 83208298995174604174773590298203639360540024871256126892889661345742403314929861939100492666605647316646576486526217457006376842280869728581726746401583705899941768214138742259689334840735633553053887641847651173776251820293087212885670180367406807406765923638973161375817392737747832762751690104423869019034\n\n# \u8ba1\u7b97 \u6a21\u6570n \u548c \u6b27\u62c9\u51fd\u6570\u03d5(n)\nn = p * q\n\u03d5n = (p - 1) * (q - 1)\n\n# \u8ba1\u7b97\u79c1\u94a5d\uff0c\u6ee1\u8db3(d*e) mod \u03d5(n)=1\nd = pow(e, -1, \u03d5n)\n\n# \u89e3\u5bc6\u5f97\u5230\u660e\u6587m ,\u6ee1\u8db3m=c^d mod n\nm = pow(c, d, n)\n\n# \u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\u5e76\u751f\u6210Flag\nsecret_message = str(m)\nflag = f\"flag{{{secret_message}}}\"\n\nprint(\"\u89e3\u5bc6\u540e\u7684Flag\u4e3a\uff1a\", flag)\n<\/code><\/pre>\n<p>flag{5577446633554466577768879988}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>rsarsa \u9898\u76ee\uff1a Math is cool! Use the RSA algorithm to decode the secret message, c, p, q, and e are parameters for the RSA algorithm. Use RSA to find the secret message \u6570\u5b66\u5f88\u9177!\u4f7f\u7528RSA\u7b97\u6cd5\u89e3\u7801\u8fd9\u4efd\u5bc6\u4fe1\uff0cc\u3001p\u3001q\u3001e\u90fd\u662fRSA\u7b97\u6cd5\u7684\u53c2 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[126,114,113],"tags":[44,56,112],"class_list":["post-1155","post","type-post","status-publish","format-standard","hentry","category-buuctf","category-crypto","category-ctf","tag-44","tag-ctf","tag-crypto"],"_links":{"self":[{"href":"https:\/\/www.youvii.site\/index.php\/wp-json\/wp\/v2\/posts\/1155","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.youvii.site\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.youvii.site\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.youvii.site\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.youvii.site\/index.php\/wp-json\/wp\/v2\/comments?post=1155"}],"version-history":[{"count":0,"href":"https:\/\/www.youvii.site\/index.php\/wp-json\/wp\/v2\/posts\/1155\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.youvii.site\/index.php\/wp-json\/wp\/v2\/media?parent=1155"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.youvii.site\/index.php\/wp-json\/wp\/v2\/categories?post=1155"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.youvii.site\/index.php\/wp-json\/wp\/v2\/tags?post=1155"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}