사이트에 접속했더니 큰 별(*)과 작은 별(*) 두 개가 있었다.
뭔가 싶어서 키보드를 아무거나 눌러봤는데 별이 움직였다.
w키를 누르면 위로, a키를 누르면 왼쪽으로, s키를 누르면 아래로, d키를 누르면 오른쪽으로 움직이며 다른 키를 입력할 시 작은 별만 늘어나고 별 다른 건 없었다. 자세히 알기 위해 Ctrl + u 를 입력해 html 소스 코드를 확인해 보았다. 소스는 다음과 같다.
<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>
코드를 보던 중 if문 다섯 개가 눈에 띄었다. 다섯 개의 if문을 보면, (cd=숫자)로 되어 있는 부분을 확인할 수 있다. 이 숫자들은 문자를 숫자로 변환하는 아스키 코드로 보였다. 우선 첫 번째 숫자인 '100'은 문자로 변환할 시 'd'를 뜻하며, 두 번째 '97'은 'a', 세 번째 '119'는 'w', 네 번째 '115'는 's', 마지막 다섯 번째 숫자인 '124'는 '|'를 뜻한다는 것을 알 수 있다.
- 100 -> d
- 97 -> a
- 119 -> w
- 115 -> s
- 124 -> |
이렇게 알고 그 다음으로 코드를 쭉 읽어 보면 4번째까지는
star.style.left=parseInt(star.style.left/top+0,10)+/-50+"px"
의 형태를 가짐을 알 수 있다. 그러나 마지막 코드만
location.href=String.fromCharCode(cd)+".php"; // do it!
라 되어 있고, 심지어 마지막에는 'do it'이라는 문장을 볼 수 있다.
때문에 다시 사이트를 돌아가서 마지막 코드에서 알려 준 '|' 를 입력했더니
문제를 해결할 수 있었다!
'워게임 스터디' 카테고리의 다른 글
[241104][SuNiNaTaS] level 1 (0) | 2024.11.04 |
---|---|
[241006][webhacking] old-01 (0) | 2024.10.06 |
[241006][webhacking] old-17 (0) | 2024.10.06 |
[241001][webhacking] old-14 (0) | 2024.10.01 |
[240925] 드림핵 비기너 정리 (6) | 2024.09.25 |