jam 블로그

[Hackthissite Javascript] level 7 본문

해킹/웹해킹

[Hackthissite Javascript] level 7

kid1412 2010. 9. 26. 14:44
728x90
해설과 답은 마우스로 글을 긁으면 보여요..

JS Obfuscation. FTW!
=> JS 혼란

풀이 :
스크립트가 다음과 같다.
<script language="javascript">
var _0x4e9d=["\x66\x72\x6F\x6D\x43\x68\x61\x72\x43\x6F\x64\x65","\x77\x72\x69\x74\x65"];document[_0x4e9d[0x1]](String[_0x4e9d[0x0]](0x3c,0x62,0x75,0x74,0x74,0x6f,0x6e,0x20,0x6f,0x6e,0x63,0x6c,0x69,0x63,0x6b,0x3d,0x27,0x6a,0x61,0x76,0x61,
0x73,0x63,0x72,0x69,0x70,0x74,0x3a,0x69,0x66,0x20,0x28,0x64,0x6f,0x63,0x75,0x6d,0x65,0x6e,0x74,0x2e,0x67,0x65,
0x74,0x45,0x6c,0x65,0x6d,0x65,0x6e,0x74,0x42,0x79,0x49,0x64,0x28,0x22,0x70,0x61,0x73,0x73,0x22,0x29,0x2e,0x76,
0x61,0x6c,0x75,0x65,0x3d,0x3d,0x22,0x6a,0x30,0x30,0x77,0x31,0x6e,0x22,0x29,0x7b,0x61,0x6c,0x65,0x72,0x74,0x28,
0x22,0x59,0x6f,0x75,0x20,0x57,0x49,0x4e,0x21,0x22,0x29,0x3b,0x77,0x69,0x6e,0x64,0x6f,0x77,0x2e,0x6c,0x6f,0x63,
0x61,0x74,0x69,0x6f,0x6e,0x20,0x2b,0x3d,0x20,0x22,0x3f,0x6c,0x76,0x6c,0x5f,0x70,0x61,0x73,0x73,0x77,0x6f,0x72,
0x64,0x3d,0x22,0x2b,0x64,0x6f,0x63,0x75,0x6d,0x65,0x6e,0x74,0x2e,0x67,0x65,0x74,0x45,0x6c,0x65,0x6d,0x65,0x6e,
0x74,0x42,0x79,0x49,0x64,0x28,0x22,0x70,0x61,0x73,0x73,0x22,0x29,0x2e,0x76,0x61,0x6c,0x75,0x65,0x7d,0x65,0x6c,
0x73,0x65,0x20,0x7b,0x61,0x6c,0x65,0x72,0x74,0x28,0x22,0x57,0x52,0x4f,0x4e,0x47,0x21,0x20,0x54,0x72,0x79,0x20,
0x61,0x67,0x61,0x69,0x6e,0x21,0x22,0x29,0x7d,0x27,0x3e,0x43,0x68,0x65,0x63,0x6b,0x20,0x50,0x61,0x73,0x73,0x77,
0x6f,0x72,0x64,0x3c,0x2f,0x62,0x75,0x74,0x74,0x6f,0x6e,0x3e));
</script>

해석하기 불편하게 hex로 바꾼 모습이다. 여기서 좀더 바꾸어야 한다. 일단 0x를 다 지우자

<script language="javascript">
var _ 4e9d=["\x66\x72\x6F\x6D\x43\x68\x61\x72\x43\x6F\x64\x65","\x77\x72\x69\x74\x65"];document[_ 4e9d[ 1]](String[_ 4e9d[ 0]]( 3c, 62, 75, 74, 74, 6f, 6e, 20, 6f, 6e, 63, 6c, 69, 63, 6b, 3d, 27, 6a, 61, 76, 61, 73, 63, 72, 69, 70, 74, 3a, 69, 66, 20, 28, 64, 6f, 63, 75, 6d, 65, 6e, 74, 2e, 67, 65, 74, 45, 6c, 65, 6d, 65, 6e, 74, 42, 79, 49, 64, 28, 22, 70, 61, 73, 73, 22, 29, 2e, 76, 61, 6c, 75, 65, 3d, 3d, 22, 6a, 30, 30, 77, 31, 6e, 22, 29, 7b, 61, 6c, 65, 72, 74, 28, 22, 59, 6f, 75, 20, 57, 49, 4e, 21, 22, 29, 3b, 77, 69, 6e, 64, 6f, 77, 2e, 6c, 6f, 63, 61, 74, 69, 6f, 6e, 20, 2b, 3d, 20, 22, 3f, 6c, 76, 6c, 5f, 70, 61, 73, 73, 77, 6f, 72, 64, 3d, 22, 2b, 64, 6f, 63, 75, 6d, 65, 6e, 74, 2e, 67, 65, 74, 45, 6c, 65, 6d, 65, 6e, 74, 42, 79, 49, 64, 28, 22, 70, 61, 73, 73, 22, 29, 2e, 76, 61, 6c, 75, 65, 7d, 65, 6c, 73, 65, 20, 7b, 61, 6c, 65, 72, 74, 28, 22, 57, 52, 4f, 4e, 47, 21, 20, 54, 72, 79, 20, 61, 67, 61, 69, 6e, 21, 22, 29, 7d, 27, 3e, 43, 68, 65, 63, 6b, 20, 50, 61, 73, 73, 77, 6f, 72, 64, 3c, 2f, 62, 75, 74, 74, 6f, 6e, 3e));
</script>

다음으로는 \x를 지우자

<script language="javascript">
var _ 4e9d=[" 66 72 6F 6D 43 68 61 72 43 6F 64 65"," 77 72 69 74 65"];document[_ 4e9d[ 1]](String[_ 4e9d[ 0]]( 3c, 62, 75, 74, 74, 6f, 6e, 20, 6f, 6e, 63, 6c, 69, 63, 6b, 3d, 27, 6a, 61, 76, 61, 73, 63, 72, 69, 70, 74, 3a, 69, 66, 20, 28, 64, 6f, 63, 75, 6d, 65, 6e, 74, 2e, 67, 65, 74, 45, 6c, 65, 6d, 65, 6e, 74, 42, 79, 49, 64, 28, 22, 70, 61, 73, 73, 22, 29, 2e, 76, 61, 6c, 75, 65, 3d, 3d, 22, 6a, 30, 30, 77, 31, 6e, 22, 29, 7b, 61, 6c, 65, 72, 74, 28, 22, 59, 6f, 75, 20, 57, 49, 4e, 21, 22, 29, 3b, 77, 69, 6e, 64, 6f, 77, 2e, 6c, 6f, 63, 61, 74, 69, 6f, 6e, 20, 2b, 3d, 20, 22, 3f, 6c, 76, 6c, 5f, 70, 61, 73, 73, 77, 6f, 72, 64, 3d, 22, 2b, 64, 6f, 63, 75, 6d, 65, 6e, 74, 2e, 67, 65, 74, 45, 6c, 65, 6d, 65, 6e, 74, 42, 79, 49, 64, 28, 22, 70, 61, 73, 73, 22, 29, 2e, 76, 61, 6c, 75, 65, 7d, 65, 6c, 73, 65, 20, 7b, 61, 6c, 65, 72, 74, 28, 22, 57, 52, 4f, 4e, 47, 21, 20, 54, 72, 79, 20, 61, 67, 61, 69, 6e, 21, 22, 29, 7d, 27, 3e, 43, 68, 65, 63, 6b, 20, 50, 61, 73, 73, 77, 6f, 72, 64, 3c, 2f, 62, 75, 74, 74, 6f, 6e, 3e));
</script>

여기서 , 와 " hex가 아닌 값들을 지우자

4e 9d 66 72 6F 6D 43 68 61 72 43 6F 64 65 77 72 69 74 65 4e 9d 4e 9d 3c 62 75 74 74 6f 6e 20 6f 6e 63 6c 69 63 6b 3d 27 6a 61 76 61 73 63 72 69 70 74 3a 69 66 20 28 64 6f 63 75 6d 65 6e 74 2e 67 65 74 45 6c 65 6d 65 6e 74 42 79 49 64 28 22 70 61 73 73 22 29 2e 76 61 6c 75 65 3d 3d 22 6a 30 30 77 31 6e 22 29 7b 61 6c 65 72 74 28 22 59 6f 75 20 57 49 4e 21 22 29 3b 77 69 6e 64 6f 77 2e 6c 6f 63 61 74 69 6f 6e 20 2b 3d 20 22 3f 6c 76 6c 5f 70 61 73 73 77 6f 72 64 3d 22 2b 64 6f 63 75 6d 65 6e 74 2e 67 65 74 45 6c 65 6d 65 6e 74 42 79 49 64 28 22 70 61 73 73 22 29 2e 76 61 6c 75 65 7d 65 6c 73 65 20 7b 61 6c 65 72 74 28 22 57 52 4f 4e 47 21 20 54 72 79 20 61 67 61 69 6e 21 22 29 7d 27 3e 43 68 65 63 6b 20 50 61 73 73 77 6f 72 64 3c 2f 62 75 74 74 6f 6e 3e

이제 hex->ascii로 바꾸자
http://www.yellowpipe.com/yis/tools/encrypter/index.php
여기서 hex -> ascii 바꾸기를 하면 다음과 같이 나온다.

NfromCharCodewriteNN<button onclick='javascript:if (document.getElementById("pass").value=="j00w1n"){alert("You WIN!");window.location += "?lvl_password="+document.getElementById("pass").value}else {alert("WRONG! Try again!")}'>Check Password</button>

잘 읽어보면 j00w1n이 답인 것을 확인 할 수 있다.

'해킹 > 웹해킹' 카테고리의 다른 글

[Hackthissite Javascript] level 6  (0) 2010.09.26
[Hackthissite Javascript] level 5  (0) 2010.09.26
[Hackthissite Javascript] level 4  (0) 2010.09.26
[Hackthissite Javascript] level 3  (0) 2010.09.26
[Hackthissite Javascript] level 2  (0) 2010.09.26
Comments