Wargame 풀이/webhacking.kr (웹해킹)
old - 16
전재윤_
2020. 8. 16. 21:07
source code
<html>
<head>
<title>Challenge 16</title>
<body bgcolor=black onload=kk(1,1) onkeypress=mv(event.keyCode)>
<font color=silver id=c></font>
<font color=yellow size=100 style=position:relative id=star>*</font>
<script>
document.body.innerHTML+="<font color=yellow id=aa style=position:relative;left:0;top:0>*</font>";
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+="<font color=#"+rndc+" id=aa style=position:relative;
left:"+x+";top:"+y+" onmouseover=this.innerHTML=''>*</font>";
}
</script>
</body>
</html>
우리가 주목해야 할 부분은 onkeypress
onkeypress란?
키를 눌렀을 때 현재 눌린 문자 키에 반응하며 발생
onkeypress는 아스키코드를 이용한다.
코드에 나와있는 숫자를 아스키 코드로 바꿔 적어보면 아래와 같다
100 = d
97 = a
119 = w
115 = s
124 = | (shift+\)
a,s,d,w를 눌러보면 큰 별이 움직이는 것을 확인할 수 있다.
if(cd==124) location.href=String.fromCharCode(cd)+".php"; // do it!
124의 아스키코드 값 즉, | 를 누르면 해결!!