miércoles, 24 de enero de 2018

Malware Forence

Malware Forensics

El malware forensics se puede hacer de 4 formas:
- Análisis estático básico
- Análisis dinámico básico
- Análisis estático Avanzado
- Análisis dinámico Avanzado

Cuando en el analisis estatico basico no podemos obtener muchas informacion por que el archivo puede estar packed o ofuscado, el análisis dinámico nos permitiría mostrar mas, por que al ejecutar el virus vamos a poder observar que acciones va a realizar.
A través de la herramienta Process Monitor, permite grabar todas las tareas que realizan los procesos de tal forma que luego se puede revisar que acciones realizo el malware, como por ejemplo si muto, si creo un registro en el RegEdit, entre otras.
Uno de los filtros que puedo aplicar para conocer si escribio en el archivo de registro, es filtrar la operación a con la palabra clave RegSetValue y para saber si muto, se puede conocer si ejecuto la operación WriteFile


Lo que muestra en la siguiente figura son las acciones realizadas por el malware, en las segunda acción se puede ver que se copio el archivo como vmx32to64.exe en la carpeta mencionada.
En la tercera acciones se puede ver que genero un registro para que se ejecute el virus automáticamente al momento de reiniciar.


En la figura anterior se muestra que el malware escribe constantemente en Microsoft\Cryptography\RNG\Seed, este registro es una información generada como semilla para un número aleatorio criptográfico. Hay dos formas de generar semillas para números aleatorios en criptografía a traves de hardware y software, este registro no están importante, puede distraer nuestra atención, por eso es mejor filtrarlo.

Un malware no solo se presenta en un exe, tambien puede venir en una dll, para ejecutar la DLL utilizamos el siguiente comando:
C:\>rundll32.exe Lab03-02.dll,installA

Ahora extraemos información de la DLL, un registro importante es por ejemplo cuando el malware escribe dentro del registro HKLM\SYSTEM\CurrentControlSet\Services, esto nos da un indicio de que el malware se esta colocando como servicio.
La imagen anterior muestra los procesos ejecutados por una dll, dado que el malware es una DLL, depende de un ejecutable para ejecutarlo. De hecho, en la linea 2 se puede observar que ImagPath esta con el parametro svchost.exe -k netsvcs, lo cual significa que el malware sera lanzado sobre el procesos svchost, el proceso sobre el que es lanzado svchost es básicamente es el encargado en Windows de ejecutar los servicios que corren desde una DLL (dynamic-link libraries). Existen tantas entradas svchost como procesos que lo utilizan.  El resto de la información, como DisplayName y Descripción, la line 3 y 4, crea una huella digital única que se puede utilizar para identificar el servicio malicioso.
En la imagen anterior se puede extraer información como el nombre del servicio y el DisplayName, ahora vamos a ejecutar el virus.
If we examine the strings closely, we see SOFTWARE\Microsoft\Windows NT\CurrentVersion\SvcHostand a message "You specify service name not in Svchost//netsvcs, must be one of following". If we follow our hunch and examine the \SvcHost\netsvcs registry key, we can see other potential service names we might use, like 6to4 AppMgmt. Running Lab03-02.dll,installA 6to4 will install this malware under the 6to4 service instead of the IPRIP service, as in the previous listing.
After installing the malware as a service, we could launch it, but first we’ll set up the rest of our basic dynamic tools. We run procmon (after clearing out all events); start Process Explorer; and set up a virtual network, including ApateDNS and Netcat listening on port 80 (since we see HTTP in the strings listing).
Since this malware is installed as the IPRIP service, we can start it using the net command in Windows, as follows:
c:\>net start IPRIP
The Intranet Network Awareness (INA+) service is starting.
The Intranet Network Awareness (INA+) service was started successfully.
The fact that the display name (INA+) matches the information found in the registry tells us that our malicious service has started.
Next, we open Process Explorer and attempt to find the process in which the malware is running by selecting Find ▸ Find Handle or DLL to open the dialog shown in Figure C-6. We enter Lab03-02.dll and click Search. As shown in the figure, the result tells us that Lab03-02.dll is loaded by svchost.exe with the PID 1024. (The specific PID may differ on your system.)

Figure C-6. Searching for a DLL in Process Explorer
In Process Explorer, we select View ▸ Lower Pane View ▸ DLLs and choose the svchost.exe running with PID 1024. Figure C-7 shows the result. The display name Intranet Network Awareness (INA+) shown at ❶confirms that the malware is running in svchost.exe, which is further confirmed when we see at ❷ that Lab03-02.dll is loaded.

Figure C-7. Examining service malware in Process Explorer
Next, we turn our attention to our network analysis tools. First, we check ApateDNS to see if the malware performed any DNS requests. The output shows a request for practicalmalwareanalysis.com, which matches the strings listing shown earlier.
NOTE
It takes 60 seconds after starting the service to see any network traffic (the program does a Sleep(60000)before attempting network access). If the networking connection fails for any reason (for example, you forgot to set up ApateDNS), it waits 10 minutes before attempting to connect again.
We complete our network analysis by examining the Netcat results, as follows:
c:\>nc -l -p 80
GET /serve.html HTTP/1.1
Accept: */*
User-Agent: MalwareAnalysis2 Windows XP 6.11
Host: practicalmalwareanalysis.com
We see that the malware performs an HTTP GET request over port 80 (we were listening over port 80 with Netcat since we saw HTTP in the string listing). We run this test several times, and the data appears to be consistent across runs.
We can create a couple of network signatures from this data. Because the malware consistently does a GETrequest for serve.html, we can use that GET request as a network signature. The malware also uses the User-Agent MalwareAnalysis2 Windows XP 6.11. MalwareAnalysis2 is our malware analysis virtual machine’s name (so this portion of the User-Agent will be different on your machine). The second part of the User-Agent (Windows XP 6.11) is consistent and can be used as a network signature.



A través de la herramienta ProcessExplorer vamos a poder encontrar que el malware muto con el nombre WinVMX32.

Para conocer que acciones realizo en la red, podemos utilizar la herramienta apateDNS

Una guia completa para instalar inetsim es la siguiente:
https://techanarchy.net/2013/08/installing-and-configuring-inetsim/





miércoles, 17 de enero de 2018

Como revisar los procesos de Windows

La herramientas tasklist, nos permite listar todos los procesos con información como que programa esta corriendo, cuando de memoria esta consumiendo, el estado del proceso que usuario esta haciendo uso del proceso el tiempo que esta activo, entre otras muchas cosas.

Para listar todos los procesos que no responden, se adiciona el parámetro /v para que muestre toda la información y /FI para filtrar el contenido, se puede utilizar el siguiente comando:
tasklist /v /FI "STATUS eq Not Responding"

Si quiere eliminarlo, se adiciona el /F para forzar el cierre y /FI para hacer el filtro,  se puede utilizar el siguiente comando:
taskkill /F /FI "STATUS eq Not Responding"

Para buscar todos los procesos, se puede filtrar utilizando el parámetro /FI seguido del parámetro de filtro, el parámetro de filtro puede ser el de las cabeceras de la tabla mostrada, se puede utilizar comodines como * para mejorar la busqueda, la lista completa de parámetros esta en la siguiente pagina:
https://technet.microsoft.com/es-es/library/bb491010.aspx


tasklist /v /FI "IMAGENAME eq chrome*"


Para ordenar los resultados podemos adicionar el comando SORT
tasklist /v /FI "IMAGENAME eq chrome*"  | sort /r /+56