過程が大事

学んだことを適当にアウトプットします

picoCTF Writeup (Web問)その3

dont-use-client-side(100pts)

Description

Can you break into this super secure portal? https://jupiter.challenges.picoctf.org/problem/29835/ (link) or http://jupiter.challenges.picoctf.org:29835

入力フォームが1つのみ
とりあえずdevtoolsをみるとJSで発見

string.substring(indexStart, indexEnd)のため、並び替えてflagを入手

It is my Birthday(100pts)

Description

I sent out 2 invitations to all of my friends for my birthday! I'll know if they get stolen because the two invites look similar, and they even have the same md5 hash, but they are slightly different! You wouldn't believe how long it took me to find a collision. Anyway, see if you're invited by submitting 2 PDFs to my website. http://mercury.picoctf.net:20277/

pdfファイルを2つ入れるようになっている

問題文より同じmd5ハッシュを持つ異なる2つのpdfファイルが必要みたい
ハッシュ値は128ビット(2128通り)で有限であるから同じmd5ハッシュを持つファイルは作れるが、流石に自分で用意するのは無理なので検索
md5で衝突するやつのデモを見つけた
https://www.mscs.dal.ca/~selinger/md5collision/

ファイルを入手してpdfに変換してUploadするとflagが得られた

Who are you?(100pts)

Description

Let me in. Let me iiiiiiinnnnnnnnnnnnnnnnnnnn http://mercury.picoctf.net:52362/

PicoBrowserの公式ユーザじゃないとこのサイトは使えないみたい
何かめっちゃ煽られてる

UserAgentを変えると、今度は他のサイトから閲覧したユーザは信用できないと言われた

Refererヘッダーの設定をすればいけそう
Refererヘッダーは、UserAgentがリクエストを生成するのに使用したページのアドレスを含む HTTP ヘッダーのこと
curlRefererヘッダーの設定をしてリクエストをする

curl -A "PicoBrowser" -e "http://mercury.picoctf.net:52362/" http://mercury.picoctf.net:52362/   

レスポンスをみると、サイトは2018年のみ機能すると言われた

Dateヘッダーを設定して日付を2018年に指定

curl -A "PicoBrowser" -e "http://mercury.picoctf.net:52362/" -H "Date: Tue, 01 May 2018 00:00:00 GMT" http://mercury.picoctf.net:52362/

ラッキング可能なユーザは信用できないと言われた

DNT (Do Not Track) ヘッダーを追加してトラッキングを拒否

curl -A "PicoBrowser" -e "http://mercury.picoctf.net:52362/" -H "Date: Tue, 01 May 2018 00:00:00 GMT" -H "DNT: 1" http://mercury.picoctf.net:52362/

今度はスウェーデンの人のみが見れるとでた

ipアドレススウェーデンに設定

curl -A "PicoBrowser" -e "http://mercury.picoctf.net:52362/" -H "Date: Tue, 01 May 2018 00:00:00 GMT" -H "DNT: 1" -H "X-Forwarded-For: 2.65.255.255" http://mercury.picoctf.net:52362/

スウェーデン語を話せと言われた

スウェーデン語に設定

curl -A "PicoBrowser" -e "http://mercury.picoctf.net:52362/" -H "Date: Tue, 01 May 2018 00:00:00 GMT" -H "DNT: 1" -H "X-Forwarded-For: 2.65.255.255" -H "Accept-Language: sv" http://mercury.picoctf.net:52362/

フラグを入手できた

login(100pts)

Description

My dog-sitter's brother made this website but I can't get in; can you help? login.mars.picoctf.net

ログインフォームがあり、devtoolsでJSを見ると、気になるのを見つけた

(async() => {
  await new Promise((e => window.addEventListener("load", e))), document.querySelector("form").addEventListener("submit", (e => {
    e.preventDefault();
    const r = {
        u: "input[name=username]",
        p: "input[name=password]"
      },
      t = {};
    for (const e in r) t[e] = btoa(document.querySelector(r[e]).value).replace(/=/g, "");
    return "YWRtaW4" !== t.u ? alert("Incorrect Username") : "cGljb0NURns1M3J2M3JfNTNydjNyXzUzcnYzcl81M3J2M3JfNTNydjNyfQ" !== t.p ? alert("Incorrect Password") : void alert(`Correct Password! Your flag is ${atob(t.p)}.`)
  }))
})();

JSコードからbtoa関数を使用してBase64エンコードしていることがわかる。そのため、YWRtaW4の末尾に=をつけてデコードしてみるとadminだとわかる

同様にcGljb0NURns1M3J2M3JfNTNydjNyXzUzcnYzcl81M3J2M3JfNTNydjNyfQをデコードすると、flagが入手できた

Includes(100pts)

Description

Can you get the flag? Go to this website and see what you can discover.

includeの話が書いてある
Say helloボタンを押すとこれが出る

JSを見るとなんかあった
flagっぽい

CSSも見るとあった

上記の2つを組み合わせたらflagになった。
HTMLでは、JavaScriptCSSをincludeしているから調べろってことだったのかな?

Inspect HTML(100pts)

Description

Can you get the flag? Go to this website and see what you can discover.

アクセスしたらなんかよくわからないこと書いてある

devtoolsで見たらflagを発見

Local Authority(100pts)

Description

Can you get the flag? Go to this website and see what you can discover.

ログインフォームがあり、適当な入力をしてLoginボタンを押し、devtoolsのnetworksタブで挙動を見ると、secure.jsという気になるファイルを見つけた

secure.jsの中を見ると、正規のusernameとpassを見つけた。
これをログインフォームに入力したらflagを入手できた