Privilege Escalation
General Privilege Escalation
Gather System information
Windows:
Linux:
Stability of shell
For example, when you have a Meterpreter session, sometime it can be killed easily (e.g. browser). In this case, you have to migrate the Meterpreter session to another process. Meterpreter has a function to do this automatically:
Or manually:
Windows Privilege Escalation
getsystem
For Windows with Meterpreter, the easiest way is of course getsystem
.
However, if you are not admin, getsystem
will probably fail. To check current privilege:
Bypass UAC
If win_privs
shows UAC enabled, we may use some modules in Metasploit. For example, search for bypassuac:
Also, there is a tool UACME:
After compiling executables, we can use the upload function in Meterpreter to upload Akagi and ReverseShell Payload (msfvenom). After that, create a multi handler referencing to the msfvenom payload. Then execute:
Meterpreter Incognito Extension
Incognito is used to impersonate other valid user tokens on that machine.
In Meterpreter shell:
To check available tokens:
To impersonate:
Unquoted Service Paths
Abuse the way that Windows searches for executables belonging to a service.
For example, in the above case, we can put an executable to one of the following locations and the service will use this executable!
C:\Program.exe
C:\Program Files (x86)\Canon\IJ.exe
To check if the system has unquoted services, in Windows cmd:
Or use sc
to query a specific service
Or Metasploit exploit ...
An other problem is that we may not have the permission to upload a file to the folder. To check:
Again another problem is that the session could be unstable. A trick is to migrate to another process when handler gets a callback!
HackTricks Check List
Find phrases in files
Find a phrase in the files in the current directory
Payload All THE THING
Linux Privilege Escalation
Abusable Unix Binaries
Generally speaking you have to do it manually. A baseline is at least do a system info recon - for example in Meterpreter:
Compile known exploits
Research ... on Google ... Exploit-DB ...
Generally we have to use gcc to compile the exploit:
For 32-bit system:
openssl
Check the capability of openssl:
If you can find -ep
capabilities, you have the root permission to read/write!
To read:
To add ourselves with sudo privilege, first:
Then:
Linux Privilege Escalation by g0tmi1k
Source:
Environment vars
Plaintext usernames/passwords?
Are there any passwords in; scripts, databases, configuration files or log files? Default paths and locations for passwords
Private keys?
Config files can be written?
Unmounted system?
Sticky bits, SUID / GUID?
Where can written to and executed from? A few 'common' places: /tmp, /var/tmp, /dev/shm
Any "problem" files? Word-writeable, "nobody" files
Payload All The Things
Cronjob Detect
Last updated