Day 18: The Egg Shell File - Advent of Cyber 2025

xhetic

xhetic

@xhetic

TryHackMeAdventOfCyberObfuscation
Day 18: The Egg Shell File - Advent of Cyber 2025

📚 Esta publicación pertenece a las colecciones:

Day 18: The Egg Shell File - Advent of Cyber 2025

Este writeup pertenece al evento Advent of Cyber 2025 de TryHackMe. Si quieres seguir toda la serie, consulta nuestra colección completa del Advent of Cyber 2025.

WareVille está en alerta máxima. Sistemas fallando, dashboards enloquecidos y alertas del SOC disparándose sin parar. En medio del caos, McSkidy ha detectado un correo sospechoso supuestamente de "Recursos Humanos del Polo Norte" (¡pero si RRHH está en el Polo Sur!).

El correo contenía un script de PowerShell lleno de caracteres sin sentido. Esto es ofuscación: la técnica de hacer que el código sea difícil de leer para evadir la detección. Hoy aprenderemos a revertir este proceso.

Room: Obfuscation - The Egg Shell File
Dificultad: Medium


🥚 Parte 1: Desofuscando la URL del C2

Al abrir el script SantaStealer.ps1 que encontramos en el escritorio, vemos que está dividido en varias secciones. La primera parte nos reta a desofuscar una variable crítica.

# ==========================
# Start here
# Part 1: Deobfuscation
# ==========================
# TODO (Step 1): Deobfuscate the string present in the $C2B64 variable and place the URL in the $C2 variable,
# then run this script to get the flag.
$C2B64 = "aHR0cHM6Ly9jMi5ub3J0aHBvbGUudGhtL2V4Zmls"
$C2    = "<C2_URL_HERE>"

La variable $C2B64 contiene una cadena que parece Base64 (caracteres alfanuméricos, termina en = si fuera necesario). Nuestro objetivo es revelar la URL oculta.

Usando CyberChef, es pan comido. Simplemente usamos la receta From Base64.

El resultado es: https://c2.northpole.thm/exfil.

Copiamos esta URL en la variable $C2 del script y lo ejecutamos.

El script nos felicita devolviéndonos la primera flag.

Pregunta: What is the first flag you get after deobfuscating the C2 URL and running the script?

Respuesta: THM{C2_De0bfuscation_29838}


🔐 Parte 2: Ofuscando la API Key

La segunda parte del reto invierte los papeles. Ahora no tenemos que desofuscar, sino ofuscar una clave API para entender cómo lo hacen los atacantes.

# ==========================
# Part 2: Obfuscation
# ==========================
# TODO (Step 2): Obfuscate the API key using XOR single-byte key 0x37 and convert to hexidecimal,
# then add the hex string to the $ObfAPieEy variable.
# Then run this script again to receive Flag #2 from the validator.
$ApiKey = "CANDY-CANE-API-KEY"
$ObfAPIKEY = Invoke-XorDecode -Hex "<HEX_HERE>" -Key 0x37

Las instrucciones son:

  1. Tomar la API Key: CANDY-CANE-API-KEY.
  2. Aplicar una operación XOR con la clave 0x37.
  3. Convertir el resultado a Hexadecimal.

Volvemos a nuestra herramienta favorita, CyberChef, para construir esta receta:

Receta CyberChef XOR y Hex

El resultado hexadecimal es: 747679736e1a747679721a76677e1a7c726e.

Pegamos este valor en la variable $ObfAPIKEY y ejecutamos el script nuevamente. Si todo es correcto, el validador nos entregará la segunda flag.

Pregunta: What is the second flag you get after obfuscating the API key and running the script again?

Respuesta: THM{API_Obfusc4tion_ftw_0283}


🏁 Conclusión

Hoy hemos explorado dos caras de la misma moneda: la ofuscación y la desofuscación.

Hemos visto cómo técnicas sencillas como Base64 y XOR pueden ocultar información a simple vista, pero también cómo herramientas como CyberChef nos permiten revertir estos procesos fácilmente una vez identificamos el patrón.

Si te perdiste el reto de ayer sobre decodificación avanzada con CyberChef, echa un vistazo al Día 17: Hoperation Save McSkidy.

Recuerda que puedes seguir toda la serie de retos en nuestra colección completa del Advent of Cyber 2025.

¡Nos vemos mañana para más hacking navideño! 🎄

~ Xhetic