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

# Miscelanea

### Busqueda recursiva de una palabra dentro de un archivo

```bash
grep -rn "palabra_a_buscar" /ruta/donde/empezar/
```

### Busqueda de archivos con git

```bash
git log
```

```bash
git show 'id'
```

### Shell Interactiva

```bash
script /dev/null -c bash
ctrl Z
stty raw -echo;fg
reset
xterm
export SHELL=bash TERM=xterm
stty size                             #verificar tamaño de tty en maquina atacante
stty rows x columns y
```

### Verificar con ID si el user pertenece algun grupo y luego busqueda recursiva

```bash
id
```

```bash
find / -group 'grupo' 2>/dev/null | grep -v "^/proc\|^/run\|^/sys”
```

### En maquinas con docker, enumerar el .sock

```bash
ls -la /var/run/docker.sock
```

### Disminución de tamaño de MTU en interfaz tun0

Este error ocurre por un problema de tamaño de paquetes (MTU) en la VPN de HTB. La interfaz `tun0` trabaja por defecto con un MTU de 1500. Cuando interactúas con el servicio web, como al enviar una petición POST, el tamaño del paquete puede superar este límite (llegando a unos 1560).

Como estos paquetes suelen viajar con el bit DF (*Don't Fragment*) activado, cuando llegan al firewall este no tiene permitido dividirlos en partes más pequeñas. Al ser demasiado grandes para pasar por el túnel y no poder fragmentarse, los paquetes se pierden, provocando que la página se quede "colgada" y no termine de cargar por completo.

Aqui hay una solucion y es colocar el MTU de los paquetes de tun0 a 1200 para que el firewall no se sature y pueda pasar directamente.

```bash
sudo ip link set dev tun0 mtu 1200
```

### Conexion con winrm y ejecucion de comandos en windows

```powershell
$cred = New-Object System.Management.Automation.PSCredential('INLANEFREIGHT\sql_svc', (ConvertTo-SecureString 'lucky7' -AsPlainText -Force)); $s= New-PSSession -ComputerName MS01 -Credential $cred; Invoke-Command -Session $s -ScriptBlock { type C:\Users\Administrator\Desktop\flag.txt }
```

### Enumeracion de hosts internos - One liner Linux

```bash
bash -c 'for i in {1..254}; do ping -c 1 172.16.5.$i | grep "bytes from" & done; wait'
```

### Enumeracion de hosts internos - One liner Windows

CMD

```powershell
for /L %i in (1,1,254) do @ping -n 1 -w 200 172.16.5.%i | find "Reply" > nul && echo 172.16.5.%i
```

POWERSHELL

```powershell
1..254 | % { if (Test-Connection 172.16.5.$_ -Count 1 -Quiet) { echo 172.16.5.$_ } }
```

Portforwarding simple

```bash
ssh -i id_rsa webadmin@10.129.24.238 -D 9050 -N -v
```

habilitar socks4 127.0.0.1 9050

### FUZZING

Recursivo

```bash
ffuf -w /opt/useful/seclists/Discovery/Web-Content/directory-list-2.3-small.txt -u http://SERVER_IP:PORT/FUZZ -recursion -recursion-depth 1 -e .php -v
```

### PASSWORD 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"
```


---

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