# DarkHole 2

```python
arp-scan -I eth0 --localnet --ignoredups
Interface: eth0, type: EN10MB, MAC: 00:0c:29:07:19:cb, IPv4: 192.168.1.139
Starting arp-scan 1.10.0 with 256 hosts (https://github.com/royhills/arp-scan)
192.168.1.1	64:66:24:39:6c:a8	(Unknown)
192.168.1.129	38:f9:d3:39:de:c0	(Unknown)
192.168.1.145	00:0c:29:c1:f5:01	(Unknown)
192.168.1.144	00:7c:2d:1f:c0:93	(Unknown)
```

Hacenos un escaneo a nivel de red local y la 145 es la de la maquina victima.

***

```python
sudo nmap -sS -Pn -n -vvv --open --min-rate 5000 192.168.1.145 -oG port | tail -n 8

PORT   STATE SERVICE REASON
22/tcp open  ssh     syn-ack ttl 64
80/tcp open  http    syn-ack ttl 64
MAC Address: 00:0C:29:C1:F5:01 (VMware)
```

Tenemos dos puertos abiertos en el Host.

***

```javascript
nmap -sCV -p22,80 192.168.1.145 -oN target.txt
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-11-26 06:32 EST
Nmap scan report for 192.168.1.145
Host is up (0.00083s latency).

PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 8.2p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   3072 57:b1:f5:64:28:98:91:51:6d:70:76:6e:a5:52:43:5d (RSA)
|   256 cc:64:fd:7c:d8:5e:48:8a:28:98:91:b9:e4:1e:6d:a8 (ECDSA)
|_  256 9e:77:08:a4:52:9f:33:8d:96:19:ba:75:71:27:bd:60 (ED25519)
80/tcp open  http    Apache httpd 2.4.41 ((Ubuntu))
| http-cookie-flags: 
|   /: 
|     PHPSESSID: 
|_      httponly flag not set
|_http-server-header: Apache/2.4.41 (Ubuntu)
|_http-title: DarkHole V2
| http-git: 
|   192.168.1.145:80/.git/
|     Git repository found!
|     Repository description: Unnamed repository; edit this file 'description' to name the...
|_    Last commit message: i changed login.php file for more secure 
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
```

Versiones y servicios que corren para cada uno de esos dos puertos.

***

<figure><img src="/files/Rwh981xJSGhuMyGcObqh" alt=""><figcaption></figcaption></figure>

En el propio escaneo de Nmap nos esta soplando un subdirectorio este .git, Usaremos git-dumper para tratarlo ya que es un proyecto.

{% embed url="<https://github.com/arthaud/git-dumper>" %}

Aca dejo el enlace a la herramienta donde la misma explica como se usar pero basicamente seria asi.

```java
git-dumper http://website.com/.git ~/CreaTuPropioDirectorio
```

***

<figure><img src="/files/yWqvhlh6gOTQzg5GIKfE" alt=""><figcaption></figcaption></figure>

Ahora despues entras al directorio donde recreastes el proyecto usando la anterior herramienta, observamos los logs de los pull que se hace con git al proyecto y encontramos credenciales de inicio de session.

***

<figure><img src="/files/Mt3BjJCdf586046N8wJ8" alt=""><figcaption></figcaption></figure>

Iniciamos session.

***

<figure><img src="/files/uKgYOxYTHDX52PpGjUek" alt=""><figcaption></figcaption></figure>

Ya en el dashboard hay una inyeccion SQL de primeras descubrimos con order by que hay 6 columnas esta peticion la pasaremos ah BurpSuite para un mejor trato.

***

<figure><img src="/files/kQMMfCQxIkqy9PHuVVaU" alt=""><figcaption></figcaption></figure>

Si en la Query preguntamos por  la actual base de datos nos la pasa.

***

<figure><img src="/files/GcDGs7HyrZnOTPnNA4hR" alt=""><figcaption></figcaption></figure>

Empezamos de primeras usamos `schema_name` que indica el nombre de un esquema en la base de datos, usado para organizar y agrupar objetos como tablas, vistas y funciones.

***

<figure><img src="/files/9y2AVM1QDh58zoXXqLW7" alt=""><figcaption></figcaption></figure>

Nostros vamos por la base de datos que se llama igual que la maquina, enumerando las tablas observamos que tenemos dos ssh y users.

***

<figure><img src="/files/wGNLfRtLGFwULJ15gsGs" alt=""><figcaption></figcaption></figure>

Ahora vamos por las columnas, la Query se lee asi, de la base de datos darkhole\_2 que tiene una tabla llamada ssh pasame las columnas que tiene dicha tabla. Observamos tres columnas id,user y pass.

***

<figure><img src="/files/ByLot0Yzr3UF2Ff6HC9K" alt=""><figcaption></figcaption></figure>

Ahora haciendo uso de group\_conat nos traemos la info de user  y pass que estan en la tabla ssh de la base de datos darkhole\_2, y tenemos credenciales de ssh Supuestamente.

***

```javascript
history | head  -n 150

  109  netstat -tulpn | grep LISTEN
  110  ssh -L 127.0.0.1:9999:192.168.135.129:9999 jehad@192.168.135.129
  111  curl http://localhost:9999
  112  curl "http://localhost:999/?cmd=id" 
  113  curl "http://localhost:9999/?cmd=id" 
  114  curl http://localhost:9999/
```

Si observamos el history de la maquina al parecer estan intentando hacer un PortForwarding, lo que significa que habra un servicio que corre internamente.

***

<figure><img src="/files/IrQs2mLPAnkQ9QRK3tif" alt=""><figcaption></figcaption></figure>

Lo consultamos y es correcto, ellos por lo que se ve lo hicieron via ssh yo lo hare con chisel, dejare el enlace a un articulo mio de como se usa y de donde descargarla.

{% embed url="<https://rodgar.gitbook.io/rodgar/ctf-writeups/pivoting/pivoting>" %}

Como se usa.

{% embed url="<https://github.com/jpillora/chisel/releases>" %}

Herramienta.

***

<figure><img src="/files/JmnQ3O00F3TyJmBH9PEx" alt=""><figcaption></figcaption></figure>

Creamos el tunel usando chisell para llegar hasta ese puerto 9999.

***

<figure><img src="/files/pgqvoNm6blQWd0WrAIjV" alt=""><figcaption></figcaption></figure>

En el puerto 9999 que lo redirigimos a mi 5000 en mi localhost esta esta web que directamente ya te dice lo que hay que hacer, si le pasamos un whoami somos losy, ahora nos enviaremos una revershell y  nos la deberia enviar como losy.

Basicamente haremos un userPivoting pasamos del usuario jehad a losy.

***

<figure><img src="/files/dnjsAaaOy8AMEK0PIN1k" alt=""><figcaption></figcaption></figure>

Nos enviamos la rev.

***

<figure><img src="/files/Qh21Hes7hBCOTxKTuYmD" alt=""><figcaption></figcaption></figure>

Escuchando con NC recivimos la conexion como losy, y bueno ahora somos otro usario y ya no jehad.

***

<figure><img src="/files/ObgR0IwsXROkE6RK8SOK" alt=""><figcaption></figcaption></figure>

De la misma manera que con el anterior usuario el history nos da pista, esta vez en el history esta la contraseña para el usuario losy.

Ahora si hacemos un sudo -l observamos que podemos ejecutar python3 de manera privilegiada.

***

<figure><img src="/files/l4loCa7agcrgJEa94IJe" alt=""><figcaption></figcaption></figure>

Somos root maquina resuelta.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://rodgar.gitbook.io/rodgar/plataformas/vulnhub/darkhole-2.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
