ペンギン技術 blog

CTFのWriteupなどを記載していこうと思います

setodaNoteCTF Writeup [Web]

Web

Body

Webページにアクセス
ソースを見るとコメントにフラグがある
view-source:https://ctf.setodanote.net/web001/

<p>特に指定がない限りフラグは flag{<!-- *** flag{Section_9} *** -->} という形式をとります。</p>

header

Webページにアクセス
HTTPレスポンスヘッダを見る

x-setodanotectf-flag: flag{xxxxx}

puni_puni

日本語ドメインとかのやつ

Punycode変換・逆変換
https://rakko.tools/tools/5/

xn--q6jaaaaaa08db0x8nc9t1b8fsviei84atb4i0lc
xn--q6jaaaaa03dpd4mb3jc5rpa0g9jpk07acadc.
xn--q6jylla3va3j6c8138a8eptvb303cxv4ft3o4ue63a
xn--v8ja6aj2a3cri3ag4a2r6cx2a1rkk1272c7j4ajd4bmf0kjhg6rb.
xn--q6j6gav1a0b2e1bh1ac2cl29ad7728kdjen6cz80dju6bqexchl9gel8b.
フラグは、さん、さん、ピー、ユー、エヌ、ワイ、
シー、オー、ディー、イー、よん、よん、です
カタカナ表記は半角英小文字に、
ひらがな表記は半角数字にしたものがフラグです
なお、読点は区切り文字なので取り除いてください

Mistake

<!-- Webserver directory index? -->というヒントがある

https://ctf.setodanote.net/web003/images/ にアクセスすると、ファイル一覧が見える

pic_flag_is_here.txtがあるので開く

tkys_royale

https://ctf.setodanote.net/web005/#

Login formがあるのでSQLインジェクションを試す。

ユーザー名に「aa」パスワードに「' or 1=1--」でエラー

Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''' at line 1

Query: SELECT * From basic_accounts where username='aa' and password='' or 1=1;--'

ユーザー名に「aa」パスワードに「' or 1=1#」で成功

Welcome admin!!
flag{xxxxx}

Estimated

https://ctf.setodanote.net/web006/20210603.html

お詫び:昨日の記事について
JUNE 3, 2021
昨日の記事について、掲載していた画像に公開すべきではない情報が含まれていたため当該記事を削除いたしました。

皆様にはご心配、ご迷惑をおかけしてしまい申し訳ありません。

↓ 6月2日の画像を探す問題か
Web魚拓などでページを探したが見つからず

画像自体のURLが推測可能なのでアクセスしてみる

https://ctf.setodanote.net/web006/images/20210602001b.jpg
ブログ記事は削除したが、画像自体はアップロードされたままという問題

画像中にフラグが書いてあった

Mx.Flag

https://ctf.setodanote.net/web007/
にアクセスしてフラグを探す

HTMLソースを見てみる

    <link rel="icon" type="image/png" href="images/favicon.png">
    <link rel="stylesheet" href="assets/css/style.css">

CSSには不審点は何もない
シンプルなサイトなのにfaviconがあるのは怪しい

ブラウザメニューでの「画像を保存」もグレーアウトされている
HTMLソース画面からfaviconをダウンロード

ペイントでは開けないファイル→画像ではない
テキストエディタで開いたらフラグがあった

// flag{xxxxx}
console.table({place: "favicon.png", png: "false", flag: "true", Look: "me"});

Redirect

https://ctf.setodanote.net/web004/#
からフラグを探す ソースを見ると以下スクリプトが怪しい

<script>!function(){var ref = document.referrer;var domain = ref.match(/^http([s]?):\/\/([a-zA-Z0-9-_\.]+)(:[0-9]+)?/)[2];if(domain == "www.google.com" || domain == "www.google.co.jp" ){location.href = atob('aHR0cHM6Ly9jdGYuc2V0b2Rhbm90ZS5uZXQvd2ViMDA0L2JXRnNhMmwwLmh0bWw=');}}();</script>

atobの中身をbase64 decodeするとURLがでてくる
ブラウザからアクセスするとリダイレクトされるのでcurlでアクセスする

$ curl https://ctf.setodanote.net/web004/bWFsa2l0.html
<!DOCTYPE HTML>
<html>
  <head>
    <title>start</title>
    <noscript>
      <meta http-equiv=refresh content="1; URL=https://ctf.setodanote.net/web004/noscript.html">
    </noscript>
    <script>
      !function() {
        var params = new URL(window.location.href).searchParams;
        if(Array.from(params).length > 0){
          location.href = 'https://ctf.setodanote.net/web004/bm9mbGFn/?'+params;
        }else{
          location.href = 'https://ctf.setodanote.net/web004/bWFsa2l0.html?callback=wantFlag&data1=2045&data2=0907&data3=BiancoRoja&data4=1704067200';
        }
      }();
    </script>
  </head>
  <body>
    <p>Find out the flag.</p>
  </body>
</html>

同様に、何度かたどっていく

curl https://ctf.setodanote.net/web004/bWFsa2l0.html
curl https://ctf.setodanote.net/web004/bm9mbGFn/?
curl https://ctf.setodanote.net/web004/bmV4dG5leHQ/?
curl https://ctf.setodanote.net/web004/b25lLXR3by10aHJlZQ/?

パラメータがあれば進めそうなページにたどり着く

$ curl https://ctf.setodanote.net/web004/dGFjaGlrb21hX2thd2FpaV95b25l/?
<html>
  <head>
    <title>GO!GO!GO!</title>
    <noscript>
      <meta http-equiv=refresh content="1; URL=https://ctf.setodanote.net/web004/noscript.html">
    </noscript>
    <script>
      !function() {
        var params = new URL(window.location.href).searchParams;
        var callback = params.get('callback');
        var data1    = params.get('data1');
        var data2    = params.get('data2');
        var data3    = params.get('data3');
        var data4    = params.get('data4');
        if (callback == 'getFlag' && data1 == "2045" && data2 =="0907" && data3 == "BiancoRoja" && data4 =="1704067200") {
          location.href = 'https://noisy-king-d0da.setodanote.net/?'+params;
        }else{
          location.href = 'https://ctf.setodanote.net/web004/ZGFtbXlmbGFn/hint.html?'+params;
        }
      }();
      </script>
  </head>
  <body>
  <p>Yes! Go to next.</p>
  </body>
</html>

以下のように指定してアクセス

$ curl 'https://noisy-king-d0da.setodanote.net/?callback=getFlag&data1=2045&data2=0907&data3=BiancoRoja&data4=1704067200'
<!DOCTYPE html>
<body>
  <h1>Nice work!!</h1>
  <p>flag{xxxxx}</p>
</body>

フラグが返ってきた