Linux PrivEsc
Overview — A practice lab built around one deliberately broken Debian 6 virtual machine (kernel 2.6.32) where almost every classic Linux privilege escalation is planted at once. You log in as an ordinaryuserand are walked through twenty-odd techniques, each ending in a root shell: a root-run MySQL UDF, world-readable and world-writable password files, eleven sudo shell escapes,LD_PRELOADandLD_LIBRARY_PATH, writable cron scripts, tar wildcard injection, an old Exim SUID bug, shared-object injection and environment tricks in custom SUID programs, stored credentials and keys, NFS and kernel exploits.
| Platform | TryHackMe |
| Category | Offensive |
| Difficulty | Medium |
| Room | Linux PrivEsc |
| Target IP | MACHINE_IP |
Attack map
ssh user@MACHINE_IP (user / password321)
|
+-- service running as root ........ MySQL UDF (raptor_udf2)
+-- weak file permissions .......... /etc/shadow read or write, /etc/passwd write
+-- sudo rules ..................... shell escapes, LD_PRELOAD, LD_LIBRARY_PATH
+-- cron as root ................... writable script, PATH order, tar wildcard
+-- SUID/SGID binaries ............. Exim CVE-2016-1531, missing .so,
| relative command, bash function / SHELLOPTS
+-- secrets ........................ history, VPN auth file, root SSH key
+-- NFS no_root_squash ............. SUID payload planted from the attacker
+-- kernel ......................... suggester output, Dirty COW (does not build)
v
root
Task 1 — Deploy the Vulnerable Debian VM
The machine was assembled by Sagi Shahar for his Linux privilege escalation workshop. Each later task leaves you with a root shell, and you are meant to leave it, clean up and log in again as user before the next one, because several techniques reuse the same filenames (for example /tmp/rootbash).
The VM is old, and so is its SSH server. Modern OpenSSH clients refuse its ssh-rsa host key, so you have to opt back in explicitly:
ssh -oHostKeyAlgorithms=+ssh-rsa user@MACHINE_IP
The same option is needed for scp. Without it you see no matching host key type found. Their offer: ssh-rsa,ssh-dss. The password is password321.
user@debian:~$ id
uid=1000(user) gid=1000(user) groups=1000(user),24(cdrom),25(floppy),29(audio),30(dip),44(video),46(plugdev)
Q: Run the "id" command. What is the result?
A: uid=1000(user) gid=1000(user) groups=1000(user),24(cdrom),25(floppy),29(audio),30(dip),44(video),46(plugdev)
A handy recurring trick in this room is the "rootbash" pattern: have a root-run command copy/bin/bashto/tmp/rootbashand set the SUID bit. You then run/tmp/rootbash -p. The-pflag matters because Bash normally drops the effective UID when it differs from the real UID;-p(privileged mode) keeps it, givingeuid=0.
Root Access unlocks the content you can't see — everything else on the site is already open.
See Root Access plansNo account? Create one free then upgrade from your console.