[Webhacking.kr] 20번

2017. 10. 12. 22:26
time limit : 2
nickname
comment
code

do not programming!
this is javascript challenge


문제다.


소스를 보자.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<html>
<head>
<title>Challenge 20</title>
<style type="text/css">
body { background:black; color:white; font-size:10pt; }
input { background:silver; color:black; font-size:9pt; }
</style>
</head>
<body>
<center><font size=2>time limit : 2</font></center>
<form name=lv5frm method=post>
<table border=0>
<tr><td>nickname</td><td><input type=text name=id size=10 maxlength=10></td></tr>
<tr><td>comment</td><td><input type=text name=cmt size=50 maxlength=50></td></tr>
<tr><td>code</td><td><input type=text name=hack><input type=button name=attackme value="hlajbgotso"
 style=border:0;background=lightgreen onmouseover=this.style.font=size=30 onmouseout=this.style.font=size=15></td></tr>
<tr><td><input type=button value="Submit" onclick=ck()></td><td><input type=reset></td></tr>
</table>
<script>
function ck()
{
 
if(lv5frm.id.value=="") { lv5frm.id.focus(); return; }
if(lv5frm.cmt.value=="") { lv5frm.cmt.focus(); return; }
if(lv5frm.hack.value=="") { lv5frm.hack.focus(); return; }
if(lv5frm.hack.value!=lv5frm.attackme.value) { lv5frm.hack.focus(); return; }
 
lv5frm.submit();
 
}
</script>
 
<br>
 
do not programming!<br>
 
this is javascript challenge
 
</body>
</html>
 
cs


POST로 nickname comment code를 전송하는 형식같다.


form의 이름은 lv5frm이다. code 라는 부분이 중요해 보인다. name=hack이고 옆에 있는 hlajbgotso값을 가진 버튼은 name=attackme이다.


아... 방금 알았는데 저 옆에 있는 버튼 attackme의 값은 계속해서 바뀐다.(새로고침할때마다 변함)


Submit 버튼을 누르면 ck()가 작동한다.


function ck()
{
 
if(lv5frm.id.value=="") { lv5frm.id.focus(); return; }
if(lv5frm.cmt.value=="") { lv5frm.cmt.focus(); return; }
if(lv5frm.hack.value=="") { lv5frm.hack.focus(); return; }
if(lv5frm.hack.value!=lv5frm.attackme.value) { lv5frm.hack.focus(); return; }
 
lv5frm.submit();
 
}



nickname, comment, hack 값이 없다면 focus로 커서를 입력칸으로 이동하고 return 되어 함수를 빠져나온다.

또 hack의 값과 attackme의 값이 동일하지않으면 focus후 함수를 빠져나온다.


이제 어떻게 동작하는지 알았으니... 적당히 입력한 후 (물론 code값(hack)과 그 옆에 랜덤으로 변하는 값(attackme)과 같게 해야한다.)


Submit해보았다. Wrong이 떳다.


... 흠... 일단 문제는 do not programming과 javascript challenge라고 한다.


위에 적힌 time limit : 2 가... 2초안에 입력해야한다는 것을 뜻하는 것 같다. 왜냐하면 늦게하면 Wrong이 나온다.

(왜 2초라 생각하였냐면... 그냥 크롬 개발자 열어놓고 Console에 lv5frm.submit();만 보내면 Wrong은 뜨지않는다.)


그래서 아래와 같이 미리 준비해둔 자바스크립트문을 적어서 복사해뒀다가...


새로고침하고 개발자도구 Console을 통해서 보내보았다.


1
2
3
4
lv5frm.id.value="sherlock"
lv5frm.cmt.value="Clear~~~"
lv5frm.hack.value=lv5frm.attackme.value
lv5frm.submit();
cs


결과는 성공~ 2초안에 성공하는게 맞았나 보다.






You have cleared the 20 problems.

Score + 200




+ Recent posts