Forensics

UMDCTF(writeup) - HHJ

HackHiJack 2022. 3. 7. 01:00
728x90
반응형

난 다음 4문제를 풀었다. -> Renzik's Case, Xorua, Magic Plagueis the Wise, jdata

(모두 포렌식 문제이다.)

 

Renzik's Case

 

winhex로 .img을 열었을 때, 다음과 같이 나왔다.

"중요한 문서" 라고 문제 설명에서 말하길래, 위에 personal_document에 뭔가 있음을 예상했다.

다음과 같이 폴더 안으로 들어가면 REALLY_personal_document가 있었다.

들어가면 다음과 같은 두 파일이 있었다.

두 파일 중 png파일이 다음과 같이 flag를 가지고 있었다.

flag : UMDCTF-{Sn00p1N9_L1K3_4_Sl317h!}

 

Xorua

이 문제는 before.png 와 after.png를 XOR한 후 PNG파일 부분만 보면 flag가 나왔다.

다음과 같은 python 코드를 이용해서 두 파일을 XOR하였다.

import sys

# Read two files as byte arrays
file1_b = bytearray(open(sys.argv[1], 'rb').read())
file2_b = bytearray(open(sys.argv[2], 'rb').read())

# Set the length to be the smaller one
size = len(file1_b) if len(file1_b) < len(file2_b) else len(file2_b)
xord_byte_array = bytearray(size)

# XOR between the files
for i in range(size):
	xord_byte_array[i] = file1_b[i] ^ file2_b[i]

# Write the XORd bytes to the output file	
open(sys.argv[3], 'wb').write(xord_byte_array)

print "[*] %s XOR %s\n[*] Saved to \033[1;33m%s\033[1;m."%(sys.argv[1], sys.argv[2], sys.argv[3])

그리고 나온 Raw data에서 PNG 부분만 따로 파일을 만들면 다음과 같이 flag 사진 파일이 나온다.

flag : UMDCTF{Sh4p3Sh1ft3R}

 

Magic Plagueis the Wise

 

이 문제는 다음과 같이 zip 파일에 매우 많은 raw 파일들이 있다.

총 이렇게 4464 개의 파일이 있었다.

 

안에 hexdump를 보면 다음과 같이 png파일같이 되어 맨 앞 byte부분만 다르다.

그래서 python으로 이 파일들을 순서대로 첫 바이트만 모아서 만든 문자열을 출력하는 코드를 만들었다.

flag = ""


for i in range(1,4464):
	with open(str(i),'r') as file: 
		raw = file.read(1)
	
	flag += raw

print flag

다음과 같이 실행했을 때 flag가 나오는 걸 확인할 수 있다.

flag : UMDCTF{d4r7h_pl46u315_w45_m461c}

 

jdata

마지막으로 jdata를 풀어보겠다.

 

아래와 같이 zip 파일을 준다.

그런데 hexdump를 확인하면 ELF 파일이다.

그래서 ida로 main부분을 봤는데 다음과 같이 이상한 문자열(?)을 출력하는 걸 확인할 수 있다.

사실, 이건 전혀 상관없고 hehe라는 함수에 flag가 시작된다.

거꾸로 이걸 받아 적으면 다음과 같은 문자열이 된다.(umdctf는 대문자로 바꾼다.)

UMDCTF{ghidraisforbinariesbroand

이제 나머지를 찾으면 되는데 hexdump 마지막 부분에 우연히 jdata.png라고 되어있는 걸 봤다.

그래서 foremost를 이용해서 다음과 같이 파일을 추출했다.

추출한 파일은 다음과 같이 나머지 flag를 주었다.

그래서 둘을 합치면 다음과 같이 flag가 완성된다.

flag : UMDCTF{ghidraisforbinariesbroandpubl1sh_s0m3_r3al_w0rk}

728x90
반응형