반응형
반응형
반응형

2020 Defenit CTF Write-up 6/5 09:00 ~ 6/7 09:00 (UTC, 48h)

 

 

 

Forensic

Baby Steganography

I heared you can find hide data in Audio Sub Bit. Do you want to look for it?

 

 

.wav 파일이 주어진다. 문제 지문을 보면 Audio Sub Bit에 데이터를 숨긴다고 한다.

 

Audio Sub Bit...

 

Sub Bit...

 

SB...

 

LSB?

 

LSB가 아닐까 생각을 해보고서 바로 구글링을 했다.

 

 

 

https://medium.com/@sumit.arora/audio-steganography-the-art-of-hiding-secrets-within-earshot-part-2-of-2-c76b1be719b3

 

Audio Steganography : The art of hiding secrets within earshot (part 2 of 2)

In this article we take a look at methods and tools along with code walk-through for performing Audio Steganography.

medium.com

Audio Steganography : LSB

 

 

포스트를 내리다보면 Python으로 작성된 Decode 코드가 있다. 바로 긁어다가 실행해 보았다.

 

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# Use wave package (native to Python) for reading the received audio file
import wave
song = wave.open("problem", mode='rb')
# Convert audio to byte array
frame_bytes = bytearray(list(song.readframes(song.getnframes())))
 
# Extract the LSB of each byte
extracted = [frame_bytes[i] & 1 for i in range(len(frame_bytes))]
# Convert byte array back to string
string = "".join(chr(int("".join(map(str,extracted[i:i+8])),2)) for i in range(0,len(extracted),8))
# Cut off at the filler characters
decoded = string.split("###")[0]
 
# Print the extracted text
print("Sucessfully decoded: "+decoded)
song.close()
 
cs

 

Sucessfully decoded: Defenit{Y0u_knOw_tH3_@uD10_5t39@No9rAphy?!}

 

결과는 대성공.

 

 

 

 


Misc

QR Generator

Escape from QR devil!

 

nc 연결을 하자.

 

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
Let's START!
 
< QR >
1 1 1 1 1 1 1 0 1 1 0 0 0 1 1 0 1 1 1 1 1 0 1 1 1 1 1 1 1 
1 0 0 0 0 0 1 0 1 0 1 1 1 0 0 0 1 0 0 0 0 0 1 0 0 0 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0 0 0 0 0 0 1 0 0 1 1 0 1 0 0 0 1 0 1 0 1 1 
1 0 0 0 1 0 1 0 1 1 1 1 1 0 0 1 0 1 1 0 1 1 1 1 1 0 0 1 0 
0 0 0 0 0 0 0 0 1 0 1 0 0 0 1 1 0 0 1 1 1 0 0 0 1 0 0 0 0 
1 1 1 1 1 1 1 0 0 0 1 0 0 1 1 0 0 0 0 1 1 0 1 0 1 0 0 0 1 
1 0 0 0 0 0 1 0 1 1 1 1 0 1 0 1 1 1 0 0 1 0 0 0 1 1 1 1 0 
1 0 1 1 1 0 1 0 0 1 0 1 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 0 0 
1 0 1 1 1 0 1 0 1 0 1 1 1 1 1 1 0 0 0 1 1 0 0 1 0 1 1 1 0 
1 0 1 1 1 0 1 0 0 0 1 0 0 0 0 0 1 1 0 0 1 1 0 0 0 0 0 0 0 
1 0 0 0 0 0 1 0 1 0 0 0 0 1 0 1 0 0 0 0 1 1 0 0 0 0 1 1 0 
1 1 1 1 1 1 1 0 0 0 0 1 1 0 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 
 
STAGE 1
>> Time Over!
 
cs

 

1과 0으로 된 qrcode를 보내준다.

 

하얀배경 이미지를 불러와서 값이 1이면 해당 위치의 픽셀의 값을 검정으로 바꾸도록 코드를 쓱-싹 작성해 준다.

하얀배경 이미지는 포토샵을 이용한다. 넉넉하게 200px*200px

 

 

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
from pwn import *
from PIL import Image
 
= remote("qr-generator.ctf.defenit.kr"9000)
p.recvuntil('name?')
p.sendline('M4ndU')
img = Image.open('./200.png') #load white background 200*200 image
img = img.convert("RGB")
newData = []
 
qrbin = [0* 200
p.recvuntil('< QR >\n')
for i in range(200):
    data = str(p.recvline())
    data = data.replace("b'""")
    data = data.replace("\\n'""")
    data = data.replace(" """)
    if data == "":
        print(p.recvline())
        break
    qrbin[i] = data
 
for x in range(len(qrbin)):
    if qrbin[x] == 0:
        break
    for y in range(len(str(qrbin[x]))):
        if qrbin[x][y] == "1":
            img.putpixel( (x, y), (000)) #black
 
img.save("./dimg/TransparentImage"+str(n)+".png""PNG")
 
 
p.interactive()
 
cs

 

그러면 이러한 qrcode 이미지를 만들어 낼 수 있다.

(제공되는 qrcode 크기가 제각각 이어서 배경 이미지의 크기에 여유를 주었다. 인식하는데에는 문제가 없었다.)

 

 

이제 이 qrcode를 decoding해서 보내주기만 하면 된다. 그러나 이 과정에서 삽질이 있었다.

 

이 qrcode이미지를 디코딩하는 방법에는 여러가지가 있다.

qrcode를 디코딩해주는 사이트에 리퀘스트 날려서 크롤링하는 방법. (이미지 보내고 크롤링 해야되는 무조건 버리고)

파이썬 모듈을 이용해서 디코딩 하는 방법.

 

qrcode를 디코딩할 수 있는 파이썬 모듈에는 여러가지가 있었다.

 

먼저 qrtools.

 

$sudo pip3 install qrtools

 

      qr = qrtools.QR()

AttributeError: module 'qrtools' has no attribute 'QR'

 

음? (오류 1스택)

파이썬 2로 다시시도..

 

 

$sudo pip install qrtools

 

import qrtools
ImportError: No module named qrtools

 

??????? (오류 2스택)

 

다음 시도한 것이 qrcode

 

 d = qrcode.Decoder()
AttributeError: module 'qrcode' has no attribute 'Decoder'

 

문서에서는 이렇게 쓰라고 나와있었는데 뭐지..(오류 3스택)

 

 

pyzbar를 사용해볼까

>>> decode(img)
[]

 

도대체 되는게 뭡니까(오류 4스택)

 

 

$ sudo pip3 install pyqrcode

$ sudo apt-get install python-qrtools

 

>>> import pyqrcode
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named pyqrcode
(오류 5스택)

 

>>> import qrtools

>>> qr = qrtools.QR()

>>> qr.decode("./TransparentImage.png")
False

(오류 6스택)

 

AttributeError: module 'pyqrcode' has no attribute 'Decoder'

(오류 7스택)

 

 

...

 

웹으로 해결할까 생각이 들어서 테스트때 디코딩에 성공했던 ZXng Decode Online에 들어가봤다.

 

https://zxing.org/w/decode.jspx

 

ZXing Decoder Online

 

zxing.org

하단 내용을 보면 오픈소스 프로젝트라고 써있다.

 

혹시 파이썬 모듈도 있나 들어가봤다.

 

pyzxing Python wrapper to ZXing library

 

있다.

 

바로 설치.

 

>>> from pyzxing import BarCodeReader

>>> reader = BarCodeReader()

>>> results = reader.decode( './TransparentImage.png')

>>> results
[{'filename': 'file:///home/mandu/Desktop/p/./TransparentImage.png', 'format': 'QR_CODE', 'type': 'TEXT', 'raw': '0pXenF4L00pza6n9XO45WjUvM4RvBUuoQICQAraBTh1rJIBeYUpxxJFNFsGOQ7DFNZ67QzuP0fNzl8of6j3wfObKWkRuUO1xrn2iMLQl7KCBJ6waeBboITBQRPDYtZUmQmHHa85ll4J', 'parsed': '0pXenF4L00pza6n9XO45WjUvM4RvBUuoQICQAraBTh1rJIBeYUpxxJFNFsGOQ7DFNZ67QzuP0fNzl8of6j3wfObKWkRuUO1xrn2iMLQl7KCBJ6waeBboITBQRPDYtZUmQmHHa85ll4J', 'points': [(3.5, 49.5), (3.5, 3.5), (49.5, 3.5), (46.5, 46.5)]}]
>>> results[0]['raw']
'0pXenF4L00pza6n9XO45WjUvM4RvBUuoQICQAraBTh1rJIBeYUpxxJFNFsGOQ7DFNZ67QzuP0fNzl8of6j3wfObKWkRuUO1xrn2iMLQl7KCBJ6waeBboITBQRPDYtZUmQmHHa85ll4J'

 

성공.

 

 

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
from pwn import *
from PIL import Image
from pyzxing import BarCodeReader
 
= remote("qr-generator.ctf.defenit.kr"9000)
p.recvuntil('name?')
p.sendline('M4ndU')
for n in range(100):
    img = Image.open('./200.png')
    img = img.convert("RGB")
    newData = []
 
    qrbin = [0* 200
    p.recvuntil('< QR >\n')
    for i in range(200):
        data = str(p.recvline())
        data = data.replace("b'""")
        data = data.replace("\\n'""")
        data = data.replace(" """)
        if data == "":
            print(p.recvline())
            break
        qrbin[i] = data
 
    for x in range(len(qrbin)):
        if qrbin[x] == 0:
            break
        for y in range(len(str(qrbin[x]))):
            if qrbin[x][y] == "1":
                img.putpixel( (x, y), (000))
 
    img.save("./dimg/TransparentImage"+str(n)+".png""PNG")
 
 
    reader = BarCodeReader()
    results = reader.decode('./dimg/TransparentImage'+str(n)+'.png')
    print(results[0]['raw'])
 
    p.sendline(results[0]['raw'])
 
p.interactive()
 
cs

 

 

 

 

 

 

 


Minesweeper

Can you solve the minesweeper in one minute?

 

 

1분안에 지뢰찾기를 성공하면 되는 문제.

 

 

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
     a   b   c   d   e   f   g   h   i   j   k   l   m   n   o   p   
   -----------------------------------------------------------------
 1 |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |
   -----------------------------------------------------------------
 2 |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |
   -----------------------------------------------------------------
 3 |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |
   -----------------------------------------------------------------
 4 |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |
   -----------------------------------------------------------------
 5 |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |
   -----------------------------------------------------------------
 6 |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |
   -----------------------------------------------------------------
 7 |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |
   -----------------------------------------------------------------
 8 |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |
   -----------------------------------------------------------------
 9 |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |
   -----------------------------------------------------------------
10 |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |
   -----------------------------------------------------------------
11 |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |
   -----------------------------------------------------------------
12 |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |
   -----------------------------------------------------------------
13 |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |
   -----------------------------------------------------------------
14 |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |
   -----------------------------------------------------------------
15 |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |
   -----------------------------------------------------------------
16 |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |
   -----------------------------------------------------------------
 
Type the column followed by the row (eg. a5). To put or remove a flag, add 'f' to the cell (eg. a5f). Type 'help' to show this message again.
 
Enter the cell (40 mines left): 
 
cs

 

이런식으로 칸이 주어지고, a1을 입력하면 

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
     a   b   c   d   e   f   g   h   i   j   k   l   m   n   o   p   
   -----------------------------------------------------------------
 1 | 0 | 0 | 0 | 0 | 0 | 1 |   |   |   |   |   |   |   |   |   |   |
   -----------------------------------------------------------------
 2 | 0 | 0 | 0 | 0 | 0 | 1 |   |   |   |   |   |   |   |   |   |   |
   -----------------------------------------------------------------
 3 | 0 | 1 | 2 | 2 | 1 | 1 |   |   |   |   |   |   |   |   |   |   |
   -----------------------------------------------------------------
 4 | 0 | 1 |   |   |   |   |   |   |   |   |   |   |   |   |   |   |
   -----------------------------------------------------------------
 5 | 0 | 1 |   |   |   |   |   |   |   |   |   |   |   |   |   |   |
   -----------------------------------------------------------------
 6 | 1 | 1 |   |   |   |   |   |   |   |   |   |   |   |   |   |   |
   -----------------------------------------------------------------
 7 |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |
   -----------------------------------------------------------------
 8 |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |
   -----------------------------------------------------------------
 9 |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |
   -----------------------------------------------------------------
10 |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |
   -----------------------------------------------------------------
11 |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |
   -----------------------------------------------------------------
12 |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |
   -----------------------------------------------------------------
13 |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |
   -----------------------------------------------------------------
14 |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |
   -----------------------------------------------------------------
15 |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |
   -----------------------------------------------------------------
16 |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |
   -----------------------------------------------------------------
 
cs

주변 3*3범위에 폭탄의 개수를 알려준다.

 

지뢰의 위치에는 깃발을 꽂아야 한다. 저기서는 C4자리에 폭탄이 있으니 c4f를 입력해주어야 한다.

다음으로 지뢰가 없는 c5를 입력하여 나아가도록 한다.

 

이 과정을 자동화 하자.

 

 

http://www.hakank.org/numberjack/minesweeper.py

구글링 해서 찾아낸 지뢰찾기 솔버.

 

사용을 위해서 Numberjack 모듈을 설치해준다.

https://github.com/eomahony/Numberjack

 

eomahony/Numberjack

Python Combinatorial Optimisation Platform. Contribute to eomahony/Numberjack development by creating an account on GitHub.

github.com

X = -1

default_game = [
            [2,3,X,2,2,X,2,1],
            [X,X,4,X,X,4,X,2],
            [X,X,X,X,X,X,4,X],
            [X,5,X,6,X,X,X,2],
            [2,X,X,X,5,5,X,2],
            [1,3,4,X,X,X,4,X],
            [0,1,X,4,X,X,X,3],
            [0,1,2,X,2,3,X,2]
            ]

이렇게 지뢰찾기 배열을 넘겨주면

0 0 1 0 0 1 0 0 
1 1 0 0 1 0 1 0 
0 0 1 1 0 1 0 1 
1 0 1 0 1 1 0 0 
0 1 1 1 0 0 1 0 
0 0 0 0 1 1 0 1 
0 0 1 0 1 0 1 0 
0 0 0 1 0 0 1 0 
Nodes: 3  Time: 0.0

 

0: 지뢰없음 1: 지뢰있음 으로 결과를 출력해준다. 확실하지 않은 곳은 확률을 반환해준다. 이것을 개조했다.

 

문제에 아무 위치 한곳을 입력해주고 그 출력값을 위 코드로 분석하여 확실한 지뢰가 아닌 곳(0)과 지뢰인 곳(1)을 구해낼 수 있다. 지뢰인 곳에는 flag를 세우고 지뢰가 아닌 곳은 입력해서 주변 값들도 알아낸다.

 

이제 다시 맵의 결과값을 바탕으로 위 루틴을 전체를 구해낼 때까지 돌린다.

 

 

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
#!/usr/bin/python
"""
This Numberjack model was created by
Hakan Kjellerstrand (hakank@bonetmail.com)
 
See also my Numberjack page http://www.hakank.org/numberjack/
"""
import sys
from Numberjack import *
 
from pwn import *
 
colNum = "abcdefghijklmnop"
 
= -1
alreadyInput = [[0 for ccccc in range(16)] for ddddd in range(16)]
row = [['0' for cola in range(16)] for rowa in range(16)]
gamerow = [[-1 for colas in range(16)] for rowas in range(16)]
 
= remote("minesweeper.ctf.defenit.kr"3333)
p.recvuntil(':')
p.sendline('h7'#중앙을 파면 한 번에 많은 위치를 분석할 수 있지 않을까
 
default_game = gamerow
default_r = 16
default_c = 16
 
#
# Solve the Minesweeper problem
#
def minesweeper(libs, game="", r="", c=""):
 
    # Set default problem
    if game == "":
        game = default_game
        r = default_r
        c = default_c
    else:
        print "rows:", r, " cols:", c
 
    #
    # Decision variables
    # Note: Matrix is defined with cols,rows,...
    #
    mines = Matrix(c,r,0,1)
 
    S = [-1,0,1]  # for the neighbors of this cell
 
    model = Model()
 
    for i in range(r):
        for j in range(c):
            if game[i][j] >= 0:
                model.add(mines[i,j] == 0)
                # this cell is the sum of all the surrounding cells
                model.add(
                    game[i][j] == Sum([mines[i+a,j+b]
                                       for a in S for b in S
                                       if i+a>=0 and
                                          j+b>=0 and
                                          i+a<r  and
                                          j+b<c
                                       ])
                    )
            if game[i][j] > X:
                # This cell cannot be a mine
                model.add(mines[i,j] == 0)
 
    # print model
 
 
    for library in libs:
        solver = model.load(library)
        # print solver
        print ''
        if solver.solve():
            solver.printStatistics()
            print_mines(mines, r, c)
            print 'Nodes:', solver.getNodes(), ' Time:', solver.getTime()
            #while library == 'Mistral' and solver.getNextSolution():
            #    print_mines(mines, r, c)
            #    print 'Nodes:', solver.getNodes(), ' Time:', solver.getTime()
 
        else:
            print "No solution"
            p.interactive()
        print ''
 
#
# Print the mines
#
def print_mines(mines, rows, cols):
    for i in range(rows):
        print i+1,
        for j in range(cols): #이부분을 수정했다. 불확실한 곳은 ?표시
            if len(str(mines[i,j])) > 4:
                print "?",
            else : #확실
                print str(mines[i,j]),
                if str(mines[i,j]) == '1'#지뢰는 플래그를 세우자
                    if alreadyInput[i][j] == 0#중복 입력 방지
                        print(colNum[j]+str(i+1)+"f"+'\n')
                        try:
                            p.send(colNum[j]+str(i+1)+"f"+'\n')
                            p.recvuntil("):")
                        except Exception as e:
                            p.interactive()
                elif str(mines[i,j]) == '0'#지뢰가 아니면 주변을 더 알아내자
                    if alreadyInput[i][j] == 0#중복 입력 방지
                        print(colNum[j]+str(i+1)+'\n')
                        try:
                            p.send(colNum[j]+str(i+1)+'\n')
                            p.recvuntil("):")
                        except Exception as e:
                            p.interactive()
        print ''
 
def print_game(game, rows, cols):
    for i in range(rows):
        print i+1,
        for j in range(cols):
            if game[i][j] == -1:
                print "?"#모르거나 지뢰인 곳은 ?표시
            else :
                print game[i][j],
        print ''
 
 
# file = "minesweeper1.txt"
 
for aa in range(6): #루틴을 몇번 돌릴 것인지. 끝까지 돌리는게 최고지만 정확성이 떨어져서 적당히 맞춰줘야 했다.
    row = [['0' for cola in range(16)] for rowa in range(16)]
    gamerow = [[-1 for colas in range(16)] for rowas in range(16)]
 
    p.recvline()
    p.recvline()
    p.recvline()
    p.recvline()
    p.recvline()
    for i in range(16):
        data = p.recvline()
        row[i] = str(data).split('|')
        p.recvline()
        for j in range(117):
            try:
                if row[i][j] == '   ':
                    gamerow[i][j-1= -1;
                elif row[i][j] == ' F ':
                    alreadyInput[i][j-1= -1 #중복입력을 방지하기 위함. 깃발을 세웠다는건 여기를 더 이상 이 위치를 입력할 필요가 없다는 것
                else :
                    gamerow[i][j-1= int(row[i][j].strip());
                    alreadyInput[i][j-1= 1 #중복입력ㅇ르 방지하기 위함. 이곳의 값이 있다는건 더 이상 이 위치를 입력할 필요가 없다는
            except Exception as e:
                p.interactive()
 
 
    default_game = gamerow
    print_game(default_game, 1616)
    # minesweeper(['NumberjackSolver', 'Mistral'])
    minesweeper(['Mistral'])
    # minesweeper(['SCIP'])
    print "================================================="
    p.sendline("h7")
 
p.interactive()
 
cs

 

 

근데 solver가 완벽하지는 않다. 완벽한 지뢰 위치를 찾아주지 못한다. 그래서 중간에 game over가 나기도 한다.

그래서 약 6번의 루틴을 시도하게 하고, 코드를 수십번 돌려서 운좋게 165행 코드가 실행이 되면 약 3칸정도가 남는다. 이건 눈으로 보고 풀어서 flag를 받을 수 있었다.

 

 

It took you 0 minutes and 17 seconds.

You Win!!!
Defenit{min35w33p3r_i5_ezpz}

 

 

 

 

반응형

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

CCE2020 Quals Write-up  (0) 2020.09.26
FIESTA 2020 Write up  (2) 2020.09.07
angstrom CTF 2020 write up  (0) 2020.03.14
UTCTF 2020 Write up  (0) 2020.03.07
RiceTeaCatPanda CTF 2020 Write up  (0) 2020.01.22
반응형

2020년 5월에 새로운 Wargame사이트를 추천합니다!

 

 

ctf.no-named.kr:1234/

 

N0Named (노나메드) 팀에서 제작한 Wargame입니다.

 

 

 

Misc, Reversing, Forensic, Pwnable, Crypto 카테고리의 문제들을 풀어보실 수 있습니다.

 

현재 29문제가 등록되어 있으며, 앞으로도 꾸준히 문제가 추가될 예정입니다.

 

 

많은 이용 부탁드립니다!

반응형
반응형

직접 MBTI를 검사하는 봇은 아니고, 외부 사이트 등에서 mbti를 검사하고서 그 결과를 등록한 뒤, 디스코드 구성원들과 궁합을 보는 봇이다.

 

인터넷에 떠돌아 다니는 MBTI 궁합 차트를 기반으로 했다.

 

물론 아무런 근거 없는 궁합이기 때문에 재미로만 보자.

 

 


명령어별 기능

 

 

mbti

명령어 모음 (help 명령어와 동일)

 

1. mbti 검사

MBTI를 검사할 수 있는 링크를 출력한다.

 

2. mbti 보기 [MBTI]

MBTI 유형을 입력해주면, 해당 유형의 내용을 볼 수 있는 링크를 출력한다.

 

3. mbti 등록 [MBTI]

자신의 MBTI 유형을 등록한다. (기존에 등록했어도 덮어쓰기 가능.)

 

4. mbti 등록현황

mbti 등록 현황을 출력한다.

 

5. mbti 궁합 @A @B

@자리에 원하는 사람을 언급해주면 된다.

@A만 언급하면 A와 나 자신의 궁합 결과를 출력한다.

@A @B 모두 언급해주면, @A와 @B의 궁합 결과를 표시해준다.

 

 


개발환경 : UBUNTU 18.04.3

개발언어: NODE JS V12

모듈 : discord.js v12

텍스트 에디터: ATOM (편하신거 사용하시면 됩니다.)

 

봇 생성하는 것은 아래 포스트를 보고 오자.

https://mandu-mandu.tistory.com/385?category=693080

 

노드자스로 디스코드 봇 만들기(1) - 봇 생성부터 테스트까지

이 글만을 통해서 기본적으로 텍스트를 출력하는 디스코드 봇을 만들 수 있습니다. 1. 봇 생성하고 초대하기 2. 코드 작성하기 3. 테스트 하기 봇 생성하고 초대하기 먼저 봇 계정을 생성해 주어��

mandu-mandu.tistory.com

 

 

 

일단 위 궁합표를 배열로 만들었다. (노가다다 노가다...)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
//16가지 mbti 유형
const mbti = new Array("INFP","ENFP","INFJ","ENFJ""INTJ""ENTJ""INTP""ENTP""ISFP""ESFP""ISTP""ESTP""ISFJ""ESFJ""ISTJ""ESTJ");
 
//Relation : A, B, C, D, F
var mbtiR = new Array(16);
mbtiR[0]  = ["A"];
mbtiR[1]  = ["A""A"];
mbtiR[2]  = ["A""B""A"];
mbtiR[3]  = ["B""A""A""A"];
mbtiR[4]  = ["A""B""A""A""A"];
mbtiR[5]  = ["B""A""A""A""A""A"];
mbtiR[6]  = ["A""A""A""A""A""B""A"];
mbtiR[7]  = ["A""A""B""A""B""A""A""A"];
mbtiR[8]  = ["F""F""F""B""C""C""C""C""D"];
mbtiR[9]  = ["F""F""F""F""C""C""C""C""D""D"];
mbtiR[10= ["F""F""F""F""C""C""C""C""D""D""D"];
mbtiR[11= ["F""F""F""F""C""C""C""C""D""D""D""D"];
mbtiR[12= ["F""F""F""F""D""C""D""D""C""B""C""B""A"];
mbtiR[13= ["F""F""F""F""D""C""D""D""B""C""B""C""A""A"];
mbtiR[14= ["F""F""F""F""D""C""D""D""C""B""C""B""A""A""A"];
mbtiR[15= ["F""F""F""F""D""C""B""D""B""C""B""C""A""A""A""A"];
 
cs

A, B, C, D, F 5단계이며, 위 표 기준으로 A가 파랑, F가 빨강이다.

 

 

 

 

 

 

 

이제 명령어 별로 6가지의 기능을 구현해야 하는데, 1번과 2번은 단술 입출력이기 때문에 아래 포스트를 보고 구현이 가능하다.

https://mandu-mandu.tistory.com/385?category=693080

 

노드자스로 디스코드 봇 만들기(1) - 봇 생성부터 테스트까지

이 글만을 통해서 기본적으로 텍스트를 출력하는 디스코드 봇을 만들 수 있습니다. 1. 봇 생성하고 초대하기 2. 코드 작성하기 3. 테스트 하기 봇 생성하고 초대하기 먼저 봇 계정을 생성해 주어��

mandu-mandu.tistory.com

https://mandu-mandu.tistory.com/386?category=693080

 

노드자스로 디스코드 봇 만들기(2) - 노래/사진/상태/삭제

이번에 추가할 기능은 아래와 같습니다. [ 로컬 노래파일 재생, 로컬 사진 전송, 상태메세지 설정, 메세지 지우기 ] 개발환경 : UBUNTU 18.04.3 개발언어: NODE JS V8 모듈 : discord.js v11 텍스트 에디터: ATOM

mandu-mandu.tistory.com

 

 

 


 

3번 4번 5번의 핵심 기능은 동일하다.

 

 

 

배열을 하나 만들어서

유저의 id (고유값), username, mbti 유형값을 받아서 저장하고

json으로 만들어서 외부 파일에 저장해둔다.

 

저장된 유저의 mbti값을 가져와서 궁합 값을 출력해주면 된다.

 

 

간단하다.

 

 

 

 

봇의 핵심인 3번과 5번 명령에 해당되는 코드:

 

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
if (msg.content.startsWith('mbti 등록 ')) {
    var reg_mbti = msg.content.split(' ');
 
    //type
    var type = 16;
    var input_mbti = reg_mbti[2].toUpperCase();
    for(var i=0; i<16; i++) {
      if (mbti[i] == input_mbti) {
        type = i;
        break;
      }
    }
    if(type == 16){
      msg.channel.send("실패!");
    }else {
 
      //json to Array
      var data = fs.readFileSync('./user_list.json''utf8');
      var user_list_arr = JSON.parse(data);
 
      //search
      var j = -1;
      for(var k=0; k<user_list_arr.length; k++) {
        if (user_list_arr[k].user_id == msg.member.user.id) {
          j = k;
          break;
        }
      }
 
      //patch or push
      if (j == -1) {
        var user_list = new Object();
        user_list.user_id = msg.member.user.id;
        user_list.username = msg.member.user.username;
        user_list.mbti  = type;
        user_list_arr.push(user_list);
      } else {
        user_list_arr[j].username = msg.member.user.username;
        user_list_arr[j].mbti  = type;
      }
 
      //Array to json
      data = JSON.stringify(user_list_arr);
      fs.writeFileSync('./user_list.json', data, 'utf8');
 
      msg.channel.send("성공!");
    }
  }
 
  if (msg.content.startsWith('mbti 궁합')) {
    var comp_mbti = msg.content.split(' ');
 
    //json to Array
    var data = fs.readFileSync('./user_list.json''utf8');
    var user_list_arr = JSON.parse(data);
 
    //search user 1
    var user_1 = "";
    if (comp_mbti[2=== undefined) {
      user_1 = "";
    } else {
      user_1 = comp_mbti[2].replace(/[^0-9]/g,'');
    }
 
    var user1type = 16;
    var user1name = "";
    for(var k=0; k<user_list_arr.length; k++) {
      if (user_list_arr[k].user_id == user_1) {
        user1type = user_list_arr[k].mbti;
        user1name = user_list_arr[k].username;
        break;
      }
    }
 
    //search user 2
    var user_2 = "";
    if (comp_mbti[3=== undefined) {
      user_2 = msg.member.user.id;
    } else if (comp_mbti[3== "") {
      comp_mbti[3= comp_mbti[4]; //중간에 띄어쓰기가 한 번 더 들어간 경우에도 정상적인 처리를 위해서
      user_2 = comp_mbti[3].replace(/[^0-9]/g,'');
    } else {
      user_2 = comp_mbti[3].replace(/[^0-9]/g,'');
    }
 
    var user2type = 16;
    var user2name = "";
    for(var k=0; k<user_list_arr.length; k++) {
      if (user_list_arr[k].user_id == user_2) {
        user2type = user_list_arr[k].mbti;
        user2name = user_list_arr[k].username;
        break;
      }
    }
 
    //result
    if (user1type == 16 || user2type == 16) {
      msg.channel.send(noresultEmbed);
    } else{
 
      if (user2type > user1type) {
        [user1type, user2type] = [user2type, user1type];
      }
 
      var result = mbtiR[user1type][user2type];
 
      var explain_text1 = " 와(과) ";
      var explain_text2 = " 의 궁합";
 
      var resultEmbed = new Discord.MessageEmbed()
          .setColor('#0099FF')
          .setTitle(user1name.concat(explain_text1,user2name,explain_text2))
        .addField('결과', result, true)
          .setFooter('Powered by node.js  Made by M4ndU''');
 
      msg.channel.send(resultEmbed);
 
    }
  }
cs

 

 

 

 

 

 

 

 

 

 

 


실행

 

user_list.json 파일을 하나 만들어두고 봇을 실행해야한다.

 

 

실행 후에 오류나면 아래 글에서 해결법을 찾아보자. 아래 글에도 없다면 구글링!

https://mandu-mandu.tistory.com/381

 

discord js 설치, 실행 오류 / 오디오 재생 오류 문제 해결

1. npm으로 discord.js 설치 후 봇 실행시 발생하는 오류 해결 /Client.js:39 } catch { ^ 봇 실행시 위와 같은 오류가 발생할 경우입니다. 저같은 경우에는 discord.js github에 나와있는 설치방법으로 설치를 했

mandu-mandu.tistory.com

 

반응형
반응형

이번에 추가할 기능은 아래와 같습니다.

 

[

로컬 노래파일 재생,

로컬 사진 전송,

상태메세지 설정,

메세지 지우기

]

 


개발환경 : UBUNTU 18.04.3

개발언어: NODE JS V8

모듈 : discord.js v11

텍스트 에디터: ATOM (편하신거 사용하시면 됩니다.)

 

 

 

 

로컬 경로에 존재하는 mp3파일을 재생하는 기능입니다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
  if (msg.content === 'r.play') {
    // Only try to join the sender's voice channel if they are in one themselves
    if (msg.member.voiceChannel) {
      msg.member.voiceChannel.join()
        .then(connection => { // Connection is an instance of VoiceConnection
          msg.reply('playing music!');
          const dispatcher = connection.playFile('./music.mp3');
          dispatcher.on("end", end => {});
        })
        .catch(console.log);
    } else {
      msg.reply('먼저 방에 들어가');
    }
  }
  if (msg.content === 'r.leave') {
    // Only try to join the sender's voice channel if they are in one themselves
    if (msg.member.voiceChannel) {
      msg.member.voiceChannel.leave();
      msg.reply('bye!');
    } else {
      msg.reply('이미 나왔는데..');
    }
  }
 
cs

 

r.play는 내가 들어간 음성 채팅방으로 들어가서 music.mp3를 재생합니다. (7행에서 파일명, 경로를 설정할 수 있습니다.)

내가 음성채팅방에 들어가 있지 않은 경우 12행 메세지를 출력합니다.

 

r.leave로 방을 나갈 수 있습니다.

 

 

 

 

오디오 재생시 오디오가 재생되지 않고 바로 종료되는 문제

또는 Error: FFMPEG not found 에러 발생시 아래 포스트 참조

 

https://mandu-mandu.tistory.com/381

 

discord js 설치 후 catch 오류 / 오디오 재생 오류 문제 해결

1. npm으로 discord.js 설치 후 봇 실행시 발생하는 오류 해결 /Client.js:39 } catch { ^ 봇 실행시 위와 같은 오류가 발생할 경우입니다. 저같은 경우에는 discord.js github에 나와있는 설치방법으로 설치를 했..

mandu-mandu.tistory.com

 

 

 


로컬경로에 존재하는 이미지를 채팅방에 전송하는 기능입니다.

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
  if (msg.content.startsWith('r.gif')) {
    const args = msg.content.split(' ').slice(1); // All arguments behind the command name with the prefix
    var no = args.join(' '); // Amount of messages which should be deleted
 
    if (!no) no = '1';
    if (isNaN(no) || no > 14return msg.reply('only number 1-14');
 
   // Create the attachment using Attachment
   var path = "./gif/";
   path = path.concat(no,".gif");
   console.log(path);
   const attachment = new Attachment(path);
   // Send the attachment in the message channel with a content
   msg.channel.send(attachment);
  }
cs

명령어는 r.gif n 입니다. n에는 정수가 들어갑니다. ex) r.gif 1

 

저는 gif 이미지를 보내도록 했습니다. 필요에 따라서 10번행의 확장자명을 gif에서 png, jpg등으로 바꾸실 수 있습니다.

저는 ./gif/ 디렉토리 안에 1.gif, 2.gif, 3.gif ... 파일을 넣어 놨습니다.

 

파일 명을 정수로 설정해주세요!

 

 

5번행은 명령어 뒤에 정수가 입력되지 않은 경우 자동으로 1로 하도록

6번행은 숫자인지 검증, 14까지만 입력되도록 한 것입니다.

 


 

상태메세지 설정은 아래 사진과 같이 별명 아래에 메세지를 표시하는 것입니다.

ready 안에 아래 코드 한줄을 추가만 해주시면 됩니다. (전체 코드는 밑에서 확인하실 수 있습니다.)

  client.user.setActivity('봇 만들자', { type: 'WATCHING' })

 

type에는 WATCHING (시청 중) 외에도 

  • PLAYING   (하는 중)
  • STREAMING
  • LISTENING

으로 설정하실 수 있습니다.

 

 

 


메세지 지우기 기능

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
  if (msg.content.toLowerCase().startsWith("r.clear")) {
      const args = msg.content.split(' ').slice(1); // All arguments behind the command name with the prefix
      const amount = args.join(' '); // Amount of messages which should be deleted
 
      if (!amount) return msg.reply('You haven\'t given an amount of messages which should be deleted!'); // Checks if the `amount` parameter is given
      if (isNaN(amount)) return msg.reply('The amount parameter isn`t a number!'); // Checks if the `amount` parameter is a number. If not, the command throws an error
 
      if (amount > 10return msg.reply('You can`t delete more than 10 messages at once!'); // Checks if the `amount` integer is bigger than 100
      if (amount < 1return msg.reply('You have to delete at least 1 message!'); // Checks if the `amount` integer is smaller than 1
 
      msg.channel.fetchMessages({ limit: amount }).then(dmsg => { // Fetches the messages
      msg.channel.bulkDelete(dmsg // Bulk deletes all messages that have been fetched and are not older than 14 days (due to the Discord API)
      ).catch(console.log);});
    }
cs

 

r.clear n 과 같이 입력하면, n개의 메세지를 삭제해줍니다.

 

8행 9행에서 각각 최대 최소 개수를 설정할 수 있습니다.

 

 

 

 


전체 봇 소스코드 bot.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
// Extract the required classes from the discord.js module
const { Client, Attachment } = require('discord.js');
 
// Create an instance of a Discord client
const client = new Client();
 
 
client.on('ready', () => {
  console.log(`Logged in as ${client.user.tag}!`);
  client.user.setActivity('봇 만들자', { type: 'WATCHING' })
});
 
client.on('message', msg => {
  if (msg.content.startsWith('r.help')) {
    msg.reply('Powered by node.js\nMade by M4ndU');
  }
  if (msg.content.startsWith('r.gif')) {
    const args = msg.content.split(' ').slice(1); // All arguments behind the command name with the prefix
    var no = args.join(' '); // Amount of messages which should be deleted
 
    if (!no) no = '1';
    if (isNaN(no) || no > 14return msg.reply('only number 1-14');
 
   // Create the attachment using Attachment
   var path = "./gif/";
   path = path.concat(no,".gif");
   console.log(path);
   const attachment = new Attachment(path);
   // Send the attachment in the message channel with a content
   msg.channel.send(attachment);
  }
 
 
  if (msg.content === 'r.play') {
    // Only try to join the sender's voice channel if they are in one themselves
    if (msg.member.voiceChannel) {
      msg.member.voiceChannel.join()
        .then(connection => { // Connection is an instance of VoiceConnection
          msg.reply('playing music!');
          const dispatcher = connection.playFile('./music.mp3');
          dispatcher.on("end", end => {});
        })
        .catch(console.log);
    } else {
      msg.reply('먼저 방에 들어가');
    }
  }
  if (msg.content === 'r.leave') {
    // Only try to join the sender's voice channel if they are in one themselves
    if (msg.member.voiceChannel) {
      msg.member.voiceChannel.leave();
      msg.reply('bye!');
    } else {
      msg.reply('이미 나왔는데..');
    }
  }
 
  if (msg.content.toLowerCase().startsWith("r.clear")) {
      const args = msg.content.split(' ').slice(1); // All arguments behind the command name with the prefix
      const amount = args.join(' '); // Amount of messages which should be deleted
 
      if (!amount) return msg.reply('You haven\'t given an amount of messages which should be deleted!'); // Checks if the `amount` parameter is given
      if (isNaN(amount)) return msg.reply('The amount parameter isn`t a number!'); // Checks if the `amount` parameter is a number. If not, the command throws an error
 
      if (amount > 10return msg.reply('You can`t delete more than 10 messages at once!'); // Checks if the `amount` integer is bigger than 100
      if (amount < 1return msg.reply('You have to delete at least 1 message!'); // Checks if the `amount` integer is smaller than 1
 
      msg.channel.fetchMessages({ limit: amount }).then(dmsg => { // Fetches the messages
      msg.channel.bulkDelete(dmsg // Bulk deletes all messages that have been fetched and are not older than 14 days (due to the Discord API)
      ).catch(console.log);});
    }
 
  if (msg.content === 'r.whoami') {
    // Send the user's avatar URL
    msg.reply(msg.author.avatarURL);
  }
});
 
client.login('token');
 
cs

 

79행 token에 반드시 자신의 봇의 토큰값을 입력하세요

반응형
반응형

이 글만을 통해서 기본적으로 텍스트를 출력하는 디스코드 봇을 만들 수 있습니다.

 

1. 봇 생성하고 초대하기

2. 코드 작성하기

3. 테스트 하기

 


 

봇 생성하고 초대하기

 

먼저 봇 계정을 생성해 주어야 합니다.

 

 

디스코드 홈페이지로 이동합니다. -> https://discordapp.com/

 

Discord — A New Way to Chat with Friends & Communities

Discord is the easiest way to communicate over voice, video, and text. Chat, hang out, and stay close with your friends and communities.

discordapp.com

 

상단에 개발자 > 개발자 포털

 

 

 

 

New Application을 누릅니다.

 

 

 

 

이름을 설정하고 Create!

 

 

 

왼쪽 탭에서 Bot을 클릭하고, 오른쪽에 있는 Add Bot을 클릭하여 봇을 만들어 줍시다!

 

 

현재 페이지에서 봇의 프로필사진, 이름을 수정하실 수 있으며,

중요한 Token 값을 확인하실 수 있습니다. (절대 외부로 유출되서는 안됩니다. Regenerate버튼을 통해 재생성 가능합니다.)

Public Bot 설정은 아무나 이 봇을 초대할 수 있는지, 나만 초대할 수 있는지를 설정하는 것입니다.

체크가 해제되어 있다면, 나만 이 봇을 초대할 수 있습니다.

 

아래로 스크롤하면, 봇의 권한을 설저할 수 있는 탭이 나옵니다.

여기서 설정하지 않아도, 디스코드 서버 역할을 통해서 권한을 부여해 줄 수도 있습니다.

 

 

 

 

 

 

이제 봇 초대코드를 생성하겠습니다.

 

왼쪽 두번째 탭 OAuth2를 클릭하시고, 중간에 bot을 체크하시면 아래에 링크가 생성됩니다.

 

해당 링크로 접속하여 자신의 서버로 봇을 초대할 수 있습니다.

 

 

 

 

현재 봇은 오프라인 상태가 됩니다.

 


 

코드 작성하기

 

 

개발환경 : UBUNTU 18.04.3

개발언어: NODE JS V8

모듈 : discord.js v11

텍스트 에디터: ATOM (편하신거 사용하시면 됩니다.)

 

 

 

설치방법

 

 바로가기 <-- (https://github.com/discordjs/discord.js#installation)

 

 

먼저 npm과 node가 설치되어 있는지 확인해보세요.

node -v
npm -v

 

 

음성 봇을 사용하지 않는 경우

npm install discord.js

 


음성 봇을 사용할 경우

npm install discord.js opusscript

 

 

 

 

 

 

설치를 마쳤다면,

이제 텍스트 에디터로 가서 소스를 작성해 봅시다.

 

 

기본적인 소스는 다음과 같습니다. node_modules폴더가 있는 폴더에서 작업해주세요!

저는 파일명을 bot.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
// Extract the required classes from the discord.js module
const { Client, Attachment } = require('discord.js');
 
// Create an instance of a Discord client
const client = new Client();
 
 
client.on('ready', () => {
  console.log(`Logged in as ${client.user.tag}!`);
});
 
client.on('message', msg => {
  if (msg.content.startsWith('r.help')) {
    msg.reply('Powered by node.js\nMade by M4ndU');
  }
 
  if (msg.content === 'r.whoami') {
    // Send the user's avatar URL
    msg.reply(msg.author.avatarURL);
  }
});
 
client.login('token');
 
cs

 

 

23행 token 자리에 디스코드 봇 관리 페이지에서 확인가능한 token 값을 넣어주시면 됩니다.

 

콘솔에 node bot.js을 입력해주시면 봇이 실행되면서, 디스코드 서버내에서 봇이 온라인 상태가 되는 것을 확인할 수 있습니다.

 

 

 

 

봇의 기능을 당담하는 12~21행의 내용을 분석해보겠습니다.

 

client.on('message', msg => {
  if (msg.content.startsWith('r.help')) {
    msg.reply('Powered by node.js\nMade by M4ndU');
  }

채팅창에 r.help로 시작하는 메세지를 보내면 메세지를 출력합니다.

Powered by node.js\nMade by M4ndU 이 부분을 수정하여 본인이 원하는 메세지를 넣을 수도 있습니다.

r.help를 수정하여 본인이 원하는 명령어로 변경하실 수도 있습니다.

 

 

 

if (msg.content === 'r.whoami') { 
    // Send the user's avatar URL 
    msg.reply(msg.author.avatarURL); 
  } 
});

메세지의 내용이 r.whoami와 동일하다면

그 유저의 정보를 보냅니다.

r.whoami를 수정하여 본인이 원하는 명령어로 변경하실 수도 있습니다.

msg.author.avatarURL 대신 'msg'로 자신이 원하는 메세지를 넣을 수도 있습니다.

 

 

msg.reply는 명령어를 입력한 사람을 언급과 함께 메세지를 보냅니다. 메세지만 보내고 싶으신 경우 msg.channel.send함수를 이용하시면 됩니다.

 

 

다음 포스트부터는 이 봇에 여러가지 기능을 추가해 보겠습니다.

반응형
반응형

Shifter

Misc

 

What a strange challenge...

It'll be no problem for you, of course!

 

 

 

Solve 50 of these epic problems in a row to prove you are a master crypto man like Aplet123!
You'll be given a number n and also a plaintext p.
Caesar shift `p` with the nth Fibonacci number.
n < 50, p is completely uppercase and alphabetic, len(p) < 50
You have 60 seconds!
--------------------
Shift XECK by n=1

 

주어진 문자열을 n번째 피보나치 수열 만큼 shift 한 값을 보내면 된다.

 

 

EX

 

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
from pwn import *
 
def fibo(n):
    t = [01]
 
    if n in (01):
        f = n
    else:
        for i in range(2, n+1):
            f = sum(t)
            t = [t[1], f]
 
    return f
 
 
 
 
alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
 
= remote("misc.2020.chall.actf.co"20300)
 
for a in range(0,50):
    p.recvuntil("Shift ")
    taskstr = list((p.recvuntil(" ")).strip())
    p.recvuntil("=")
    n = fibo(int(p.recvline()))
 
 
    for i in range(len(taskstr)):
        taskstr[i] = alpha[(ord(taskstr[i]) - 65 + n) % 26]
 
    ans = ''.join(taskstr)
    print ans
    p.sendline(ans)
p.interactive()
 
cs

 

 

 

flag : actf{h0p3_y0u_us3d_th3_f0rmu14-1985098}


Reasonably Strong Algorithm

Crypto

 

 

n = 126390312099294739294606157407778835887
e = 65537
c = 13612260682947644362892911986815626931

 

 

https://www.alpertron.com.ar/ECM.HTM

 

Integer factorization calculator

 

www.alpertron.com.ar

여기에서 n을 인수분해 해준다.

 

 

126 390312 099294 739294 606157 407778 835887 (39 digits) = 9 336949 138571 181619 × 13 536574 980062 068373

 

 

 

$ python rsatool.py -p 9336949138571181619 -q 13536574980062068373
Using (p, q) to initialise RSA instance

n = 126390312099294739294606157407778835887 (0x5f15e3803896f7b78f17d685eb590daf)

e = 65537 (0x10001)

d = 122116681453826726664714315157880092841 (0x5bded13dfcef588dae9e87c5c23eb8a9)

p = 9336949138571181619 (0x819381c5b26cbe33)

q = 13536574980062068373 (0xbbdb93397a0a3e95)

 

rsatool.py를 이용해서 d값을 구해준다.

 

c^d mod N

 

복호화

 

 

flag : actf{10minutes}

 

 

 


 

Wacko Images

Crypto

 

How to make hiding stuff a e s t h e t i c? And can you make it normal again? enc.png image-encryption.py

 

 

enc.png

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from numpy import *
from PIL import Image
 
flag = Image.open(r"flag.png")
img = array(flag)
 
key = [413723]
 
a, b, c = img.shape
 
for x in range (0, a):
    for y in range (0, b):
        pixel = img[x, y]
        for i in range(0,3):
            pixel[i] = pixel[i] * key[i] % 251
        img[x][y] = pixel
 
enc = Image.fromarray(img)
enc.save('enc.png')
cs

 

각 픽셀의 rgb 값에 각각 41, 37, 23을 곱하고 251로 나눈 나머지 값을 저장하여 enc.png 이미지를 만든다.

 

 

역연산을 해주면 되는데 251로 나눈 몫을 모르기 때문에 t로 두고 브포를 때렸다.

 

 

ex.py :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from numpy import *
from PIL import Image
 
flag = Image.open(r"enc.png")
img = array(flag)
 
key = [413723]
 
a, b, c = img.shape
 
for x in range (0, a):
    for y in range (0, b):
        pixel = img[x, y]
        for i in range(0,3):
            for t in range(0,41):
                if (251 * t + pixel[i]) % key[i] == 0:
                    pixel[i] = (251 * t + pixel[i]) / 23
        img[x][y] = pixel
 
enc = Image.fromarray(img)
enc.save('flag.png')
 
cs

 

 

반응형

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

FIESTA 2020 Write up  (2) 2020.09.07
2020 Defenit CTF Write Up  (2) 2020.06.06
UTCTF 2020 Write up  (0) 2020.03.07
RiceTeaCatPanda CTF 2020 Write up  (0) 2020.01.22
Christmas CTF 2019 Write-up 문제 풀이  (2) 2019.12.30
반응형

Team : N0Named

 

 

 

Forensics

 

Observe Closely

50

A simple image with a couple of twists...

by phleisch

 

 

png 파일이 하나 주어진다.

 

 

이미지만 봤을 때는 정상이다. 그럼 hxd로 까보자

 

PNG의 푸터 시그니처인 end를 검색해주었더니 뒤에 PK시그니처가 있는 것을 볼 수 있다.

해당 뒷부분을 추출해서 zip파일로 만들어주면 elf 파일이 하나 존재한다.

 

ida 64bit로 뜯어서 main 함수를 확인하면 flag를 찾을 수 있다.

 

 

 

 

 


 

 

1 Frame per Minute

50

I recently received this signal transmission known as SSTV in a mode called Martian? This technology is all very old so I'm not sure what to do with it. Could you help me out?

by phleisch

 

 

wav 파일이 하나 주어진다.

 

SSTV에 사용되는 것인데

http://users.belgacom.net/hamradio/rxsstv.htm

 

RX-SSTV: Freeware SSTV Software and SSTV Decoder

 

users.belgacom.net

이걸로 디코딩을 할 수 있다.

 

(근데 꼭 마이크로 입력해야돼?)

 


[basics] forensics

50

My friend said they hid a flag in this picture, but it's broken! Now that I think about it, I don't even know if it really is a picture...

 

 

jpeg 파일이 주어진다.

 

이미지로는 안열려서 hxd로 열었다.

 

엥 그냥 plaintext잖아

 

메모장으로 열어서 플래그포멧인 utflag를 검색하니까 플래그가 바로 나왔다.

 

 


 

Spectre

50

I found this audio file, but I don't think it's any song I've ever heard... Maybe there's something else inside?

 

 

이번에도 오디오 파일인데 문제 제목이나 지문을 보면 오디오 스펙트럼을 봐야한다는 감이 온다.

 

 

그럼그럼

 

sonic visualiser 라는 프로그램을 이용하면 된다!

반응형

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

2020 Defenit CTF Write Up  (2) 2020.06.06
angstrom CTF 2020 write up  (0) 2020.03.14
RiceTeaCatPanda CTF 2020 Write up  (0) 2020.01.22
Christmas CTF 2019 Write-up 문제 풀이  (2) 2019.12.30
UTC-CTF 2019 Teaser write-up  (0) 2019.12.22
반응형

1. npm으로 discord.js 설치 후 봇 실행시 발생하는 오류 해결

 

 

 

/Client.js:39
     } catch {
             ^

봇 실행시 위와 같은 오류가 발생할 경우입니다.

 

 

저같은 경우에는 discord.js github에 나와있는 설치방법으로 설치를 했을 경우에 발생하였습니다.

https://github.com/discordjs/discord.js#installation

 

discordjs/discord.js

A powerful JavaScript library for interacting with the Discord API - discordjs/discord.js

github.com

 

 

npm install discordjs/discord.js

 

 

 

 

이 명령어 대신에

https://discord.js.org/#/docs/main/stable/general/welcome

 

Discord.js

Discord.js is a powerful node.js module that allows you to interact with the Discord API very easily. It takes a much more object-oriented approach than most other JS Discord libraries, making your bot's code significantly tidier and easier to comprehend.

discord.js.org

이 문서에 나와있는 명령어를 사용하시면 됩니다.

 

 

npm install discord.js

 

 

 

자신의 node버전을 확인해서 12 이상으로 업데이트 하시면 됩니다.

 

 

 

 


 

 

2. 오디오 재생시 오디오가 재생되지 않고 바로 종료되는 문제

또는 Error: FFMPEG not found 에러 발생시

 

FFMPEG 설치

윈도우

npm install --save ffmpeg-binaries

 

리눅스

sudo apt install ffmpeg

 

 

 


 

3. opus 설치 오류

 

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-opus@0.3.2 install:
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-opus@0.3.2 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

 

 

이런 오류가 발생한다면, sudo를 두 번 사용해주면 된다.

sudo sudo npm install @discordjs/opus
반응형
반응형

Team : N0Named

 

제가 푼 문제만 풀이를 적었습니다.

 

Misc

Strong Password

Eat, Drink, Pet, Hug, Repeat!

flags are entered in the format rtcp{flag}


Hints

  • Words are separated by underscores ("_")

  • Come on, repeat it! Just once!

 

먹는거 마시는거 애완동물 안아주기

반복!

밥 차 고양이 판다

 

flag : rtcp{rice_tea_cat_panda}

 

 

 

 


 

 

Forensics

 

Allergic College Application

100

I was writing my common app essay in Mandarin when my cat got on my lap and sneezed. Being allergic, I sneezed with him, and when I blew my nose into a tissue, the text for my essay turned really weird! Get out, Bad Kitty!

 

 

hxd로 파일 열어서 hex값 복사해다가 아래 사이트에서 인코딩을 변경해주었다.

https://dencode.com/string/hex

 

Hexadecimal String Converter Online - DenCode

Hexadecimal String Converter. (e.g. "Hello, world!" <=> "48 65 6C 6C 6F 2C 20 77 6F 72 6C 64 21")

dencode.com

GB18030 이나 EUC-CN 인코딩을 사용할 경우 다른 글자 깨짐 없이 전부 한자로 깔금하게 나온다.

설마하고 구글번역 돌려보니.. 깔끔한 문장이었다.

 

 

flag : {我_只_修改_了_两_次}

 

 


cat-chat

125

nyameowmeow nyameow nyanya meow purr nyameowmeow nyameow nyanya meow purr nyameowmeow nyanyanyanya nyameow meow purr meow nyanyanyanya nya purr nyanyanyanya nya meownyameownya meownyameow purr nyanya nyanyanya purr meowmeownya meowmeowmeow nyanya meownya meowmeownya purr meowmeowmeow meownya purr nyanyanyanya nya nyameownya nya !!!!

 

냐 냐냐냐냐냐프르르르르르

 

 

사용된 단어는 3가지이다.

In that conversation, 3 word used: nya, meow, purr

 

it seems like morse code.

nya => .

meow => _

purr => /

 

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
MORSE_CODE_DICT = { 'A':'._''B':'_...',
                    'C':'_._.''D':'_..''E':'.',
                    'F':'.._.''G':'__.''H':'....',
                    'I':'..''J':'.___''K':'_._',
                    'L':'._..''M':'__''N':'_.',
                    'O':'___''P':'.__.''Q':'__._',
                    'R':'._.''S':'...''T':'_',
                    'U':'.._''V':'..._''W':'.__',
                    'X':'_.._''Y':'_.__''Z':'__..',
                    '1':'.____''2':'..___''3':'...__',
                    '4':'...._''5':'.....''6':'_....',
                    '7':'__...''8':'___..''9':'____.',
                    '0':'_____'', ':'__..__''.':'._._._',
                    '?':'..__..''/':'_.._.''_':'_...._''_':'..__._',
                    '(':'_.__.'')':'_.__._'' ':'/''\n':'\n''':''':':"___..."'\'':'.____.'}
 
 
 
def decrypt(message):
    message += ' '
    message = message.replace("nya",".")
    message = message.replace("meow","_")
    message = message.replace("purr","/")
    decipher = ''
    citext = ''
    for letter in message:
        if (letter != ' ' and letter != '\n'):
            i = 0
            citext += letter
 
        else:
            i += 1
 
            if i == 2 :
                decipher += ' '
            else:
 
                decipher += list(MORSE_CODE_DICT.keys())[list(MORSE_CODE_DICT.values()).index(citext)]
                citext = ''
 
    return decipher
 
def main():
    message = '''nyameowmeow nyameow nyanya meow purr nyameowmeow nyameow nyanya meow purr nyameowmeow nyanyanyanya nyameow meow purr meow nyanyanyanya nya purr nyanyanyanya nya meownyameownya meownyameow purr nyanya nyanyanya purr meowmeownya meowmeowmeow nyanya meownya meowmeownya purr meowmeowmeow meownya purr nyanyanyanya nya nyameownya nya'''
    result = decrypt(message)
    print(result)
 
if __name__ == '__main__':
    main()
 
cs
WAIT WAIT WHAT THE HECK IS GOING ON HERE

good

 

than, go to the discord channel and copy all of the cat-chat and decode it!

 

 

than you can find this:

RTCP:TH15_1Z_A_C4T_CH4T_N0T_A_M3M3_CH4T

 

flag : RTCP{TH15_1Z_A_C4T_CH4T_N0T_A_M3M3_CH4T}

 

 


 

Chugalug's Footpads

Chugalug makes footpads that he can chug and lug. However, his left one is different from his right... I wonder why?

 

 

I downloaded 2 files: left.jpg and right.jpg

They seems that they are perfectly same, but they are not.

 

I used cmp command to find different data between left.jpg and right.jpg.

 

$ cmp -l right.jpg left.jpg 
  1720 122 162
  1721 115 164
  2041 105 143
  2042 121 160
  2328 160 173
  2329 165 124
  2330 102 150
  2854 240  63
  2855  63 172
  2856 154 145
  3016 144 137
  3017 201 136
  3019  24 162
  3110 161  63
  3332  14 137
  3626  21 156
  3627 232  60
  4215 112 124
  4405  40 143
  4413   2 110
  4775  62  64
  4776 347 156
  5125  57 103
  5149 114  61
  5150 112 141
  5400 364  65
  5401 362 175

 

1
2
3
4
5
6
7
= [162,164,143,160,173,124,150,63,172,145,137,136,162,63,137,156,60,124,143,110,64,156,103,61,141,65,175]
 
flag = ""
for cc in c:
    flag += chr(int(str(cc), 8))
print flag
 
cs

 

flag : rtcp{Th3ze_^r3_n0TcH4nC1a5}

 

 

 


Motivational Message

My friend sent me this motivational message because the CTF organizers made this competition too hard, but there's nothing in the message but a complete mess. I think the CTF organizers tampered with it to make it seem like my friend doesn't believe in me anymore, but it's working like reverse psychology on me!!!!

 

 

motivation!!!!!.txt 파일 하나가 주어진다.

 

It's reversed PNG file!

 

reverse it!

 

< motivation.txt xxd -p -c1 | tac | xxd -p -r > file.png

 

But there is no flag in picture.

 

 

I used zsteg and i can find a flag!

 

 

 


Web

 

growls at the chicken

grrrrrrR
big chicken, i hisS At you!!!


Hints

NQr2MIa1jsaifAVOn3zYeMynNJwd4oBiiem4fJHsA1WjzfyhUp1+seCW0GMijoDHb3w9BMKj7aw6hhtae5/Qw5xOqMioJU3vvEj0BEHO1wInPqlOeTRdZb8BcTsXP+Z/KBA2FjSZcpGHo7rOZ7NtR15y3eY4s/e/tgKUHvPe9MdmDe1kINtyRXgjghJO9e3uMEQmFe2Ai5moVnG7yIVfUd3QG6/Z+K4PSttbJtjWSLFO7zpmYpEOg3XBxsOw/w5scJQqJ7OLGiH22u4+JFXRlD/wPmDzk9uYlLWLcCuxnY0xuMlSfKIFJtVmF0ViO4o4X89ZwsQjjHuYYDaB3el7iA63BzBlsC54Q7Ekv70/GI0UA3R3zJkMaBV12Z6NAE/kAgEJu9ZRcVm6MAIZInLwMU4R1frM0Bks1jeTe72agmxnAIrR8XDeAxzovbvXFwoxNyxiA63fPJGPVoGZq4ecfGvJ23i/Cg+cynB35lc3f+4QifpjCn+MxWkKCzCVEJXdDah19yXKlIxbaR1zm+YHkS0YSUzjr7NJUXHfDCrwAUpXpikfi2f9tgcXEnuhszScE1PCbdt22rRz1pS7MNdRxjCZ5j+8BQNRBLi2BjLGW14X3zd4d6ieoHWH+4fmbqU9dFsUgKN5qL4Gs2LZbbQwkf3+VbIRQK9RaSO9Hj+4/T0=

 

Public

MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAmy27XroKLfED3q32/K7G +TnREe2ZkSgceDJH9X+Jf2I++kJHxNxe5HbQBdTHW/tLTWxwMEpric9zGFlt1f76 zdG2iocGw81BVznN/btVAYJBGbhJPYTeULSCv4WG+NTrss8NSl6WGS9NCOKEWTA/ JjR1z8fXik5foTK18sLJloRFGmxcKV6ZI0VFEi77U6PouOseaPBRYgVlPAjNM/pl AuJotPjFYtNTQWCgpj+Vgt3cxm9erBl8G9K9rIsK6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PfBo798/JoucQKCAQBw2Vm2CUbWC1IlgHU2rEngB1F1 c6asxmpIn3j4EiigwO+27G9cmpQ54CvRjp18Fw2/ZABok8C8edm+VMtWRd5gXFTP K7lmWJnGJ0W2eGcjdOCrHZx3sFxoer0Vdy3dQbcWtAQJhqUBbIqCwLkWIQgrsNdl CQiaeKqBz0cQrj6UkNs2qXfjzTg8xPgR/Yapps4O9yoJUKpVUiMlcHgRGi/wsgHx Mq/Ghvz6tYMW7zIXjgYw575Nd9BJy+si9dXShsFmwFQ0MoU0uHFI5oGTGvqc07j8 eVFNV+dm4dr9Irt0qhSHxcaVCyDs36bXz7S0kSgvECV1QhgtFQPOrVQdgsTn

 

 

 

 

Add -----BEGIN RSA PRIVATE KEY----- and -----END RSA PRIVATE KEY----- to head and bottom of prviate base64 strings. than make private.txt

 

 

1
2
3
4
5
6
7
8
9
10
11
12
13
from Crypto.PublicKey import RSA
from Crypto.Cipher import PKCS1_v1_5 as Cipher_PKCS1_v1_5
from base64 import b64decode
 
enc ='''
NQr2MIa1jsaifAVOn3zYeMynNJwd4oBiiem4fJHsA1WjzfyhUp1+seCW0GMijoDHb3w9BMKj7aw6hhtae5/Qw5xOqMioJU3vvEj0BEHO1wInPqlOeTRdZb8BcTsXP+Z/KBA2FjSZcpGHo7rOZ7NtR15y3eY4s/e/tgKUHvPe9MdmDe1kINtyRXgjghJO9e3uMEQmFe2Ai5moVnG7yIVfUd3QG6/Z+K4PSttbJtjWSLFO7zpmYpEOg3XBxsOw/w5scJQqJ7OLGiH22u4+JFXRlD/wPmDzk9uYlLWLcCuxnY0xuMlSfKIFJtVmF0ViO4o4X89ZwsQjjHuYYDaB3el7iA63BzBlsC54Q7Ekv70/GI0UA3R3zJkMaBV12Z6NAE/kAgEJu9ZRcVm6MAIZInLwMU4R1frM0Bks1jeTe72agmxnAIrR8XDeAxzovbvXFwoxNyxiA63fPJGPVoGZq4ecfGvJ23i/Cg+cynB35lc3f+4QifpjCn+MxWkKCzCVEJXdDah19yXKlIxbaR1zm+YHkS0YSUzjr7NJUXHfDCrwAUpXpikfi2f9tgcXEnuhszScE1PCbdt22rRz1pS7MNdRxjCZ5j+8BQNRBLi2BjLGW14X3zd4d6ieoHWH+4fmbqU9dFsUgKN5qL4Gs2LZbbQwkf3+VbIRQK9RaSO9Hj+4/T0=
'''
 
rsa_key = RSA.importKey(open('private.txt'"rb").read())
cipher = Cipher_PKCS1_v1_5.new(rsa_key)
raw_cipher_data = b64decode(enc)
phn = cipher.decrypt(raw_cipher_data, None)
print(phn)
cs

 

plain text : unknown-123-246-470-726.herokuapp.com/

 

 

 

 

1
2
3
4
5
6
7
8
= [9,20,30,15,16,5,14,19,30,27,29,8,20,13,12,28]
ss = "0abcdefghijklmnopqrstuvwxyz[]. "
= ""
for i in range(len(s)):
    f+= ss[s[i]]
 
print f
 
cs

it opens [.html]

 


 

 

Cryptography

 

15

Lhzdwt eceowwl: Dhtnwt Pcln Eaao Qwoohvw

Okw qsyo okcln bah'i fslo cl baht Dhtnwt Pcln dhtnwt cy yazwalw'y eaao ehlnhy. Dho sy co ohtly aho, okso zcnko dw fkso bah nwo. S 4vksllwt hmqasiwi s mkaoa slalbzahyqb oa okw ycow ykafvsycln kcy ewwo cl s mqsyocv dcl ae qwoohvw, fcok okw yosowzwlo: "Okcy cy okw qwoohvw bah wso so Dhtnwt Pcln." Sizcoowiqb, kw ksi ykawy al. Dho okso'y wgwl fatyw.

Okw mayo fwlo qcgw so 11:38 MZ al Xhqb 16, sli s zwtw ofwlob zclhowy qsowt, okw Dhtnwt Pcln cl rhwyocal fsy sqwtowi oa okw tanhw wzmqabww. So qwsyo, C kamw kw'y tanhw. Kaf ici co ksmmwl? Fwqq, okw DP wzmqabww ksil'o twzagwi okw WJCE isos etaz okw hmqasiwi mkaoa, fkcvk yhnnwyowi okw vhqmtco fsy yazwfkwtw cl Zsbecwqi Kwcnkoy, Akca. Okcy fsy so 11:47. Oktww zclhowy qsowt so 11:50, okw Dhtnwt Pcln dtslvk siitwyy fsy mayowi fcok fcykwy ae ksmmb hlwzmqabzwlo. Ecgw zclhowy qsowt, okw lwfy yosocal fsy valosvowi db slaokwt 4vksllwt. Sli oktww zclhowy qsowt, so 11:58, s qclp fsy mayowi: DP'y "Owqq hy sdaho hy" alqclw eathz. Okw eaao mkaoa, aokwtfcyw plafl sy wjkcdco S, fsy soosvkwi. Vqwgwqsli Yvwlw Zsnsuclw valosvowi okw DP cl rhwyocal okw lwjo isb. Fkwl rhwyocalwi, okw dtwspesyo ykceo zslsnwt ysci "Ak, C plaf fka okso cy. Kw'y nwoocln ectwi." Zbyowtb yaqgwi, db 4vksl. Laf fw vsl sqq na dsvp oa wsocln aht esyo eaai cl mwsvw.

tovm{v4T3Ehq_f1oK_3J1e_i4O4}

 

치환암호다.

https://quipqiup.com/

 

quipqiup - cryptoquip and cryptogram solver

 

quipqiup.com

 

 

flag : rtcp{c4R3Ful_w1tH_3X1f_d4T4}

 

 


 

That's a Lot of Stuff...

Do you want some numbers? Here, take these numbers. I don't need them anyways. I have too many numbers at home, so go on, take them. Shoves numbers towards the computer screen

31 31 35 20 31 32 34 20 31 34 37 20 31 34 37 20 31 31 35 20 31 35 32 20 31 30 31 20 31 34 37 20 31 31 35 20 31 37 31 20 31 30 31 20 31 37 30 20 31 31 36 20 31 35 31 20 31 30 31 20 31 37 32 20 31 31 31 20 31 30 34 20 31 30 35 20 36 30 20 31 31 31 20 31 30 34 20 31 31 31 20 31 37 31 20 31 31 31 20 31 30 34 20 31 30 35 20 36 34 20 31 31 31 20 31 30 34 20 31 30 35 20 36 35 20 31 31 31 20 31 30 34 20 31 30 35 20 36 30 20 31 31 31 20 31 30 34 20 31 30 35 20 36 35 20 31 31 31 20 31 30 34 20 31 30 35 20 31 34 37 20 31 31 35 20 31 32 34 20 31 34 37 20 31 34 37 20 31 31 35 20 31 37 31 20 31 30 31 20 31 37 30 20 31 31 35 20 31 35 31 20 31 30 31 20 31 37 32 20 31 31 31 20 31 30 34 20 31 31 31 20 31 36 37 20 31 31 31 20 31 30 34 20 31 30 35 20 36 35

 

hex -> oct -> dec

 

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
task = '''36 31 20 36 31 20 36 34 20 34 30 20 36 31 20 36 31 20 36 36 20 34 30 20 37 31 20 37 31 20 34 30 20 36 31 20 36 31 20 36 32 20 34 30 20 36 31 20 36 32 20 36 33 20 34 30 20 37 31 20 37 31 20 34 30 20 36 34 20 37 30 20 34 30 20 36 31 20 36 31 20 36 30 20 34 30 20 36 31 20 36 31 20 37 30 20 34 30 20 36 35 20 36 31 20 34 30 20 36 31 20 36 31 20 36 34 20 34 30 20 36 31 20 36 31 20 36 35 20 34 30 20 36 34 20 37 31 20 34 30 20 36 34 20 37 30 20 34 30 20 36 31 20 36 31 20 36 30 20 34 30 20 36 31 20 36 31 20 36 35 20 34 30 20 37 31 20 36 35 20 34 30 20 37 31 20 36 37 20 34 30 20 36 31 20 36 31 20 36 34 20 34 30 20 36 35 20 36 31 20 34 30 20 37 31 20 36 35 20 34 30 20 36 35 20 36 32 20 34 30 20 37 31 20 36 35 20 34 30 20 37 31 20 37 31 20 34 30 20 36 34 20 37 30 20 34 30 20 36 34 20 37 30 20 34 30 20 36 37 20 36 36 20 34 30 20 37 31 20 36 35 20 34 30 20 37 31 20 37 31 20 34 30 20 36 35 20 36 32 20 34 30 20 36 31 20 36 31 20 36 36 20 34 30 20 36 31 20 36 31 20 36 35 20 34 30 20 36 31 20 36 32 20 36 35'''
 
task = task.replace(" "",")
print task
 
###
 
= [36,31,20,36,31,20,36,34,20,34,30,20,36,31,20,36,31,20,36,36,20,34,30,20,37,31,20,37,31,20,34,30,20,36,31,20,36,31,20,36,32,20,34,30,20,36,31,20,36,32,20,36,33,20,34,30,20,37,31,20,37,31,20,34,30,20,36,34,20,37,30,20,34,30,20,36,31,20,36,31,20,36,30,20,34,30,20,36,31,20,36,31,20,37,30,20,34,30,20,36,35,20,36,31,20,34,30,20,36,31,20,36,31,20,36,34,20,34,30,20,36,31,20,36,31,20,36,35,20,34,30,20,36,34,20,37,31,20,34,30,20,36,34,20,37,30,20,34,30,20,36,31,20,36,31,20,36,30,20,34,30,20,36,31,20,36,31,20,36,35,20,34,30,20,37,31,20,36,35,20,34,30,20,37,31,20,36,37,20,34,30,20,36,31,20,36,31,20,36,34,20,34,30,20,36,35,20,36,31,20,34,30,20,37,31,20,36,35,20,34,30,20,36,35,20,36,32,20,34,30,20,37,31,20,36,35,20,34,30,20,37,31,20,37,31,20,34,30,20,36,34,20,37,30,20,34,30,20,36,34,20,37,30,20,34,30,20,36,37,20,36,36,20,34,30,20,37,31,20,36,35,20,34,30,20,37,31,20,37,31,20,34,30,20,36,35,20,36,32,20,34,30,20,36,31,20,36,31,20,36,36,20,34,30,20,36,31,20,36,31,20,36,35,20,34,30,20,36,31,20,36,32,20,36,35]
 
flag = ""
for aa in a:
    flag += chr(int(str(aa), 16))
flag = flag.replace(" "",")
print flag
 
###
 
= [61,61,64,40,61,61,66,40,71,71,40,61,61,62,40,61,62,63,40,71,71,40,64,70,40,61,61,60,40,61,61,70,40,65,61,40,61,61,64,40,61,61,65,40,64,71,40,64,70,40,61,61,60,40,61,61,65,40,71,65,40,71,67,40,61,61,64,40,65,61,40,71,65,40,65,62,40,71,65,40,71,71,40,64,70,40,64,70,40,67,66,40,71,65,40,71,71,40,65,62,40,61,61,66,40,61,61,65,40,61,62,65]
 
flag = ""
for bb in b:
    flag += chr(int(str(bb), 8))
flag = flag.replace(" "",")
print flag
 
###
 
= [114,116,99,112,123,99,48,110,118,51,114,115,49,48,110,115,95,97,114,51,95,52,95,99,48,48,76,95,99,52,116,115,125]
 
flag = ""
for cc in c:
    flag += chr(int(str(cc), 10))
print flag
 
cs

 


 

General Skills

Treeeeeeee

It appears that my cat has gotten itself stuck in a tree... It's really tall and I can't seem to reach it. Maybe you can throw a snake at the tree to find it?

Oh, you want to know what my cat looks like? I put a picture in the hints.


Hints

Here, my cat looks like this:

#FFC90E#000000#FFC90E#FFFFFF#FFFFFF#FFFFFF#FFFFFF#FFC90E#FFFFFF #FFC90E#FFC90E#FFC90E#FFC90E#FFC90E#FFC90E#FFC90E#FFFFFF#FFFFFF #FFFFFF#FFFFFF#FFC90E#FFC90E#FFC90E#FFC90E#FFC90E#FFFFFF#FFFFFF #FFFFFF#FFFFFF#FFC90E#FFC90E#FFC90E#FFC90E#FFC90E#FFFFFF#FFFFFF #FFFFFF#FFFFFF#FFFFFF#FFC90E#FFFFFF#FFC90E#FFFFFF#FFFFFF#FFFFFF

 

 

Bigtree/ has 29,185 items, totalling 116.2 MB.

 

수많은 폴더에 jpg 파일들이 숨어있다.

 

To gather .jpg files in one folder, I used find & exec command.

 

bigtree$ find . -type f -name "*.jpg" -exec mv {} ./flag \;

 

All of .jpg files move to ./flag/

 

Now, easily find flag file which has different file size.

 

flag file : 2.2KB

others : 1.5KB, 1.7KB

 

반응형

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

angstrom CTF 2020 write up  (0) 2020.03.14
UTCTF 2020 Write up  (0) 2020.03.07
Christmas CTF 2019 Write-up 문제 풀이  (2) 2019.12.30
UTC-CTF 2019 Teaser write-up  (0) 2019.12.22
X-MAS CTF 2019 X-MAS Helper write-up  (0) 2019.12.21
반응형

30초 마다 경고창과 함께 크롬/파이어폭스로 특정 주소 창 띄우기

 

 

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
@echo off
echo msgbox "아무거나 막 실행하지 말자",0,"수상한 프로그램" > msg.vbs
start /wait msg.vbs
del msg.vbs
 
:_loop
start chrome https://www.youtube.com/watch?v=zwhbV4LfBrc^&t=148s
start chrome https://mandu-mandu.tistory.com
start firefox https://www.youtube.com/watch?v=zwhbV4LfBrc^&t=148s
 
timeout 30 > NUL
 
echo msgbox "귀여우셔라",0,"o kawaii koto" > msg.vbs
start /wait msg.vbs
del msg.vbs
 
goto _loop
 
cs

 

 

위 코드 내용을 메모장에 붙여넣기 하고 파일명.bat 으로 저장하시면 됩니다.

한글을 사용하실 경우 인코딩은 ANSI로 설정하시면 됩니다.

 

 

 

 

Bat_To_Exe_Converter 를 이용해서 bat파일을 exe파일로 변환해줍니다.

 

 

'보이지않는 응용프로그램'으로 해두셔야 프로그램을 실행했을 때 콘솔창이 뜨지 않습니다.

 

 

 

 

 

프로그램 종료 방법


Ctrl + Shift + ESC = 작업관리자

 

세부정보 탭

 

실행한 프로그램명을 찾아서 [작업끝내기]

cmd.exe 찾아서 전부 [작업끝내기]

반응형

+ Recent posts