웹 해킹/Webhacking.kr

[Webhacking.kr] old-16

L3m0n S0ju 2021. 9. 4. 22:21

 

 

문제서버에 접속하면 별 2개가 보인다. 자바스크립트 코드는 아래와 같다.

 

 

<html><head>
<title>Challenge 16</title>
</head><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><font color="yellow" id="aa" style="position:relative;left:0;top:0">*</font>




<font color="#6479971" id="aa" style="position:relative;left:1;top:1" onmouseover="this.innerHTML=''">*</font></body><whale-quicksearch translate="no"></whale-quicksearch></html>

 

 

 


코드를 보면 onkeypress 함수를 통해 키보드를 누르면 mv 함수로 이벤트가 전달되는데 아래 조건문을 만족하려면 아스키코드 값이 124인 |를 입력하면 플래그를 획득할 수 있다.

 

  if(cd==124) location.href=String.fromCharCode(cd)+".php"; // do it!

 

 

 

 


플래그