بتل کد Battle Codeدارد باز می‌شود…

Flag 4: Client-Side Check چالش 4 از جلسه‌ی 61، متوسط

این صفحه رمز را در جاوااسکریپت چک می‌کند و پرچم را با آن می‌سازد. آن را نباید بشکنی؛ باید درستش کنی: چک رمز و پرچم را از صفحه بردار و به تابع serverCheck(pw) بسپار (شبیه‌ساز سرور که از قبل هست و برای رمز درست پرچم را برمی‌گرداند، وگرنه null). متن #out برای رمز درست باید پرچم و برای رمز غلط nope باشد. در سورس نهایی نباید s3cret یا BC{ باشد.

<input id="pw" placeholder="password">
<button id="go" onclick="check()">Check</button>
<p id="out">-</p>

<script>
const SECRET = "s3cret";                       // bug: the secret is in the page
const FLAG = "BC{check_on_the_server}";        // bug: so is the prize
function serverCheck(pw) {
  // pretend: this runs on the server, where the secret really lives
  return pw === "s" + "3" + "cret" ? "BC{check_on_" + "the_server}" : null;
}
function check() {
  const pw = document.getElementById("pw").value;
  const out = document.getElementById("out");
  if (pw === SECRET) out.textContent = FLAG; else out.textContent = "nope";
}
</script>

راهنما و جواب این چالش · برگشت به درس جلسه‌ی 61: CTF وب ۱: معماها · چالش بعدی: Flag 5: The Trusting Cookie

بیشتر بخوان: پایتون چیست؟ تاریخچه، کاربردها و راه شروع