Last updated
Last updated
Miss-configured services (cronjobs)
any running as a privileged user?
Incorrect file permissions (exportfs, sudo)
Miss-configured environment ($PATH)
Binary with SUID bit
Software or OS with known vulnerabilities
Docker usergroup
Read http://touhidshaikh.com/blog/?p=790
If you get an error "su: must be run from a terminal" use one of the shell fixes above
Are you a sudo user already? Do you have access to powerful commands like chown or chmod?
Are you part of the sudo group, but not in the sudoers file?
What can we run with sudo?
Try su as all users and the username as password
User bash history
Create a copy of /bin/bash
or /bin/sh
can you call it rootbash
- make sure its owned by the root user. Then use /bin/bash -p
to run it
look for something(s) that are running which is not standard
if things are here that are not on the nmap scan - could be a firewall rule blocking it is mysql in there? If so creds will be stored somewhere on the box
Copy /tmp/packages.txt which it has created back to your machine and then run
Research where creds would be stored on certain webapps
What services are running as root?:
Look for vulnerable/privileged components such as: mysql, sudo, udev, python
If /etc/exports if writable, you can add an NFS entry or change and existing entry adding the no_root_squash flag to a root directory, put a binary with SUID bit on, and get root.
Are you in a docker usergroup
Get the image name docker ps
then run
this will then get you a root shell
If there is a cronjob that runs as run but it has incorrect file permissions, you can change it to run your SUID binary and get a shell.
The following command will list processes running by root, permissions and NFS exports.
Use netstat to find other machines connected
find / -name "*.txt" 2> >(grep -v 'Permission denied' >&2)
grep -R -i "password" 2> >(grep -v 'Permission denied' >&2)
If you can write to any of these files or directories you have a good chance of PE
Things to remember:
Run strings on the binary. Read all of it, don't just read the bottom of the output - read the top. Look for programs that the binary calls like curl
. If you spot one then if it doesn't have its full path you can exploit it by modifying the path variable and creating a file with /bin/bash.
See box symofonos:1.
The file will run as the owner no matter who executes it. So if root owns it, we can run it and hijack it to become root
Linux capabilities provide a subset of the available root privileges to a process. This effectively breaks up root privileges into smaller and distinctive units. Each of these units can then be independently be granted to processes. This way the full set of privileges is reduced and decreasing the risks of exploitation.
In plain English, this command says to find files in the / directory owned by the user root with SUID permission bits (-perm -4000), print them, and then redirect all errors (2 = stderr) to /dev/null (where they get thrown away). The reason for this redirect is that we aren't interested in things that we can't access, and access denied errors can fill up a terminal pretty fast.
Adding a binary to PATH, to hijack another SUID binary invokes it without the fully qualified path.
If you can get root to execute anything, the following will change a binary owner to him and set the SUID flag:
If a SUID binary allows you to write to a file, overwrite /etc/shadow with the following then su to root using password rowbot
ps -ef cat /etc/services dpkg -l rpm -qa
An example here is for instance that you see a local database like mysql is running. Maybe you are able to find credentials for it and log into it locally on the box
If MYSQL is running as root, you can run commands using sys_exec(). For instance, to add user to sudoers:
More about MYSQL:
Command to skip ignored lines in config files
Find Linux distribution & version
Check versions - use in conjunction with searchsploit
Find printers
List other users home directories
User mails
Find interesting binaries
If you can just change PATH, the following will add a poisoned ssh binary:
Compile using gcc -o <name> <filename.c>
Without interactive shell
If /etc/passwd has incorrect permissions, you can root:
or
Add user www-data to sudoers without password
If you can sudo chmod:
Wildcard injection if there is a cron with a wildcard in the command line, you can create a file, whose name will be passed as an argument to the cron task, For more info:
compile exploit fix error
Find other uses in the system
Find world-readable files:
Find nobody owned files
Add user to sudoers in python.
Ring0 kernel exploit for 2.3/2.4
Creates folder /tmp/rowbot
and copies files on kali web server to target
What is running, any cron jobs any scripts? Use PSPY to find out
Useful script to run for initial scan - displays info on box
Use this tool first to help you get in the PE mindset.
The following script runs exploit suggester and automatically downloads and executes suggested exploits:
automated kernel vulnerability enumeration and exploitation
Check kernel version
Then do a search for it on this page
Linux Kernel 2.6.39 - 3.2.2 (Gentoo / Ubuntu x86/x64) - 'Mempodipper' Local Privilege Escalation:
CVE-2012-0056
Linux Kernel 2.6.22 - 3.9 (x86/x64) - 'Dirty COW /proc/self/mem' Race Condition Privilege Escalation (SUID Method):
CVE-2016-5195
Linux Kernel 2.2.x/2.4.x (RedHat) - 'ptrace/kmod' Local Privilege Escalation
CVE-2003-0127
Linux Kernel 2.6 (Debian 4.0 / Ubuntu / Gentoo) UDEV below 1.4.1 - Local Privilege Escalation (1)
exploit/linux/local/udev_netlink
Other scripts:
Remember to run them again if you get a user shell not just www-data shell
Always be sure to read the comments in exploits they inform you about which systems and version are vulnerable, which parts of the script need modification & which compilation flags to use. $targetip 32 bit or 64 bit? Be mindful of this when compiling exploits.