728x90

[๋ฌธ์ œ]

https://webhacking.kr/challenge/js-1/

 

Challenge 14

 

webhacking.kr


[๋ฌธ์ œ ํ’€์ด]

function ck(){
  var ul=document.URL;
  ul=ul.indexOf(".kr");
  ul=ul*30;
  if(ul==pw.input_pwd.value) { location.href="?"+ul*pw.input_pwd.value; }
  else { alert("Wrong"); }
  return false;
}
  • ๋จผ์ € ๊ฐœ๋ฐœ์ž ๋„๊ตฌ๋ฅผ ์—ด์–ด ์†Œ์Šค์ฝ”๋“œ๋ฅผ ๋ถ„์„ํ•˜๋ ค๊ณ  ํ–ˆ์Šต๋‹ˆ๋‹ค.
  • ์ฝ”๋“œ๋ฅผ ๋ถ„์„ํ•ด ๋ณด๋ฉด ํ˜„์žฌ ํŽ˜์ด์ง€์˜ url์—์„œ .kr์ด ๋‚˜ํƒ€๋‚˜๋Š” ์œ„์น˜๋ฅผ ul์— ์ €์žฅํ•˜๊ณ 
  • ์ด ์œ„์น˜ ๊ฐ’์— 30์„ ๊ณฑํ•ฉ๋‹ˆ๋‹ค.
  • ๊ทธ ๋‹ค์Œ, ์‚ฌ์šฉ์ž๊ฐ€ ์ž…๋ ฅํ•œ ๋น„๋ฐ€๋ฒˆํ˜ธ๊ฐ€ ๊ณ„์‚ฐ๋œ ๊ฐ’๊ณผ ๋™์ผํ•œ์ง€ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค.
    • ๋™์ผํ•˜๋‹ค๋ฉด ํŽ˜์ด์ง€๋ฅผ ํŠน์ • ๊ฐ’์œผ๋กœ ๋ฆฌ๋‹ค์ด๋ ‰ํŠธ ํ•ฉ๋‹ˆ๋‹ค.
    • ๋™์ผํ•˜์ง€ ์•Š๋‹ค๋ฉด ๊ฒฝ๊ณ ์ฐฝ์„ ๋„์›๋‹ˆ๋‹ค.

→ ์ฝ”๋“œ๋ฅผ ๋ถ„์„ํ•œ ๊ฒฐ๊ณผ ๋จผ์ € url์—์„œ .kr์˜ ์œ„์น˜๋ฅผ ์•Œ์•„๋‚ด๊ณ  ๊ทธ ๊ฐ’์— 30์„ ๊ณฑํ•ด์„œ ๊ทธ ๊ฐ’์„ ์ž…๋ ฅํ•˜๋ฉด ๋œ๋‹ค๋Š” ๊ฒƒ์„ ์•Œ๊ฒŒ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

 

  • url์—์„œ .kr์€ 0๋ถ€ํ„ฐ ์‹œ์ž‘ํ•ด์„œ 18๋ฒˆ์งธ ์œ„์น˜ํ•ด ์žˆ๊ณ  ul=18์ด๊ณ  ๊ทธ ๊ฐ’์— 30์„ ๊ณฑํ•˜๋ฉด 540์ด๋ฏ€๋กœ 540์„ ์ž…๋ ฅํ•ด ๋ณด์•˜์Šต๋‹ˆ๋‹ค.
  • ๊ทธ ๊ฒฐ๊ณผ, ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค.

+ Recent posts