반응형
반응형
반응형

Forensics

SHIFT

anyconv.com/ko/png-to-raw-byeonhwangi/

 

PNG RAW 변환: 온라인에서 PNG를 RAW로 변환하십시오

⭐ AnyConv는 5 성급 PNG RAW 변환기입니다 ⭐ 온라인에서 png를 raw로 몇 초 안에 변환하십시오 ✅ 소프트웨어 설치가 필요하지 않습니다 ✅ 무료로 ✅ 완전히 안전합니다. PNG를 RAW로 쉽게 변경할 수

anyconv.com

png to bmp

 

rename .bmp to .data

 

open with GIMP

 

width 5261

 


Doubly Deleted Data


Sandwiched

You can see that there are several pdf files, and you can see that there is a jpg file in between.

 

However, jpg's footer signature can be found far away.

There are parts of the jpg file between the pdf files.

 

The extracted jpg file had a flag.

 


OSINT Part 1

 

search name in twitter


OSINT Part 2

 

google image search

 


Small P Problems

Diffie–Hellman

github.com/DrMMZ/Attack-Diffie-Hellman/blob/master/AttackDH.py

 

DrMMZ/Attack-Diffie-Hellman

Implementation of cryptanalysis of Diffie-Hellman public key protocol in Python - DrMMZ/Attack-Diffie-Hellman

github.com


Beginner

Various Vernacular

quipqiup.com/

 

quipqiup - cryptoquip and cryptogram solver

 

quipqiup.com

반응형

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

LINE CTF 2021 write up  (0) 2021.03.21
Codefest CTF 2021 Write up  (0) 2021.03.20
vishwaCTF 2021 Write up  (0) 2021.03.15
NahamCon CTF 2021 write up  (0) 2021.03.15
dvCTF 2021 Write up  (2) 2021.03.15
반응형
반응형

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

Codefest CTF 2021 Write up  (0) 2021.03.20
UTCTF 2021 write up  (0) 2021.03.15
NahamCon CTF 2021 write up  (0) 2021.03.15
dvCTF 2021 Write up  (2) 2021.03.15
BCA CTF 2021 Write up  (0) 2021.03.14
반응형

layers.txt

bin2ascii

oct2ascii

hex2ascii

base64decode

base85decode


Chimera

Open chimera.bin.img using FTK Imager.

 

I found key.docx.

extract it and rename key.docx to key.zip

 

hmm __main__.py ?

zip password key...

but i couldn't find any zip file.

 

so, i opened chimera.bin.img with HxD.exe. Then i searched "flag".

 

flag.png in flag.zip

good

it is in pdf file stream, but i couldn't find any pdf file. so i just carved it.

it says the file is corrupted, but i can get 61% unziped flag.png

 

 

it is half of flag, but we can read flag :)


Glitch in the matrix

 

DQT : en.wikibooks.org/wiki/JPEG_-_Idea_and_Practice/The_header_part#The_Quantization_table_segment_DQT

 

JPEG - Idea and Practice/The header part

The markers[edit] The header part of a JPEG file is divided into segments, and each segment starts with a marker, identifying the segment. Usually a JPEG file contains 7 different markers. A marker is a pair of bytes, the first is 255 and the second is dif

en.wikibooks.org

 

The DQT area is intentionally covered with 0xFF.

To recover DQT area, I copied and pasted the DQT area of other normal jpg files downloaded from the google.

After many attempts, I could read a flag.

 

we_need_bits_lots_of_bits


Net Matroyshka

 

8.pcap

 

7.pcap

 

 

6.pcap

 

copy&paste rsync data and sum data

 

5.pcap

 

follow > udp stream

 

make 4.zip

no footer signature in 5.pcap.

i think i extracted 5.zip wrong because 5.zip said zip file is corrupted.

 

i couldn't extract 5.zip correctly..

 


Tapesplice

BZh91AY&SY is bz2 header signature

 


denouement.png

use zsteg


Résumé

just copy and paste


Charge Tracker

 

dex2jar sourceforge.net/projects/dex2jar/

 

dex2jar

Download dex2jar for free. Tools to work with android .dex and java .class files. Mirrors: * https://bitbucket.org/pxb1988/dex2jar * https://github.com/pxb1988/dex2jar dex2jar contains following compment * dex-reader is designed to read the Dalvik Executab

sourceforge.net

 

open .jar using jd-gui java-decompiler.github.io/

 

Java Decompiler

The “Java Decompiler project” aims to develop tools in order to decompile and analyze Java 5 “byte code” and the later versions. JD-GUI is a standalone graphical utility that displays Java source codes of “.class” files. You can browse the reco

java-decompiler.github.io

 

part1 is here.

done.


Hashcrack 101

www.tunnelsup.com/hash-analyzer/

 

Hash Analyzer - TunnelsUP

Hash type: Bit length: Base: Example Hash Inputs 5f4dcc3b5aa765d61d8327deb882cf99MD5 5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8SHA1 5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8SHA256 $2a$10$N9qo8uLOickgx2ZMRZoMyeIjZAgcfl7p92ldGxad68LJZdL1

www.tunnelsup.com

1~4 : DES (Unix)

5~9 : md5crypt, MD5 (Unix)

10~13 : sha512crypt $6$, SHA512 (Unix)

 

use hashcat

hashcat.net/wiki/doku.php?id=example_hashes

 

example_hashes [hashcat wiki]

Example hashes If you get a “line length exception” error in hashcat, it is often because the hash mode that you have requested does not match the hash. To verify, you can test your commands against example hashes. Unless otherwise noted, the password

hashcat.net

combination bruteforce attack

dictonary attack

 

반응형

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

dvCTF 2021 Write up  (2) 2021.03.15
BCA CTF 2021 Write up  (0) 2021.03.14
TRUST CTF 2021 write up  (0) 2021.02.28
Tenable CTF 2021 write up  (0) 2021.02.23
Union CTF 2021 Write up  (0) 2021.02.22
반응형

비트에 몸을 맡겨라!

브포 때려서 말이 되는거 찾아서 넣으면 된다.


blank

whitespace -> directory indexing -> whitespace

vii5ard.github.io/whitespace/

 

Whitelips the Whitespace IDE

Stack: Heap:

vii5ard.github.io


TRUST's math class

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 sympy import *
from pwn import *
 
def cleaneqn(s):
    s = str(s)
    s = s.replace("b'""")
    s = s.replace("=0\\n'","")
    s = s.replace("x","*x")
    s = s.replace("y","*y")
    return s
 
def solveeqn(a1, a2): #연립방정식 풀어서 x와 y값 구하기
    x, y = symbols('x y')
    return eval("solve( [ Eq("+a1+" ,0), Eq("+a2+", 0) ], [x,y] )"#입력 형태 맞춰 넣기가 애매해서 eval함수 사용했습니다.
 
def solve_func(e):
    x, y = symbols('x y')
 
    for i in range(2):
        e[i] = cleaneqn(e[i]) #입력받은 방정식을 sympy가 입력받을 수 있는 형태로 변환
 
    ans = solveeqn(e[0], e[1]) #교점 좌표 구하기
    print(ans[x])
    return ans[x], ans[y]
 
#main
equation = ["0"]*2 #방정식을 저장하기 위함
= remote("n1net4il.xyz"31339)
p.recvuntil("===== TRUST's Math Class =====\n")
for i in range(0100):
    equation[0= p.recvline()
    equation[1= p.recvline()
    for j in range(2):
        print(equation[j])
    x, y = solve_func(equation)
    p.recvuntil(":")
    p.sendline(str(eval(str(x))))
    p.recvuntil(":")
    p.sendline(str(eval(str(y))))
 
p.interactive()
 
cs

Listen PIZ!!

pptx 파일을 zip으로 바꾸고

slide23.xml을 보면

base64 문자열이 있다.


ultimate hacking defense

vmdk 파일이 주어진다.

ftk imager로 열자

필요한 파일들은 뭘까 문제 지문을 잘 읽어보자.

 

해커가 가장 마지막으로 접속했던 웹사이트에서 해킹툴을 다운받았고, 터미널에서 TRUST 서버를 공격하기 위해 여러 명령어들을 썼다는 정보를 입수했다

마지막으로 접속한 웹사이트, 터미널

인터넷 접속 기록과 터미널 입력 기록을 살펴보면 되겠다.

 

크롬, 파폭, 웨일등의 브라우저가 설치되지 않았다.

바로 ie를 보면 되겠다.

ie 히스토리 (C:\Users\user\AppData\Local\Microsoft\Internet Explorer\Recovery\Last Active\{7A1FA2C8-7768-11EB-94AC-001A7DDA7113}.dat)를 직접 봐도 되겠지만

ie에 마지막으로 입력한 url 기록은 NTUSER.DAT에서도 찾아볼 수 있다.

해당 파일을 추출하여 regripper을 돌려준다.

forensic.korea.ac.kr/DFWIKI/index.php/RegRipper

 

RegRipper - Digital Forensic Wikipedia

Regripper는 Harlan Carvey에서 개발한 레지스트리 분석 도구로 오픈소스로 제공된다. 최신 업데이트는 2013년 4월이며, 최신 버전은 v2.8이다. 본 항에서는 최신버전인 v2.8버전을 사용하였다. Regripper는 C

forensic.korea.ac.kr

해당 페이지에 들어가면 플래그 뒷부분을 얻을 수 있다.

 

 

이어서, 최근 문서에서 consolehost_history.txt를 볼 수 있다.

파워쉘을 사용했다는 것을 알 수 있다.

해당 파일을 찾아 추출하자

C:\Users\Devleo\AppData\Roaming\Microsoft\Windows\Powershell\PSReadLine\ConsoleHost_history.txt

플래그 앞부분 TRUST{ 를 검색하면 된다.

반응형

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

BCA CTF 2021 Write up  (0) 2021.03.14
BSidesSF CTF 2021 write up  (0) 2021.03.09
Tenable CTF 2021 write up  (0) 2021.02.23
Union CTF 2021 Write up  (0) 2021.02.22
darkCON CTF 2021 write up  (0) 2021.02.21
반응형

blockchain

sanity check

remix.ethereum.org/

 

Remix - Ethereum IDE

 

remix.ethereum.org

 

 

code copy&paste

compile

connect metamask rinkeby wallet, load contract address and call welcome func. done.


secure enclave

0x9B0780E30442df1A00C6de19237a43d4404C5237

 

It can store text and return text

I thought constroctor of this contract store the flag in this contract.

When you call set_secret to store some string, transaction occurs.

 

I could find a transaction at etherscan

 


crackme.sol

0xDb2F21c03Efb692b65feE7c4B5D7614531DC45BE

 

"arg3 is a overflow" is a hint in line 6.

uint MaxValue + 1 = 0

so, i can pass line 7 and 11 condition.

 

uint is short for uint256, so maximum value is 2**256-1

arg3 = 115792089237316195423570985008687907853269984665640564039457584007913129639935

arg1 = 20 ^ 0x70 = 100

decrypt(arg2) = "offshift ftw"

 

ah just brute force a-z :)

arg2 = evvixyvj vjm

 

"100","evvixyvj vjm","115792089237316195423570985008687907853269984665640564039457584007913129639935"

 

compile error

To find correct uint array size, brute force all value.

 

if size is over 26 :

if size is equal 26:

got a flag.

 


crypto casino

0x186d5d064545f6211dD1B5286aB2Bc755dfF2F59

Edit code to get ouput value correctly.

To get a flag, need guessing and correct two times.

seed = b37c910f4e0df0efafb35a55489604369808b6de642ff1dbab5062680afaddcd

 

the block.number is the number of the mined block containing the transaction.

 

deploy a contract that returning result of uint(keccak256(abi.encodePacked(seed, block.number+3))) ^ 0x539

get block.number and hash

hash <= block.number <= 7956519 + 3

Then pend transaction that call bet(60284626633715439770582715312106605696128214001910194886489589200393495573074) before #7956522 block mined.


hmm out of gas

 

increase gas price and gas limit.

done.


RICH CLUB

0xC7bEc01281648D3A7F9BB86B811A2de5B1E0cc61

hmm

 

for line 21, swap eth to uniswap app.uniswap.org/#/swap

 

Uniswap Interface

 

app.uniswap.org

600 -> 601

hmm

grant_membership() function에 pubkey를 넘겨주면 encoded flag를 넘겨준다고 한다.
그럼 그걸 decrypt 하면 된다고 하는데

그럼 solidity 코드는 어떻게 수정해서 써먹어야되는거야 :(

crypto

factorize

 

p와 q의 상위 512비트는 base로 동일함.

따라서 sqrt(n)의 상위 512비트와 동일.

hmm

엥 그냥 factorize 돌리면 됐었던 문제였넹

optimizer

별거 없다. simple.

주어진 배열 정렬할 때 이동 횟수 구해서 입력해주면 된다.


pyjail

 

hmm

 


0x414141

go to www.offshift.io/

 

You are being redirected...

 

www.offshift.io

go to github

github.com/offshift-dev

 

offshift-dev - Overview

Cryptographically private offshore storage & DeFi protocol on Ethereum - offshift-dev

github.com

There are two commits in january 2021

 

 

interesting

 

 

click

 

download pyc file.

 

 

decompile pyc using uncompyle6

 

 

decrypt

 

a link!

 

download a smashing.pdf via mega link.

 

 

hmm is it xor?

 

 

correct!

 

 

bitcoin paper..?

 

compare with smashing.pdf and original bitcoin paper pdf.

smashing.pdf is a little bigger.

 

a zip file is here :)

 

 

is locked.

 

dictionary attack

dictionary file i used : rockyou.txt

 

 

i got it

 


file reader

it filters "/flag.txt"

but we can get all .txt files using glob.glob("*.txt").

 


Shjail

 

eval eval py{r..u}hon\\ -m\\ S{h..j}mpleHTTPServer\\;

 

hmm

perl flag.[a-z][a-z][a-z]

web

graphed 2.0

 

there is a input form

 

There is a code send graphql query.

 

gist.github.com/craigbeck/b90915d49fda19d5b2b17ead14dcd6da

 

Introspection query for GraphQL

Introspection query for GraphQL. GitHub Gist: instantly share code, notes, and snippets.

gist.github.com

 

i found a fake flag :(

 

no flag in users

 

no flag in coolnotes

hmm

아 역시 getNote를 사용하는 것이었다.
하나 남은게 getNote였는데, q에 뭐가 들어가는지 몰라서 포기했는데..
쿼리문을 넣어버리는 거였넹.

maze

 

 

./robots.txt

./robots.txt

./sup3r_secr37_@p1

good.

 

 

hmm

 

아 username이 pop_eax가 아니라 XFT였다.

 


hackme

?cmd=help

?cmd=123456

hmm

nl /*
nl *

>cat
* /f*
반응형

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

TrollCAT CTF write up  (0) 2021.02.07
justCTF 2020 write up  (0) 2021.02.01
ShadowCTF write up  (0) 2021.01.27
starCTF 2021 write-up  (0) 2021.01.18
The Cyber Grabs CTF 0x02 write up  (0) 2021.01.17
반응형

*CTF 2021 
Crypto

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
from random import randint
import os
 
flag = "flag"
N=64
key=randint(0,2**N)
print key
key=bin(key)[2:].rjust(N,'0')
count=0
while True:
    p=0
    q=0
    new_key=''
    zeros=[0]
    for j in range(len(key)):
        if key[j]=='0':
            zeros.append(j)
    p=zeros[randint(0,len(zeros))-1]
    q=zeros[randint(0,len(zeros))-1]
    try:
        mask=int(raw_input("mask:"))
    except:
        exit(0)
    mask=bin(mask)[2:]
    if p>q:
        tmp=q
        q=p
        p=tmp
    cnt=0
    for j in range(0,N):
        if j in range(p,q+1):
            new_key+=str(int(mask[cnt])^int(key[j]))
        else:
            new_key+=key[j]
        cnt+=1
        cnt%=len(mask)
    key=new_key
    try:
        guess=int(raw_input("guess:"))
    except:
        exit(0)
    if guess==int(key,2):
        count+=1
        print 'Nice.'
    else:
        count=0
        print 'Oops.'
    if count>2:
        print flag
 
cs

랜덤 key를 생성하고

generate random key

mask 값을 입력받아 여러번 xor을 해서

xor mask value and key

만들어진 key값을 3번 맞추면 되는데

need guessing key 3 times

 

mask에 0을 넣으면 xor을 몇 번을 하던지 그대로다.

however, when you put 0 in mask, xor calculation is useless.


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
from random import randint
import os
from flag import flag
N=64
key=randint(0,2**N)
# print key
key=bin(key)[2:].rjust(N,'0')
count=0
while True:
    p=0
    q=0
    new_key=''
    zeros=[0]
    for j in range(len(key)):
        if key[j]=='0':
            zeros.append(j)
    p=zeros[randint(0,len(zeros))-1]
    q=zeros[randint(0,len(zeros))-1]
    try:
        mask=int(raw_input("mask:"))
    except:
        exit(0)
    mask=bin(mask)[2:]
    if p>q:
        tmp=q
        q=p
        p=tmp
    cnt=0
    for j in range(0,N):
        if j in range(p,q+1):
            new_key+=str(int(mask[cnt])^int(key[j]))
        else:
            new_key+=key[j]
        cnt+=1
        cnt%=len(mask)
    key=new_key
    try:
        guess=int(raw_input("guess:"))
    except:
        exit(0)
    if guess==int(key,2):
        count+=1
        print 'Nice.'
    else:
        count=0
        print 'Oops.'
    if count>2:
        print flag
cs

guesskey 문제 잘못냈나보다.

처음 print key가 주석처리되었다.

no print key :p

 

key를 2진법으로 나타냈을 때 0의 개수를 구해서

p와 q를 생성하고

p와 q번째 사이번째 비트는 mask와 xor을 하고

그 외 비트는 그대로 가져온다.

 

mask = 1 로 두고 계속 돌리면

하위 비트 쪽은 1로 되고

0의 개수가 작아지면서 p와 q도 작아지고

그럼 더더욱 하위 비트는 유지되고

 

just put 1 in mask.

뭐 이런 식으로 비트들이 1로 되어간다.

it's gonna be 1s

 

한 150~200번 돌리면

try 150-200 times

값은 두 개중 하나가 된다.

이제 mask = 0 으로 두고 두 개중 하나를 때려박으면 된다.

choice one between 92~ and 18~

 


Misc

\

vhdxfile

encrypted by BitLocker

 

 

bitlocker2john

 

hashcat

 

 

password 12345678

 

 

 

open with tool like ftk imager

extract two pdf files

 

pdfcandy.com/extract-images.html

extract images from pdf files

flag image. done.

반응형

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

0x41414141 CTF Write up  (0) 2021.01.31
ShadowCTF write up  (0) 2021.01.27
The Cyber Grabs CTF 0x02 write up  (0) 2021.01.17
0xL4ugh CTF write up  (0) 2021.01.16
2020 Christmas CTF [show me the pcap] Write-up  (2) 2020.12.27
반응형

Forenscis

 

3Cd7MMS7GmZMwxmRTfQwoXvxcDkGt8o4cFzwPUrg

then what?

 

 

 

아 base58이었넹

ah it was base58 encoded strings.


 

ascii 85 -> pastebin.pl/view

 

use "d02a7960"

 

pastebin.pl/view/d02a7960

 

morse code

 

S0METIM35SH4RK1SFR13ND1Y

 


png file.

4F -> 4E

43 -> 44

 

46 -> 4e

 

nothing here :(

 

 

move to 5527125

start and end...?

xor 6


Crypto

{ ^),!&),!!$,^$,!^%,!$&,!%),!&#,!!#,^#,!&!,!$@,^),!$!,!^@,!$$,!#&,^!,!^#,!#&,!!),^#,!!$,!@),!)^,!@%,^!,^!,!&% }

 

! -> 1

@ -> 2

# -> 3

...

60 170 114 64 165 147 150 173 113 63 171 142 60 141 162 144 137 61 163 137 110 63 114 120 106 125 61 61 175

hmm..

Isn't it this?

 

아 8진수였네

ah octal..


n = 5028492424316659784848610571868499830635784588253436599431884204425304126574506051458282629520844349077718907065343861952658055912723193332988900049704385076586516440137002407618568563003151764276775720948938528351773075093802636408325577864234115127871390168096496816499360494036227508350983216047669122408034583867561383118909895952974973292619495653073541886055538702432092425858482003930575665792421982301721054750712657799039327522613062264704797422340254020326514065801221180376851065029216809710795296030568379075073865984532498070572310229403940699763425130520414160563102491810814915288755251220179858773367510455580835421154668619370583787024315600566549750956030977653030065606416521363336014610142446739352985652335981500656145027999377047563266566792989553932335258615049158885853966867137798471757467768769820421797075336546511982769835420524203920252434351263053140580327108189404503020910499228438500946012560331269890809392427093030932508389051070445428793625564099729529982492671019322403728879286539821165627370580739998221464217677185178817064155665872550466352067822943073454133105879256544996546945106521271564937390984619840428052621074566596529317714264401833493628083147272364024196348602285804117877
e = 65537
c = 4690057718147075505522680135959473215321622692923721213835300886402444910436674094980456964526719786485709929645871497583481786451712108343985733309427211434750949557522557087475715799166136616546091244246093209194216096205011115055709130990240778725741521267153888212132276867942685123502211572949952162376597662509054070693025973089923370015547373862589488928782901235791144433788299046705518327561160954291094820233386528023713184029738780555483600166071578613803010858511582163397706626459433456365568227181855121476317779040965290548179086133039864725660837003894485377993939038122515590380127757353399577646033195886942935498851291625325622687406058565345707842924577200871090281931390828399034387159796711570518912284855782049322766568438776035673997640836043767460584670094065481165095303859142188605921710309909549354356478577687136627040919972987279885429990570784611705563443122226291405511409355924588407638851356402686178076614729462505897314633054448103933929160379080620408454649164684464952565103672481604538187885457480005006907884784443460386864548916037417492123123957243478299871616131317172973941585334012558762947082226744473068190488648000780008598569174088053018903156614111943478152720349210983651343

search n at www.factordb.com/

 

factordb.com

 

www.factordb.com

good.

 

 


braille

 

0xL4ugh{I_Th1nk_Br1ll3_W45_$m4rt}

 


Web

make money~

 

I found base32 strings in cookie.

 

 

 


 

 

Reverse Engineering

 

HxD


 

WA! Flag!


rand() % 4 값을 반복 생성하여 파일 크기와 동일한 크기의 배열에 저장한다.

파일의 j번째 바이트와 랜덤값이 들어간 배열의 j번째 바이트를 가져와서

mystery함수 호출

 

Repeat generation of values (rand() %4) and push them on an array of the same size as the file size.
Gets the jth byte of the file and the jth byte of the array containing random values.

call mystery function

 

랜덤값이 2또는 0인경우 파일의 값과 1을 xor연산하여 리턴.

 

If the random value is 2 or 0, xor computes the byte and 1 of the file and returns it.

 

 

 

main 함수에서 srand(0)을 사용했으므로 시드가 고정.

랜덤값을 구할 수 있음.

 

 

The seed is fixed because it used sand(0) in main func.
I can get random values.

 

 

 


 

Programming

 

 

 


Misc

Sonic Visualiser

spectrogram

FLAG : 0xL4ugh{SP3c7ro_1s_Gr347}

 

 


 

github.com/jzyra/DecodeAndroidGesture

 

jzyra/DecodeAndroidGesture

This tool decode Android's pattern lock screen with gesture.key file in Android device. - jzyra/DecodeAndroidGesture

github.com

 

 


 

github.com/ribt/dtmf-decoder

 

ribt/dtmf-decoder

Extract phone numbers from an audio recording of the dial tones. - ribt/dtmf-decoder

github.com

 

 

66#666#8#33#888#33#777#999#8#44#444#66#4#666#66#7777#2#6#33#9#2#999#

->
noteverythingonsameway

 

 

 

반응형

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

starCTF 2021 write-up  (0) 2021.01.18
The Cyber Grabs CTF 0x02 write up  (0) 2021.01.17
2020 Christmas CTF [show me the pcap] Write-up  (2) 2020.12.27
CyberTalents Digital Forensics CTF write up  (0) 2020.11.29
제 2회 TeamH4C CTF 2020 Write-up  (0) 2020.10.13
반응형

forensic

keyboord

100

 

usb keyboard 패킷 캡쳐 파일이다.

github.com/TeamRocketIst/ctf-usb-keyboard-parser

 

TeamRocketIst/ctf-usb-keyboard-parser

This is the updated script from https://teamrocketist.github.io/2017/08/29/Forensics-Hackit-2017-USB-ducker/ - TeamRocketIst/ctf-usb-keyboard-parser

github.com

이거 이용해서 hex 데이터를 키보드 문자로 변환해준다.

 

해당 키보드로 c코드를 작성한 것 같다.

 

코드 작성해도 돌려주면 플래그가 나온다.

 

 

webpacket

100

웹소켓으로 id와 pw를 인증하는 과정이 있다.

 

id pw를 입력받는 페이지에서 인증서버로 인증을 거치는 것이라고 추측해볼 수 있다.

 

따라서 http 패킷 중에서 websocket발생 이전 패킷들을 살펴보았다.

찾았다.

13.209.132.135:4423으로 이동하였다.

 

login.js를 보면, 패스워드를 인코딩한다. xor이기 때문에 인코딩 함수를 그대로 사용하여 복호화하였다.

pw가 flag였다.

 

 

반응형

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

CyberTalents Digital Forensics CTF write up  (0) 2020.11.29
제 2회 TeamH4C CTF 2020 Write-up  (0) 2020.10.13
FIESTA 2020 Write up  (2) 2020.09.07
2020 Defenit CTF Write Up  (2) 2020.06.06
angstrom CTF 2020 write up  (0) 2020.03.14
반응형

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

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

+ Recent posts