Guía y respuestas del CTF de Splunk y Corelight - Parte 1

Puedes encontrar la segunda parte aquí

Hoy estoy aquí con una guía con las soluciones al CTF de threathunting ofrecido por Corelight y Splunk en su página de BOTS. Puedes registrarte gratis y aunque hay un límite de tiempo para hacer el reto de 3 horas, puedes jugarlo cuantas veces quieras.

Si ya conoces los CTFs de BOTS de Splunk de otros años, el formato te va a ser bastante familiar, si no, es muy fácil, tienes una serie de preguntas y para encontrar la respuesta tienes que hacer búsquedas en logs usando Splunk. Este reto puede ser jugado completamente en línea, simplemente usando la instancia de Splunk disponible en la misma página del reto.

El nivel de este CTF si tienes experiencia en otras ediciones de BOTS o en threathunting, diría que es bajo o muy bajo; si eres completamente nuevo en Splunk o con muy poca experiencia en la herramienta, entonces es un muy buen primer punto de contacto con Splunk y threathunting.

SPOILER ALERT: HE INCLUIDO TODAS LAS RESPUESTAS AL RETO, PERO ESTÁN ESCONDIDAS Y TIENES QUE HACER CLICK EN CADA UNA PARA VERLAS.

Una vez que hayas hecho login, verás que hay 3 CTFs disponibles en BOTS Splunk.

Corelight CTF

Iré investigando y respondiendo las preguntas una a una, numeradas de la misma manera que en los escenarios. Haz click en Play Now en el reto de Corelight, y luego abre en una segunda pestaña el servidor de Splunk que aparece en la sección de recursos - ahí tienes las credenciales para acceder también.

Resources

Una vez hecho login en el servidor de Splunk, vamos a Apps en la parte de arriba y hacemos click en la de Search & Reporting.

Resources

¡Y a jugar!

Escenario 1 Corelight Zeek and Suricata CTF

Importante: para este escenario tenemos que usar el índice “corelight” en todas nuestras búsquedas

  1. How many total Suricata alerts were generated in this index?

    Primero encontramos todos los _sourcetypes ordenados por número de ocurrencias:

       `| metadata index="corelight" type=sourcetypes | sort - totalCount`
    

    Vemos 2 relacionados con Suricata, y uno de ellos tienes todos los campos relacionados con alertas

    Buscamos por ese sourcetype:

       `index="corelight" sourcetype="corelight_suricata_corelight"`
    

    Y obtenemos el número de eventos

    Question 101
Respuesta (Click para abrir)
	47
  1. Most of the alerts are being generated by a single source host. What is its IP address?

    Contamos por el campo src:

      index="corelight" sourcetype="corelight_suricata_corelight" | stats count by src
    
Respuesta (Click para abrir)
	10.0.0.31
  1. What’s the name of the malware family identified by these alerts?

    Buscando en los eventos el campo alert.signature, hay uno que es obvio:

    index="corelight" sourcetype="corelight_suricata_corelight" "alert.signature"="ET MALWARE Win32/Trickbot Data Exfiltration"
    
    
    Question 103
    
    
Respuesta (Click para abrir)
		trickbot
  1. Let’s take a closer look at the “ET MALWARE Win32/Trickbot Data Exfiltration” alerts. You’ll notice that three of the alerts share a single UID, meaning they all occurred on a single TCP stream. What is that UID?

    Contamos por el campo uid:

       index="corelight" sourcetype="corelight_suricata_corelight" "alert.signature"="ET MALWARE Win32/Trickbot Data Exfiltration" | stats count by uid
    

    Hay uno con 3 eventos.

Respuesta (Click para abrir)
	CAoNRI62m9CRqS0R2
  1. What is the IP address of the malicious server involved in the alerts for this stream?

    Usamos el UID de la pregunta anterior para filtrar nuestra búsqueda:

       index="corelight" sourcetype="corelight_suricata_corelight" "alert.signature"="ET MALWARE Win32/Trickbot Data Exfiltration" uid=CAoNRI62m9CRqS0R2 | table src, dest
    

    La IP de destino es la del servidor malicioso, ya que esta es una alerta de exfiltrado de datos.

Respuesta (Click para abrir)
	103.16.104.83
  1. What layer 7 protocol is the traffic in the previous question flowing over that generates the alerts?

    En una búsqueda anterior, mirando a campos como app y dest_port (443), la respuesta es clara.

Respuesta (Click para abrir)
	http
  1. Taking the UID mentioned in the previous question and searching for it across the index, we see that a corelight_notice log was also generated. What is the number of the MITRE ATT&CK TTP referenced in the notice?

    Seguimos las instrucciones de la pregunta:

       index="corelight" uid=CAoNRI62m9CRqS0R2 sourcetype=corelight_notice
    

    Y obtenemos un solo evento. Si vemos el contenido del campo msg:

       msg: Potential C2 traffic - Trickbot Malware https://attack.mitre.org/software/S0266/. This detection is based on attributes within the http connection, further details can be found in http.log and conn.log - the relevant log lines will share the same uid as this notice. (Algorithm 1)
    
    Question 107
Respuesta (Click para abrir)
	S0266
  1. What User-Agent string was sent as part of the Trickbot HTTP requests?

    Continuamos filtrando por el UID que tenemos y vamos al sourcetype corelight_http:

       index="corelight" uid=CAoNRI62m9CRqS0R2 sourcetype=corelight_http
    

    Miramos en el campo http_user_agent.

Respuesta (Click para abrir)
	Ghost
  1. What is a process name that is repeated within the POST body of these HTTP requests?

    Simplemente tenemos que buscar en el contenido del campo post_body de la búsqueda anterior. Al principio no estaba seguro sobre que se está preguntando realmente, al final me di cuenta que se refiere a que proceso se repite varias veces en el mismo body.

Respuesta (Click para abrir)
	svchost.exe
  1. Let’s look at what happened after the malware was dropped. Looking at Suricata alerts following the Trickbot alert, a popular scanning tool appears to have been used for reconnaissance. What is the name of that tool?

    Establecemos el tiempo en 5 minutos después de los eventos con la firma de trickbot:

       Time Picker
    

    Mostramos valores para las firmas posteriores:

       index="corelight" sourcetype="corelight_suricata_corelight" | stats values(alert.signature)
    

    Y la respuesta está en una de dichas firmas.

Respuesta (Click para abrir)
	nessus
  1. One of the alerts generated by our infected host could result in command execution on a wireless access point. Looking at the response from the remote system, however, it’s pretty clear that the attack failed. How many bytes did the target send back to the attacker on this connection?

    Primero encontramos la alerta mencionada con la búsqueda anterior:

       index="corelight" sourcetype="corelight_suricata_corelight" | stats values(alert.signature)
    
    Exploit

    Vemos una firma ETPRO Exploit Possible Asus WRT LAN Backdoor Command Execution Buscamos el evento donde aparece:

       index="corelight" sourcetype="corelight_suricata_corelight" "ETPRO Exploit Possible Asus WRT LAN Backdoor Command Execution"
    

    Cogemos el UID del evento C1k4ed3UCQLkshoMZh y buscamos en el sorcetype corelight_conn

       index="corelight" C1k4ed3UCQLkshoMZh sourcetype=corelight_conn
    

    Obtenemos 1 evento, y en el campo resp_ip_bytes tenemos la respuesta.

Respuesta (Click para abrir)
	0
  1. Looking at the layer 7 services used by the infected host after the Trickbot alerts above, we see an SSH connection made to an internal host. What is the IP address of that host?

    Sabemos la IP de anteriores búsquedas: 10.0.0.31. Sabemos que es SSH, así que buscamos en el sourcetype corelight_ssh:

       index="corelight" src=10.0.0.31 sourcetype=corelight_ssh
    

    Nos quedan 23 eventos, con varias IP internas como destino, pero hay un campo, auth_success, filtramos por éste:

       index="corelight" src=10.0.0.31 sourcetype=corelight_ssh auth_success=true | table dest
    
    Exploit
Respuesta (Click para abrir)
	10.0.0.72
  1. What is the PCR (producer/consumer ratio) of that SSH session?

    Lo primero, que es PCR - no, no es un test para detectar COVID 😛.

    		( SrcApplicationBytes - DstApplicationBytes )
       PCR = 	---------------------------------------------
         		( SrcApplicationBytes + DstApplicationBytes )
    

    Con el UID de la conexión CLn5mqsd7SVfTn10g, buscamos en el sourcetype corelight_conn:

       index="corelight" CLn5mqsd7SVfTn10g sourcetype=corelight_conn
    

    Además los logs de Corelight nos dan un campo won el PCR precalculado, que majos: pcr: -0.9959339475461754

Respuesta (Click para abrir)
	-0.99593
  1. Examining the inferences section of the SSH log associated with that session, one code indicates a behavior that explains the PCR we just observed. Which code is it?

    Si volvemos al evento en el sourcetype corelight_ssh, hay un campo llamado InferenceName. Hay 3 inferencias, y la que probablemente esté causando la PCR en questión es Large File Download.

    PCR

    Hay otro campo en el evento, inferences, con el código.

Respuesta (Click para abrir)
	LFD
  1. The owner of the infected workstation had no credentials to log into 10.0.0.72 over SSH. However, there was another connection between those hosts over HTTP. What attack type was sent over that connection?

    Buscamos conexiones entre estos dos sistemas relacionados con HTTP:

       index="corelight" src=10.0.0.31 dest=10.0.0.72 sourcetype=corelight_http
    

    Miramos los valores del campo uri en busca de pistas:

       index="corelight" src=10.0.0.31 dest=10.0.0.72 sourcetype=corelight_http | stats values(uri)
    
    ataque

    Y vemos lo que parecen ataques SQLi:

       /mutillidae/index.php?page=user-info.php&username=admin'+or+1=1+#&password=adfadf&user-info-php-submit-button=View+Account+Details
    
Respuesta (Click para abrir)
	SQL Injection
  1. What parameter of the index.php script did the infected system attempt to use for SQL injection?

    Vemos el campo URI de la pregunta anterior, y vemos el parámetro después de la &:

       page=user-info.php&username=admin
    
Respuesta (Click para abrir)
	username
  1. What was the HTTP status code from the targeted server?

    De el evento anterior, campo status_code.

Respuesta (Click para abrir)
	200
  1. Did this SQL injection attack generate any Suricata alerts? (Yes/No)

    Seleccionamos un rango de tiempo de -+ 5 segundos desde el evento de la inyección SQL, y buscamos alertas de Suricata.

Respuesta (Click para abrir)
	NO
  1. Returning to SSH connections made by our infected host, we see a second one being made to a country the organization has no business relationship with. What country is that connection going to?

    Reutilizamos la búsqueda de la pregunta 112:

       index="corelight" src=10.0.0.31 sourcetype=corelight_ssh auth_success=true
    

    Hay un campo, remote_location.country_code, con el código de dos letras del país.

Respuesta (Click para abrir)
	Thailand
  1. Judging by the PCR (producer/consumer ratio) of this connection, data was definitely exfiltrated to this external system. What is the SSH host key of that system?

    La respuesta está en el mismo evento, en el campo host_key.

Respuesta (Click para abrir)
	1c:6e:58:a2:57:98:33:f4:53:e8:63:46:df:a2:31:ef
  1. How many payload bytes were sent over that connection?

    Buscamos con el UID de la conexión: CPxHxI3uiHLgH2I196

       index="corelight" CPxHxI3uiHLgH2I196 sourcetype=corelight_conn
    

    Nos queda un evento, y la pregunta es sobre los bytes enviados, así que el campo bytes_out debería tener la respuesta.

Respuesta (Click para abrir)
	128105745
  1. The challenge author’s favorite SSL certificate organization name - a default out of many certificate generation tools - is present in this index, highlighted by a Suricata alert. What is that organization name?

    Empezamos mirando a todas las alertas de Suricata filtrando por la firma:

       index="corelight" sourcetype="corelight_suricata_corelight"  | stats values(alert.signature)
    

    Vemos un par de ellas relacionadas con TLS y certificados:

       ET POLICY OpenSSL Demo CA - Internet Widgits Pty (O)
       ET POLICY Signed TLS Certificate with md5WithRSAEncryption
    

    De la pregunta, entiendo que es la primera alerta, “ET POLICY OpenSSL Demo CA - Internet Widgits Pty (O)”, tomamos el UID, CxAsok2xLkCyAoxiy6, y miramos en el sourcetype corelight_ssl:

       index="corelight" CxAsok2xLkCyAoxiy6 sourcetype=corelight_ssl
    

    Hay un campo ssl_issuer con todos los detalles.

    Issuer
Respuesta (Click para abrir)
	Internet Widgits Pty Ltd

Hasta aquí el primer escenario

Esta era la última pregunta del primer escenario; para no alargarlo demasiado, dejamos el segundo escenario para una nueva entrada. ¡Espero que hayas encontrado esta guía útil y nos vemos pronto!

EDIT: Puedes encontrar la segunda parte aquí


Ver también