Team Name: 숭실대CTF팀명제한은어디까지일까요진짜궁금한데제발짜르지말아주세요
Team Member: 0xH0P3, chadol_27, Nero
일반부, 통합 28th Place
1. check the target (Misc)
Solve: 0xH0P3
이미지의 신뢰도를 맞춰야한다.
PoC Code:
import torch
import numpy as np
from PIL import Image
import base64
import io
# 모델 초기화
class CustomModel(torch.nn.Module):
def __init__(self):
super(CustomModel, self).__init__()
self.hidden1 = torch.nn.Linear(784, 256)
self.hidden2 = torch.nn.Linear(256, 128)
self.output = torch.nn.Linear(128, 10)
def forward(self, x: torch.Tensor) -> torch.Tensor:
x = torch.relu(self.hidden1(x))
x = torch.relu(self.hidden2(x))
return torch.softmax(self.output(x), dim=1)
# 가중치 로드
weights_path = "weights.pkl"
weights = torch.load(weights_path, map_location=torch.device('cpu'))
# 모델 설정
model = CustomModel()
model.load_state_dict(weights)
model.eval()
# 조건을 만족하는 입력 데이터 생성
def generate_input(model, target_class=7, confidence_threshold=0.98):
input_tensor = torch.rand(1, 784) # 임의의 초기 입력값
input_tensor.requires_grad = True
optimizer = torch.optim.Adam([input_tensor], lr=0.1)
for _ in range(1000): # 최대 1000번 반복
optimizer.zero_grad()
output = model(input_tensor)
confidence = output[0, target_class]
loss = -confidence # 타겟 클래스의 확률을 최대화
loss.backward()
optimizer.step()
with torch.no_grad():
input_tensor.clamp_(0, 1) # 이미지 데이터는 [0, 1] 범위로 제한
if confidence.item() > confidence_threshold:
print(f"조건 만족: 클래스 {target_class}, 신뢰도 {confidence.item()}")
break
return input_tensor
# 입력 데이터 생성
input_data = generate_input(model)
# 이미지로 변환
image_array = (input_data.view(28, 28).detach().numpy() * 255).astype(np.uint8)
image = Image.fromarray(image_array)
image.save("generated_image.png")
# 베이스64 인코딩
buffer = io.BytesIO()
image.save(buffer, format="PNG")
base64_image = base64.b64encode(buffer.getvalue()).decode()
print(f"Base64 Encoded Image:\n{base64_image}")
2. compressor (Misc)
Solve: chadol_27
가장 쉬웠던 문제인데 이걸 못풀어서 몇시간 동안 고민했다...
Your gzip (hex) >>>
origin_hash='e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
decomp_hash='e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
ssu{have_you_heard_about_the_quine?}
아무것도 안넣으면 압축해제해도 해쉬값이 똑같다
3. $ SSU SHELL (Pwnable)
Solve: chadol_27
echo '<input>'의 쉘을 실행할 수 있지만
<>BDF[\^bdf{|~ 등의 문자열이 필터링돼
$(cat flag) 같은 명령어 치환은 사용할 수 없다
하지만
`은 필터링 되지 않아
echo `cat flag` 와 같이 명령어 치환을 쓸 수 있다
'`cat ?lag_*`'
Flag: ssu{57833e5cc254ed0b54fc7f258ae75081657f181d9776ea171b283b426967ab26}
4. meme (Misc)
Solve: chadol_27
uint256 blockHashPart = uint256(blockhash(block.number - 1)) % 1000000000;
flag = string(abi.encodePacked("ssu{", uint2str(blockHashPart), "_m3m3}"));
블록 해쉬값 찾아서 넣고 계산
block_hash = 0x3fd4e38b9b28cfe753436b3277eec250ffe435894957cc15ac493d864d1e0c29
block_hash %= 1000000000
print(block_hash)
Flag: ssu{809209385_m3m3}
5. Mazer (Misc)
Solve: Nero
파이썬으로 작성된 프로그램을 exe로 돌린거기에 pyinstxtractor를 사용하여 디컴파일,
생성된 pyc파일을 다시 한 번 디컴파일해서 파이썬 코드 원문을 얻을 수 있다
`xor_image_hash`와 `make_flag`를 사용해 사진파일을 기반으로 flag를 만들고 있기에 그대로 실행해서 플래그를 얻을 수 있다
Flag: ssu{236501dfe16b611f}
숭실대학교 CTF는 경험을 쌓으려고 참여했는데 생각보다 어려웠고 주요 분야 웹, 암호학이 0솔이라는 것이 충격적이다
많은 취약점 알고 간거 같아서 좋았다~
'Contest Write-Up' 카테고리의 다른 글
2025 SCA CTF Write-Up (0) | 2025.02.26 |
---|---|
제 30회 POC 해킹캠프 CTF Write-Up (0) | 2025.02.16 |
2025 LOGCON CTF Write-Up (1) | 2025.02.02 |
2024 HISCON Write-Up (2) | 2025.01.23 |