본문 바로가기
CTF

[corCTF 2022] whack-a-frog

by skyepodium 2022. 8. 14.

1. 개요

wireshark, pillow 문제

 

2. 분석

1) 마우스 좌표 기록

사이트에 들어가면 마우스가 움지일때마다 x,y 좌표를 기록하고 있습니다. 

 

2) wireshark

wireshark에도 좌표기록이 있어서 다음과 같이 필터걸었습니다.

frame contains anticheat

 

3) export

다음과 같이 url위주로 export 했습니다.

 

3) python

문자열을 정규표현식으로 정제하고 좌표만 뽑았습니다.

 

그리고, pillow 라이브러리를 사용해서 png 파일로 만들었습니다.

from PIL import Image
import re

# 1. 문자열 정제
# 1) wireshark에서 export한 요청 목록 임포트
pcap_exported = open("result.txt", "r")

# 2) 요청 목록을 리스트로 변환
request_list = pcap_exported.readlines()

# 3) 파일 읽었으니가 닫아주기
pcap_exported.close()

# 4) 좌표 목록 추출
position_list = []
max_x, max_y = 0, 0
for request in request_list:
    search_result = re.search("([a-z]=\d+&[a-z]=\d+)", request)
    if search_result:
        position_str = search_result.group()
        x, y = re.findall("\d+", position_str)
        x, y = int(x), int(y)
        position_list.append([x, y])
        max_x = max(max_x, x)
        max_y = max(max_y, y)

print('max_x', max_x, 'max_y', max_y) #max_x 520 max_y 68


# 2. 이미지 만들기
OFF_SET = 30
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
new_data = [[0 for _ in range(max_y+OFF_SET)] for _ in range(max_x + OFF_SET)]

for x, y in position_list:
    new_data[x][y] = 1

color_list = []
for y in range(max_y+OFF_SET):
    for x in range(max_x+OFF_SET):
        if new_data[x][y] == 1:
            color_list.append(BLACK)
        else:
            color_list.append(WHITE)


result = Image.new("RGB", (max_x + OFF_SET, max_y + OFF_SET))
result.putdata(color_list)
result.save("result.png", "PNG")

 

다음과 같은 사진을 얻었습니다.

corCTF{LILYXOX}

'CTF' 카테고리의 다른 글

[shell ctf 2022] Choosy  (0) 2022.08.14
[corCTF 2022] msfrog-generator  (0) 2022.08.14
[TFC CTF 2022] BBBBBBBBBB  (0) 2022.08.07
[TFC CTF 2022] pattern  (0) 2022.07.31
[TFC CTF 2022] random  (0) 2022.07.31