**Autor Carlos Garrido Junco **

Análisis Estático

Relacionado: VirusTotal. HOME. Forense de memoria de sistema completo. Sistema de Gestion de la Seguridad de la Informacion. Acceso remoto.

Cuando nos llega una muestra lo primero que hacemos es ver que tipo de fichero es:

/home/remnux/Downloads/theJungle/malware/njRAT/njRAT.exe: PE32 executable (GUI) Intel 80386 Mono/.Net assembly, for MS Windows

Es un PE para una arquitectura de 32 bit basada en el 8086, escrito en .NET. También, podemos ver su número mágico con el siguiente comando:

remnux@remnux:~/Downloads/theJungle/malware/Trojan.Win32.Bladabindi$ hexdump -n 16 -C njRAT.exe 
00000000  4d 5a 90 00 03 00 00 00  04 00 00 00 ff ff 00 00  |MZ..............|
0000001

Luego vemos si es un virus con clamscan (Es el antivirus que viene en linux):

remnux@remnux:~/Downloads/theJungle/malware/Trojan.Win32.Bladabindi$ clamscan njRAT.exe 
LibClamAV Warning: **************************************************
LibClamAV Warning: ***  The virus database is older than 7 days!  ***
LibClamAV Warning: ***   Please update it as soon as possible.    ***
LibClamAV Warning: **************************************************
 
/home/remnux/Downloads/theJungle/malware/Trojan.Win32.Bladabindi/njRAT.exe: Win.Packed.Bladabindi-7086597-0 FOUND
 
----------- SCAN SUMMARY -----------
Known viruses: 8704004
Engine version: 0.103.12
Scanned directories: 0
Scanned files: 1
Infected files: 1
Data scanned: 0.99 MB
Data read: 0.93 MB (ratio 1.06:1)
Time: 18.359 sec (0 m 18 s)
Start Date: 2025:03:31 06:36:26
End Date:   2025:03:31 06:36:45
 

El antivirus salta y dice que es un virus. A continuación, se lo pasamos a virus total para saber de que familia es: Que nos sale que es un virus tipo trojano- backdoor pensado para una arquitectura de 32bits de la familia bladabindi Bladabindi es NJRAT Es un troyano de acceso remoto que se descubrió pro primera vez en el 2012. Este sería mi primer indicador de compromiso

También podemos pasarlo a virusTotal através del hash

Hash de binario en md5 y en sha256. sha256

remnux@remnux:~/Downloads/theJungle/malware/njRAT$ sha256sum njRAT.exe 
fd624aa205517580e83fad7a4ce4d64863e95f62b34ac72647b1974a52822199  njRAT.exe
 

md5

remnux@remnux:~/Downloads/theJungle/malware/njRAT$ md5sum njRAT.exe 
0431311b5f024d6e66b90d59491f2563  njRAT.ex

Link de virus total de la muestra buscada mediante el hash

También es importante usar ssdeep para generar un hash diferencial para que cuando llegue una muestra nueva se puede en la que cambie un patron de ella se pueda comparar con la que tenemos. Ya que ssdeep no te genera un hash criptográfico si no te genera un fuzzy hash.

remnux@remnux:/mnt/compartida$ ssdeep njRAT.malware 
ssdeep,1.1--blocksize:hash:hash,filename
12288:+O9vE3J7JO+xEPuc//9wivAmv6SAbnzmip2hGnadlFM4ZHOT2:+eXuczPCSGnzVjad1,"/mnt/compartida/njRAT.malware"
 

A continuación nos aseguramos con yara en el cual hemos descargado un .yar con los indicadores de compromiso de njRAT de que la muestra pertenece a njRAT.

/home/remnux/Downloads/theJungle/info/c2779809-7755-4608-9336-3d6dba89df82_njRAT/rules/RAT_Njrat.yar
Njrat /home/remnux/Downloads/theJungle/malware/njRAT/njRAT.exe
njrat1 /home/remnux/Downloads/theJungle/malware/njRAT/njRAT.exe

Podemos ver que salta el motor de yara. <<<<<<< HEAD

También hecho mi propia regla yara, para ello hemirado los string que utiliza utilizando el comando strings La regla yara que he creado. lo de detecta

 
import "pe"
 
rule Njrat: RAT
{
 
    strings:
        $string1 = "FromBase64String"
        $string2 = "Base64String"
        $string3 = "Connected" wide ascii
        $string4 = "Receive"
        $string5 = "Send" wide ascii
        $string6 = "DownloadData" wide ascii
        $string7 = "DeleteSubKey" wide ascii
        $string8 = "get_MachineName"
        $string9 = "get_UserName"
        $string10 = "get_LastWriteTime"
        $string11 = "GetVolumeInformation"
        $string12 = "OSFullName" wide ascii
        $string13 = "netsh firewall" wide
        $string14 = "cmd.exe /k ping 0 & del" wide
        $string15 = "cmd.exe /c ping 127.0.0.1 & del" wide
        $string16 = "cmd.exe /c ping 0 -n 2 & del" wide
 
    condition:
 
        10 of them
}

origin/main Vemos los string que contiene el fichero utilizando rabin2, mejor utilizar rabin2 antes que string porque string solo te muestra los string que están en base utf8.

remnux@remnux:~/Downloads/theJungle/malware/Trojan.Win32.Bladabindi$ rabin2 -z njRAT.exe 
[Strings]
nth paddr      vaddr      len  size section type    string
――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
0   0x000eab36 0x004f0136 15   32   .rsrc   utf16le VS_VERSION_INFO
1   0x000eab94 0x004f0194 10   22   .rsrc   utf16le arFileInfo
2   0x000eabb2 0x004f01b2 11   24   .rsrc   utf16le Translation
3   0x000eabd6 0x004f01d6 14   30   .rsrc   utf16le StringFileInfo
4   0x000eabfa 0x004f01fa 8    18   .rsrc   utf16le 000004b0
5   0x000eac12 0x004f0212 8    18   .rsrc   utf16le Comments
6   0x000eac24 0x004f0224 5    12   .rsrc   utf16le njRAT
7   0x000eac36 0x004f0236 11   24   .rsrc   utf16le CompanyName
8   0x000eac50 0x004f0250 4    10   .rsrc   utf16le njq8
9   0x000eac62 0x004f0262 15   32   .rsrc   utf16le FileDescription
10  0x000eac84 0x004f0284 5    12   .rsrc   utf16le njRAT
11  0x000eac96 0x004f0296 11   24   .rsrc   utf16le FileVersion
12  0x000eacb0 0x004f02b0 7    16   .rsrc   utf16le 0.6.4.0
13  0x000eacc6 0x004f02c6 12   26   .rsrc   utf16le InternalName
14  0x000eace0 0x004f02e0 17   36   .rsrc   utf16le EnKSaR.HaCKeR.exe
15  0x000ead0a 0x004f030a 14   30   .rsrc   utf16le LegalCopyright
16  0x000ead28 0x004f0328 10   21   .rsrc   utf16le Copyright
17  0x000ead3e 0x004f033e 10   22   .rsrc   utf16le  njq8 2013
18  0x000ead5a 0x004f035a 15   32   .rsrc   utf16le LegalTrademarks
19  0x000ead7c 0x004f037c 5    12   .rsrc   utf16le njRAT
20  0x000ead8e 0x004f038e 16   34   .rsrc   utf16le OriginalFilename
21  0x000eadb0 0x004f03b0 17   36   .rsrc   utf16le EnKSaR.HaCKeR.exe
22  0x000eadda 0x004f03da 11   24   .rsrc   utf16le ProductName
23  0x000eadf4 0x004f03f4 5    12   .rsrc   utf16le njRAT
24  0x000eae06 0x004f0406 14   30   .rsrc   utf16le ProductVersion
25  0x000eae24 0x004f0424 7    16   .rsrc   utf16le 0.6.4.0
26  0x000eae3a 0x004f043a 16   34   .rsrc   utf16le Assembly Version
27  0x000eae5c 0x004f045c 7    16   .rsrc   utf16le 0.6.4.0
28  0x000ef0b3 0x004f46b3 2267 2268 .rsrc   ascii   <?xml version="1.0" encoding="utf-8"?>\r\n<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\r\n  <assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>\r\n  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">\r\n    <security>\r\n      <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">\r\n        <!-- UAC Manifest Options\r\n            If you want to change the Windows User Account Control level replace the \r\n            requestedExecutionLevel node with one of the following.\r\n\r\n        <requestedExecutionLevel  level="asInvoker" uiAccess="false" />\r\n        <requestedExecutionLevel  level="requireAdministrator" uiAccess="false" />\r\n        <requestedExecutionLevel  level="highestAvailable" uiAccess="false" />\r\n\r\n            Specifying requestedExecutionLevel node will disable file and registry virtualization.\r\n            If you want to utilize File and Registry Virtualization for backward \r\n            compatibility then delete the requestedExecutionLevel node.\r\n        -->\r\n        <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />\r\n      </requestedPrivileges>\r\n    </security>\r\n  </trustInfo>\r\n  \r\n  <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">\r\n    <application>\r\n      <!-- A list of all Windows versions that this application is designed to work with. Windows will automatically select the most compatible environment.-->\r\n\r\n      <!-- If your application is designed to work with Windows 7, uncomment the following supportedOS node-->\r\n      <!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>-->\r\n      \r\n    </application>\r\n  </compatibility>\r\n  \r\n  <!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->\r\n  <!-- <dependency>\r\n    <dependentAssembly>\r\n      <assemblyIdentity\r\n          type="win32"\r\n          name="Microsoft.Windows.Common-Controls"\r\n          version="6.0.0.0"\r\n          processorArchitecture="*"\r\n          publicKeyToken="6595b64144ccf1df"\r\n          language="*"\r\n        />\r\n    </dependentAssembly>\r\n  </dependency>-->\r\n\r\n</asmv1:assembly>\r\n

Podemos ver con rabin que ya nos sale en los string que es njRAT. Para ver si está empaquetado Utilizamos entroper.py para ver la entropía de dicha muestra: Vemos que varía la entropia del archivo, por lo tanto vamos a comprobar su estructura con el binwalk:

remnux@remnux:~/Downloads/theJungle/malware/Trojan.Win32.Bladabindi$ binwalk njRAT.exe 
 
DECIMAL       HEXADECIMAL     DESCRIPTION
--------------------------------------------------------------------------------
0             0x0             Microsoft executable, portable (PE)
1337          0x539           Microsoft executable, portable (PE)
193691        0x2F49B         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
194513        0x2F7D1         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
195335        0x2FB07         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
196026        0x2FDBA         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
210964        0x33814         PNG image, 256 x 256, 8-bit/color RGBA, non-interlaced
211005        0x3383D         Zlib compressed data, default compression
291778        0x473C2         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
292794        0x477BA         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
293539        0x47AA3         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
294522        0x47E7A         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
295486        0x4823E         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
296334        0x4858E         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
297249        0x48921         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
298318        0x48D4E         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
299473        0x491D1         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
300628        0x49654         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
602482        0x93172         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
603277        0x9348D         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
604016        0x93770         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
604662        0x939F6         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
605401        0x93CD9         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
606320        0x94070         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
607214        0x943EE         PNG image, 16 x 16, 8-bit/color RGB, non-interlaced
608015        0x9470F         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
608445        0x948BD         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
609374        0x94C5E         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
610124        0x94F4C         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
610503        0x950C7         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
611546        0x954DA         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
612337        0x957F1         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
613227        0x95B6B         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
614295        0x95F97         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
615239        0x96347         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
615978        0x9662A         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
616717        0x9690D         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
617402        0x96BBA         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
618308        0x96F44         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
619316        0x97334         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
688569        0xA81B9         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
689445        0xA8525         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
690269        0xA885D         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
691161        0xA8BD9         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
691864        0xA8E98         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
700125        0xAAEDD         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
701132        0xAB2CC         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
701993        0xAB629         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
702887        0xAB9A7         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
703846        0xABD66         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
704537        0xAC019         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
705283        0xAC303         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
706173        0xAC67D         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
706864        0xAC930         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
707424        0xACB60         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
759781        0xB97E5         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
760642        0xB9B42         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
761520        0xB9EB0         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
762549        0xBA2B5         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
763611        0xBA6DB         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
764618        0xBAACA         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
765309        0xBAD7D         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
770325        0xBC115         PNG image, 58 x 36, 8-bit/color RGBA, non-interlaced
770709        0xBC295         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
771604        0xBC614         PNG image, 16 x 16, 8-bit/color RGBA, non-interlaced
778945        0xBE2C1         PNG image, 227 x 256, 8-bit/color RGB, non-interlaced
779036        0xBE31C         Zlib compressed data, compressed
839821        0xCD08D         mcrypt 2.2 encrypted data, algorithm: blowfish-448, mode: CBC, keymode: 8bit
859343        0xD1CCF         Copyright string: "CopyrightAttribute"
920324        0xE0B04         XML document, version: "1.0"
920894        0xE0D3E         Microsoft executable, portable (PE)
948630        0xE7996         XML document, version: "1.0"
958450        0xE9FF2         Copyright string: "CopyrightAttribute"
979123        0xEF0B3         XML document, version: "1.0"
 

Podemos ver que al principio tiene un PE, luego varias imagenes, luego un zip, luego varias imagenes , para a continuación tiene otro zip, un fichero encriptado modo cbc con el algoritmo blowfish-448, una licencia de copyright. docuemnto xml, otro pe y más licencias y documento xml.

Consigo estraer los recursos utilizando rabin2 -e

binwalk -e njRAT.exe 

Me extrae los siguientes recursos

remnux@remnux:~/Downloads/theJungle/malware/Trojan.Win32.Bladabindi/_njRAT.exe.extracted$ ls
3383D  3383D.zlib  BE31C  BE31C.zlib

A continuación buscamos dominios con el comando grep

remnux@remnux:~/Downloads/theJungle/malware/Trojan.Win32.Bladabindi$ grep -aEro '[a-z]+\.(com|es|net)'
njRAT.exe:twitter.com

<<<<<<< HEAD no sale twiter En Flarew para el análisis de la muestra, hemos cambiado la extesion a .malware para que no se pueda ejecutar por acciendente en windows ya que la muestrá está pensada para ejecutarse en dicho entorno. Utilizamos CFF Explorer y vemos que la rawsize y la virtual addres tiene casi el mismo tamaño por lo que entendemos que la muestra no ha sido empaquetada:

nos sale twiter que es el C&C que utiliza para obtener ordenes. Si queremos ver más información desde nuestra máquina remux, utilizamos el siguiente comando:

remnux@remnux:~/Downloads/theJungle/malware/Trojan.Win32.Bladabindi$ peframe njRAT.exe

Y nos muestra la siguiente información:

XLMMacroDeobfuscator: pywin32 is not installed (only is required if you want to use MS Excel)
 
 
--------------------------------------------------------------------------------
File Information (time: 0:00:02.402526)
--------------------------------------------------------------------------------
filename         njRAT.exe
filetype         PE32 executable (GUI) Intel 80386 Mono/.Net assembly, for MS Wi
filesize         982016
hash sha256      fd624aa205517580e83fad7a4ce4d64863e95f62b34ac72647b1974a52822199
virustotal       /
imagebase        0x400000
entrypoint       0xec3de
imphash          f34d5f2d4577ed6d9ceec516c1f5a744
datetime         2013-09-27 08:00:20
dll              False
directories      import, debug, tls, resources, relocations
sections         .text, .sdata, .rsrc, .reloc
 
 
--------------------------------------------------------------------------------
Yara Plugins
--------------------------------------------------------------------------------
IsPE32
IsNET EXE
IsWindowsGUI
HasDebugData
NETexecutableMicrosoft
 
 
--------------------------------------------------------------------------------
Behavior
--------------------------------------------------------------------------------
Xor
disable dep
network tcp listen
keylogger
 
 
--------------------------------------------------------------------------------
Sections Suspicious
--------------------------------------------------------------------------------
For each section the value of entropy is less than 6
 
 
--------------------------------------------------------------------------------
Metadata
--------------------------------------------------------------------------------
Comments         njRAT
CompanyName      njq8
FileDescription  njRAT
FileVersion      0.6.4.0
InternalName     EnKSaR.HaCKeR.exe
LegalCopyright   Copyright © njq8 2013
LegalTrademarks  njRAT
OriginalFilename EnKSaR.HaCKeR.exe
ProductName      njRAT
ProductVersion   0.6.4.0
Assembly Version 0.6.4.0
 
 
--------------------------------------------------------------------------------
Import function
--------------------------------------------------------------------------------
mscoree.dll      1
 
 
--------------------------------------------------------------------------------
Ip Address
--------------------------------------------------------------------------------
54.54.54.54
 
 
--------------------------------------------------------------------------------
Url
--------------------------------------------------------------------------------
http://www.w3.org/2001/XMLSchema-instance
https://twitter.com/njq8
 
 
--------------------------------------------------------------------------------
File
--------------------------------------------------------------------------------
njRAT.exe        Executable
User32.dll       Library
mscoree.dll      Library
ClassLibrary1.exe Executable
avicap32.dll     Library
EnKSaR.HaCKeR.exe Executable
 
 
--------------------------------------------------------------------------------
Fuzzing
--------------------------------------------------------------------------------
String too long
 

El cual nos dice mucha información como utiliza la función xor para ofuscar, abre puerto e intenta hacer una conexión 54.54.54.54 , también deshabilita DEP que es la protección que se pone a nivel de sistema operativo para evitar ataques de ejecución de la pila y por ultimo habilita un keylogger para poder capturar lo que se escribe en teclado para poder mandarlo. Podemos comprobar que utiliza la siguiente url https://twitter.com/njq8 , como C&C , es comun en dichos RAT utilizen redes sociales para facilitar la emisión de ordens.

En Flarew para el análisis de la muestra, hemos cambiado la extesion a .malware para que no se pueda ejecutar por accidente en windows ya que la muestra está pensada para ejecutarse en dicho entorno. Utilizamos CFF Explorer y vemos que la rawsize y la virtual addres tiene casi el mismo tamaño por lo que entendemos que la muestra no ha sido empaquetada:

Análisis Dinámico Básico

Ejecutamos el Process Monitor para ver como funciona que comando y vemos que intenta cargar lo siguiente El árbol de procesos es el siguiente: Además en njRat crea un fichero llamado windows.exe en la carpeta temporal, que intenta habilita las reglas del firewall para establecer conexiones. El comando que ejecuta es el siguiente :

`netsh firewall add allowedprogram "C:\Users\admin\AppData\Local\Temp\windows.exe" "windows.exe" ENABLE`

Este comando se usa para permitir que un programa específico (en este caso, “windows.exe”) pase a través del firewall de Windows, agregándolo a la lista de programas permitidos. En el remmux ejecutamos el wireshark para ver que conexiones intenta hacer y podemos ver que intenta conetarse a una 239.255.255.250 utilizanod udep ssdp. SSDP, es utilizado para descubrir servicios. Con esto concluiría el análisis básico de njRAT, se ha cubierto la parte de clasificación del virus, se ha comentado su funcionamiento y también se ha comprobado su funcionamiento ejecutándolo en windows.

Links

En está sección se muestra los links donde están la muestras dentro del repositorio: https://github.com/ISRL-UAH/theJungle/tree/carlosGJ/samples/Trojan.Win32.Bladabindi En el siguiente link esta la regla yara que escogí: https://github.com/ISRL-UAH/theJungle/tree/carlosGJ/info/Trojan.Win32.Bladabindi

origin/main