on
Challenge(old) - Challenge 16번 문제풀이
Challenge(old) - Challenge 16번 문제풀이
문제
문제에 처음 들어가면 별 3개가 보인다.
키보드 입력시
키보드의 다양한 키들을 눌러보면 위와 같이 여러 개의 별들이 찍힌다. 이제 소스코드 분석을 해보자!
Challenge 16 * document.body.innerHTML+="*"; function mv(cd){ kk(star.style.left-50,star.style.top-50); if(cd==100) star.style.left=parseInt(star.style.left+0,10)+50+"px"; if(cd==97) star.style.left=parseInt(star.style.left+0,10)-50+"px"; if(cd==119) star.style.top=parseInt(star.style.top+0,10)-50+"px"; if(cd==115) star.style.top=parseInt(star.style.top+0,10)+50+"px"; if(cd==124) location.href=String.fromCharCode(cd)+".php"; // do it! } function kk(x,y){ rndc=Math.floor(Math.random()*9000000); document.body.innerHTML+="*"; }
body 부분에서 onkeypress로, 키를 누를 때마다 mv 함수를 호출함을 알려주고 있다.
function mv()를 해석해보면, kk()는 그냥 별을 그려주는 함수정도인 것 같다.
그리고 cd가 100, 97, 119, 115일 때, 별의 위치가 바뀌고, 124일 때 정답 페이지(.php)로 넘어가게 된다. 하지만 키보드 입력은 숫자가 아니라 영문자를 통해 입력된다. 때문에 해당 숫자가 의미하는 것은 아스키코드 기준일 것으로 예상된다.
ASCII Code
아스키코드표를 확인해보면,
100 == d,
97 == a,
119 == w,
115 == s,
124 == | (파이프)
를 의미한다.
정답!
문제 페이지로 돌아가서 |(파이프)를 입력하면 정답처리가 된다!
from http://liz09045.tistory.com/126 by ccl(A) rewrite - 2021-10-06 09:26:51