반응형
반응형
반응형
반응형

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

darkCON CTF 2021 write up  (0) 2021.02.21
SecureBug CTF 2021 write up  (0) 2021.02.18
justCTF 2020 write up  (0) 2021.02.01
0x41414141 CTF Write up  (0) 2021.01.31
ShadowCTF write up  (0) 2021.01.27
반응형

2020?

 

Reversing

That's not crypto

decompile it

 

bruteforce!

 

반응형

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

SecureBug CTF 2021 write up  (0) 2021.02.18
TrollCAT CTF write up  (0) 2021.02.07
0x41414141 CTF Write up  (0) 2021.01.31
ShadowCTF write up  (0) 2021.01.27
starCTF 2021 write-up  (0) 2021.01.18
반응형

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

Forensics

Peace

"the most popular social media" == twitter

holloway.nz/steg/

 

Twitter Secret Messages - Steganography

Hide secret messages in your tweets (or any text) with steg-of-the-dump.js. Tweet i had a great day at the beach! #sunshine Hidden Message kidnapped by pirates Tweet to post Warning: Not all of Hidden Message stored in tweet. Add more text (e.g. spaces) to

holloway.nz


Linux Help

given a png file.


Brutus Killer

caesar cipher


Suspicious Riddle

use volatility

Win7SP1x64

 

 

pid = 2816


Hash Riddle

dump it

 


extract s3cr3t.mp3 file

 

 

Tewm yzc bs, _n3q0rq_a4ok3w}

hmm what is it?


Source Riddle

iexplore.exe

 


Anarchy Riddle

procdump -p 2816 -D ./


Memory Detective

filescan | findstr "flag"

dumpfiles -Q 0x00000000???(i forgot) -D ./


pstree

procdump -p 2108 -D ./

 

hmm..

i couldn't find file which named volatilesecret.


Cryptography

valhalla

runes


Rick and morty on adventure

image search

 

I found this


Monk

dec to ascii


Hand-Work

mp3 file.

it says "dot" and "dash"

listen and write . and _

then decode it.

... .... ._ _.. ___ .__ _._. _.._. . ...._ ... _.__ _._. ._. _.__ .__. _ _____

 


What are Semaphores processes?

i found this.

 


Colored....P

www.boxentriq.com/code-breaking/hexahue

 

Hexahue Alphabet - decoder, translator | Boxentriq

Tool to decrypt Hexahue code. Hexahue, and variants of it, are used occasionally in geocaching mystery caches, CTFs and logic puzzles. Look specifically for the color combinations to recognize it.

www.boxentriq.com


DORAEMON

 


OSINT

Eased OSINT

wav file


Intel Expert

from north korea.

city : Pyongyang

 

 

반응형

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

justCTF 2020 write up  (0) 2021.02.01
0x41414141 CTF Write up  (0) 2021.01.31
starCTF 2021 write-up  (0) 2021.01.18
The Cyber Grabs CTF 0x02 write up  (0) 2021.01.17
0xL4ugh CTF write up  (0) 2021.01.16
반응형

System32.kr

RSA108 풀이

 

rsa107문제랑 거의 똑같다.

n값을 base-16 hex로 보면 rsa107문제처럼 중간에 0이 많이 있다.

000...000을 기준으로 앞 뒤 잘라서 factor을 찾으면

이렇게 나온다.

저 공통인수를 p로 두고 n/p 로 q를 구할 수 있다.

p랑 q 구했으니 d구해서 c 복호화하면 끝.

반응형

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

System32.kr [RSA107] 풀이  (0) 2021.01.18
System32.kr [EZB64] 풀이  (0) 2019.12.28
System32.kr [RSA106] 풀이  (0) 2019.05.19
System32.kr [RSA104] 풀이  (0) 2019.05.19
System32.kr [RSA105] 풀이  (0) 2019.05.19
반응형

System32.kr

RSA107 풀이

 

간만에 system32.kr 문제를 풀었다.

 

보면 모듈러 n 중간에 많은 0이 특징이다.

 

 

rsa 문제 풀이들을 찾아보다가

 

ctftime.org/writeup/22977

 

CTFtime.org / Crypto CTF 2020 / Decent RSA / Writeup

Tags: polynomials rsa  Rating: 4.5

ctftime.org

이런 풀이인가 싶었는데, 여기 풀이는 n값이 대부분 0으로 구성되었을 때였다.

 

그러다가 포스트 하나를 찾았다.

party4bread.github.io/a-year-of-ctf-rsa/#pq%EC%97%90-0%EC%9D%B4-%EB%A7%8E%EC%9D%84-%EA%B2%BD%EC%9A%B0

 

A year of CTF RSA | Haven 4 BREAD

1년정도 CTF 뉴비로 있으면서 (아직도 뉴비지만) 겪었던 RSA 문제들의 유형을 대략 정리했습니다.

party4bread.github.io

오 출제자님 블로그

 

 

1234..00000000...1234 이런 식으로 구성되어 있으면 p나 q중에 하나는 100000...00 + z 형태를 취하고 있을 가능성이 높다.

 

따라서 n값을 0000...000을 기준으로 큰 부분을 a로 두고

작은 부분을 b로 두어 b/a를 계산하였더니 나누어 떨어졌다.

 

p = 1000...0000 + 961

이렇게 p와 q를 구할 수 있다.

반응형

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

System32.kr [RSA108] 풀이  (0) 2021.01.19
System32.kr [EZB64] 풀이  (0) 2019.12.28
System32.kr [RSA106] 풀이  (0) 2019.05.19
System32.kr [RSA104] 풀이  (0) 2019.05.19
System32.kr [RSA105] 풀이  (0) 2019.05.19
반응형

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

my write ups during the ctf & after the ctf

공부겸 오피셜 롸업 보고 풀어서 내용들을 추가했습니다.

 

Forensic

gchq.github.io/CyberChef/

 

CyberChef

 

gchq.github.io


 

SAM은 있는데 SYSTEM이 없네...;;

 다른 방법을 찾아야 한다.

 

이 내용이 힌트였다.

 

저 내용만 가지고 temp 에 있는 lsass.DMP를 찾아내야 했다..

 

crackstation.net/

 

CrackStation - Online Password Hash Cracking - MD5, SHA1, Linux, Rainbow Tables, etc.

Free Password Hash Cracker Enter up to 20 non-salted hashes, one per line: Supports: LM, NTLM, md2, md4, md5, md5(md5_hex), md5-half, sha1, sha224, sha256, sha384, sha512, ripeMD160, whirlpool, MySQL 4.1+ (sha1(sha1_bin)), QubesV3.1BackupDefaults How Crack

crackstation.net


 

아 왜 이거 아님

 

흠.......................

여기 있는 이 stargazer.jpg를 사용해야되는 문제였다.

 

 

여기서 이 문자열을 패스워드로 해서

steghide를 돌리면 플래그가 나오는 문제였다... 아니 이걸 어케 알지..


Crypto

CipherText : @$$@@@$$@$$$$@@$@$$@@@$@@$$@@$@$@$$$@@$@@$$@@$$$@$$$@@$@@$$@@@@$@$$@@@$@@$$$@@$$@$$$$@$$@$$$@@@$@$$$@$@$@$$@$@@$@$$$@$@@@@$$@@$$@$@$$$$$@$$@@$$$@@$$@@@@@@$$@@@@@$$@@$@@@$@$$$$$@$$$@$$$@@$$@$@@@$$$@@$@@$$@$$@$@$$$@$@$@$$$@@@@@$@$$$$$@$$@$@@$@$$$@@$$@$$@$$$@@@$@@$$$@$$$@$@@@$@$$$$$@$$@$@@$@$$$@$@@@$$$$$@$

 

@ -> 0

$ -> 1

bin to ascii

 


morsecode.world/international/decoder/audio-decoder-adaptive.html

 

Morse Code Adaptive Audio Decoder | Morse Code World

Notes The decoder will analyse sound coming from the microphone or from an audio file. The spectrogram of the sound is shown in the main graph along with a pink region showing the frequency being analysed. If the volume in the chosen frequency is louder th

morsecode.world


Misc

 

holloway.nz/steg/

 

Twitter Secret Messages - Steganography

Hide secret messages in your tweets (or any text) with steg-of-the-dump.js. Tweet i had a great day at the beach! #sunshine Hidden Message kidnapped by pirates Tweet to post Warning: Not all of Hidden Message stored in tweet. Add more text (e.g. spaces) to

holloway.nz

이런게 있넹


www.boxentriq.com/code-breaking/hexahue

 

Hexahue Alphabet - decoder, translator | Boxentriq

Tool to decrypt Hexahue code. Hexahue, and variants of it, are used occasionally in geocaching mystery caches, CTFs and logic puzzles. Look specifically for the color combinations to recognize it.

www.boxentriq.com

color code cryptography

이런게 있네

반응형

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

ShadowCTF write up  (0) 2021.01.27
starCTF 2021 write-up  (0) 2021.01.18
0xL4ugh CTF write up  (0) 2021.01.16
2020 Christmas CTF [show me the pcap] Write-up  (2) 2020.12.27
CyberTalents Digital Forensics CTF write up  (0) 2020.11.29
반응형

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

show me the pcap

forensic

 

코로나사태로 인해 루돌프들 끼리 산타우체국에서 비밀리로 비대면 회의를 진행했다!
해당 회의 내용을 중간자 공격으로 PCAP형태로 가져왔으니 분석해보자!

 

 

pcap 파일 한 개가 주어진다.

 

Wireshark로 해당 파일을 열어보면 SSH, TLS 패킷들이 보이는데, 아래로 내려보면 756번부터 많은 RTP패킷들이 캡쳐된 것을 확인할 수 있다.

RTP는 실시간 전송 프로토콜로, 오디오와 비디오 정보의 실시간 전송을 하기위해 사용된다. 문제 지문에서 비대면 회의를 진행하였다고 했으므로, 해당 회의 내용이 RTP를 통해 진행된 것으로 볼 수 있다.

 

 

 

 

 

 

 

 

RTP 패킷의 담긴 내용을 확인해야 하는데, 해당 내용이 오디오형식이고 Wireshark에서 지원하는 코덱인 경우, Wireshark로 바로 확인할 수 있는 방법이 있다.

 

아무 RTP 패킷을 클릭하고 상단 메뉴에서 Telephony > RTP > Stream Analysis 를 클릭하고

Play Streams 버튼을 클릭하고 소스 선택 후 재생버튼을 누르면 된다.

 

그러나 여기에서는 비어있거나 지원하지 않는 코덱이라고 나온다.

 

따라서 해당 내용은 비디오인 것으로 추측해볼 수 있고, 다른 방법을 찾아보아야 했다.

 

 

 

 

 

 

 

 

 

여러가지를 검색하던 중에 블로그 글 하나를 찾을 수 있었다.

blog.itekako.com/technical/2017/03/07/rtp-stream-replay/

 

RTP stream replay

Company news, knowledge sharing, technology, best practices and more.

blog.itekako.com

캡쳐한 rtp 패킷을 목적지만 수정하여 다시 실시간으로 전송하여 내용을 확인하는 방식이다.

 

 

 

 

 

필요한 환경은 패킷을 보낼 리눅스 환경과 내용을 확인할 리눅스/윈도우 환경 2개이다.

 

 

먼저, 주어진 pcap파일에서 (이하 origin.pcap) rtp패킷만 추출한 pcap파일을 만들어야 한다.

1. Wireshark로 origin.pcap를 연다.

2. 상단 메뉴에서 Telephony > RTP > RTP Streams

3. 스트림 선택

4. Prepare Filter 클릭 후 창 닫기

5. 상단 메뉴에서 File > Export Specified Packets… > Export as > pcap

6. rtpstream.pcap로 저장

7. rtpstream.pcap를 패킷을 보낼 리눅스 환경으로 이동

 

 

 

 

 

rtpstream.pcap를 replay하기 위해서는 패킷의 목적지 ip와 mac 주소를 수정해 주어야 한다.

해당 과정은 아래 modify-pcap.sh로 수행한다.

 

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
#!/usr/bin/env bash
# http://blog.itekako.com/technical/2017/03/07/rtp-stream-replay/
set -o errexit
set -o nounset
set -o errtrace
set -o pipefail
 
REPLAY_DST_IP="${1}"
IN_PCAP_FILE="${2}"
OUT_PCAP_FILE="${3:-rtp-for-replay.pcap}"
OUT_SDP_FILE="${4:-sdp}"
 
REPLAY_SRC_IP=$(ip route get "${REPLAY_DST_IP}" | sed --"s/.* src (\S*).*/\1/p")
REPLAY_SRC_DEV=$(ip route get "${REPLAY_DST_IP}" | sed --"s/.* dev (\S*).*/\1/p")
REPLAY_SRC_MAC=$(ip link show "${REPLAY_SRC_DEV}" | sed --"s/.*\/ether (\S*).*/\1/p")
if [ -"${REPLAY_SRC_MAC}" ]
then
  echo "Error reading source MAC address. Make sure that the destination IP does not belong to this machine".
fi
ping --1 -- "${REPLAY_DST_IP}" > /dev/null
ARP_PATH=$(which arp)
 
if [ -"${ARP_PATH}" ]
then
  ARP_CMD="${ARP_PATH}"
else
  ARP_CMD="sudo ${ARP_PATH}"
fi
REPLAY_DST_MAC=$(${ARP_CMD} -an -- "${REPLAY_DST_IP}" | sed --"s/.* at (\S*).*/\1/p")
 
read ORIG_SRC_IP ORIG_SRC_MAC ORIG_DST_IP ORIG_DST_MAC RTP_DST_PORT <<<$(\
    tshark -T fields -e ip.src -e eth.src -e ip.dst -e eth.dst -e udp.dstport -1 -"${IN_PCAP_FILE}")
 
tcprewrite \
    --fixcsum \
    --srcipmap=${ORIG_SRC_IP}/32:${REPLAY_SRC_IP}/32 \
    --enet-smac=${REPLAY_SRC_MAC} \
    --dstipmap=${ORIG_DST_IP}/32:${REPLAY_DST_IP}/32 \
    --enet-dmac=${REPLAY_DST_MAC} \
    --infile="${IN_PCAP_FILE}" \
    --outfile="${OUT_PCAP_FILE}"
 
echo "c=IN IP4 ${REPLAY_SRC_IP}
m=video ${RTP_DST_PORT} RTP/AVP 96
a=rtpmap:96 H264/90000" > "${OUT_SDP_FILE}"
 
echo "Copy file \"$(readlink -e ${OUT_SDP_FILE})\" to player machine, open it in player, then execute:"
echo "  sudo tcpreplay --intf1=${REPLAY_SRC_DEV} '${OUT_PCAP_FILE}'"
cs

 

위 스크립트 실행에 필요한 패키지를 설치해야 한다.

$ sudo apt-get install tcpreplay tshark net-tools

 

그리고 스크립트를 실행해 준다.

$ bash modify-pcap.sh <player machine ip> <input pcap file> [<output pcap file>] [<output sdp file>]
$ bash modify-pcap.sh 192.168.0.2 rtpstream.pcap

 

 

그러면 패킷을 받기 위한 정보가 담긴 sdp파일이 생성되고, 패킷을 replay하기 위한 명령어가 출력된다.

 

sdp파일은 패킷을 받을 환경으로 이동한다.

 

 

 

 

 

 

 

 

패킷을 받아 영상으로 보기 위해서는 아래 명령어를 사용하면 된다.

$ ffplay sdp

나는 윈도우 환경에서 진행하였기 때문에 ffplay.exe를 사용하였다. ffplay.exe는 ffmpeg.org/download.html에서 다운받을 수 있다.

 

ffplay sdp로 대기 중인 상태에서, 리눅스 환경에서

 

sudo tcpreplay --intf1=enp0s3 'rtp-for-replay.pcap'

(modify-pcap.sh을 실행하고 출력된 명령어)을 실행하면, 패킷이 전송되어 받을 수 있다.

 

 

 

 

 

 

 

 

 

ffplay.exe sdp를 실행하였을 때 나는 

 

 

이러한 오류가 발생하였다. 해당 오류는 -protocol_whitelist file,udp,rtp,crypto,data 옵션을 추가해주어 해결할 수 있었다.

 

 

 

 

 

 

첫 번째 시도에서 오류가 발생하였다.

blog.itekako.com/technical/2017/03/07/rtp-stream-replay/에서는 문제가 있을 때, sdp 파일에 추가적인 정보를 추가해주라고 되어 있다. 

 

 

 

sdp-fmtp-data.sh

1
2
3
4
5
6
set -o errexit
set -o nounset
IN_FILE="${1}"
echo "a=fmtp:96 $(tshark -E aggregator=';' -Y sdp.fmtp.parameter -T fields -e sdp.fmtp.parameter -r "${IN_FILE}")"
cs
$ bash sdp-fmtp-data.sh origin.pcap

 

 

출력 결과

a=fmtp:96 profile-level-id=1;config=000001B001000001B58913000001000000012000C48D8DC43D3C04871443000001B24C61766335372E3130372E313030

 

해당 내용을 sdp 다음 행에 추가해주었다.

 

그러나 여전히 오류가 발생하였다.

 

sdp

c=IN IP4 10.0.2.15
m=video 58898 RTP/AVP 96
a=rtpmap:96 H264/90000
a=fmtp:96 profile-level-id=1;config=000001B001000001B58913000001000000012000C48D8DC43D3C04871443000001B24C61766335372E3130372E313030

 

sdp에 내용이 부족하거나 잘 못 설정된 것 같아, origin.pcap 파일을 다시 살펴보았다.

 

rtp 패킷들이 전송되기 전 부분인 749번 패킷에서 메타데이터를 확인할 수 있었다.

해당 내용에 따라 코덱 정보를 H264에서 MP4V-ES로 수정하고 시도하였더니 플래그를 얻을 수 있었다.

 

 

반응형

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

The Cyber Grabs CTF 0x02 write up  (0) 2021.01.17
0xL4ugh CTF write up  (0) 2021.01.16
CyberTalents Digital Forensics CTF write up  (0) 2020.11.29
제 2회 TeamH4C CTF 2020 Write-up  (0) 2020.10.13
CCE2020 Quals Write-up  (0) 2020.09.26

+ Recent posts