← Back to Writeups
CUSTOMEasyMisc

Кодировщик

XESXOR9/10/20262 min read
#misc#custom#easy#base32-encoding-automation#regex-pattern-matching-for-dat#time-limited-challenge-automat

Кодировщик

Platform: hackerlab | Category: Misc | Type: Challenge | Difficulty: Easy | OS: NA | Author: XESXOR | Date: 2025-12-25 | Status: Solved Techniques: Base32 encoding automation, Regex pattern matching for data extraction, Time-limited challenge automation with pwntools

Summary

Task: Encode random strings in Base32 within time limit across 50 rounds. Solution: Automated with pwntools to receive strings, encode them, and send responses before timeout.

Кодировщик — hackerlab

Description

Опять кошка, но, в этот раз она будет капризничать, если в течении нескольких секунд не погладишь её

Server: 62.173.140.174:10002

Analysis

When connecting to the server:

  1. Need to send the start command to begin the game
  2. Server provides 50 rounds
  3. Each round gives a random string that needs to be encoded in Base32
  4. Only a few seconds are given to respond
  5. Manual solving is impossible — automation is required

Server message format:

(1/50) random_string
>>>

‍​‌‌​​‌​​​‌‌​​‌​​​​‌‌​‌​​​​‌‌‌​​‌​​‌‌​​​‌​​‌‌‌​​​​​‌‌​‌‌​​​‌‌​​​​‍

Solution

Automation using pwntools:

python
#!/usr/bin/env python3
from pwn import *
import base64
import re

HOST = "62.173.140.174"
PORT = 10002

conn = remote(HOST, PORT)
conn.recvuntil(b">>>")
conn.sendline(b"start")

for i in range(50):
    data = conn.recvuntil(b">>>", timeout=10)
    match = re.search(r'\((\d+)/50\)\s+(.+)', data.decode())
    if match:
        text = match.group(2).strip()
        encoded = base64.b32encode(text.encode()).decode()
        conn.sendline(encoded.encode())

print(conn.recvall(timeout=10).decode())
# FLAG: CODEBY{REDACTED}

‍​‌‌​​‌​​​‌‌​​‌​​​​‌‌​‌​​​​‌‌‌​​‌​​‌‌​​​‌​​‌‌‌​​​​​‌‌​‌‌​​​‌‌​​​​‍

Algorithm:

  1. Connection — establish TCP connection via pwntools
  2. Start game — send the start command
  3. Loop through 50 rounds:
    • Receive data until the >>> marker
    • Extract the string to encode using regex
    • Encode in Base32 using base64.b32encode()
    • Send the response
  4. Get the flag — after 50 successful rounds the server returns the flag

Notes

  • Base32 uses alphabet A-Z and 2-7, outputs strings that are multiples of 8 characters with = padding
  • pwntools — ideal tool for automating CTF tasks with network interaction
  • The name "50 times encrypted" in the flag hints at the 50 encoding rounds ‍​‌‌​​‌​​​‌‌​​‌​​​​‌‌​‌​​​​‌‌‌​​‌​​‌‌​​​‌​​‌‌‌​​​​​‌‌​‌‌​​​‌‌​​​​‍