Pen Testing Windows Active Directory
Pen Testing Windows Active Directory
I am sure there are more than one ways of performing a penetration test on windows active
directory. In this article, I am listing some of the tricks that I would generally use when I will
encounter a windows domain.
The aim of performing a pen test on windows active directory could vary, however, I believe gaining
administrative level privileges on the “Domain Controller” is the ultimate challenge for a pen tester.
Here are some scenarios you may encounter:-
Case 1: You are allowed to plug your laptop to the internal network and all you have been
given is the target range:
This is the most common scenario. I would usually proceed in the following manner:
PS: Make sure that this account is removed after the test is over.
Now you will see a new section called abel which will have a sub section to dump all users and
another subsection to dump the hashes. After you dump the hashes, send them to the inbuilt cain
cracker and start cracking. Also it’s worth mentioning about ‘fgdump’ which can be used for similar
purposes. It's a modern tool that can evade AV and avoid crashing fully patched systems.
Question: How do I find out if the box I owned is a part of domain or not?
Answer: the following the command will tell you the domain name as well as the domain
controller as well as the groups present on the domain:
You can also get a list of all the ‘domain users’ with this command’
Net users /doman
If the same password does not work on the domain controller, things to try are:
You can obtain the domain users either by issuing a “net users /domain” command on
the box you owned or you obtain this information through nessus provided the null
1
session settings are enabled on any of the test boxes. As you already have the list of
domain users now, identify the domain admin accounts and try to crack the passwords
for these accounts against services like smb, rdp etc. If you succeed, you can go home
early. Tools to use THCHydra, ntenum3.3, tsgrinder
It could be possible that the box which you owned in step 2 could have been used by a
domain admin to log into some service, so try cache dump and also dumping the LSA
secrets to gain all the passwords you could possibly gain. A cached domain admin
password will again imply game over. I would quote someone here, "lsadump is a really
important thing to try. It gives the clear text passwords for all service accounts. Some of
which might be of ‘domain admins’. Not so common on 2k3 networks, but common
enough."
Of course, you will be running nessus against all the boxes including the domain
controller and you will have the list of vulnerabilities against every box. Try exploiting the
domain controller directly using metasploit modules. One of the things which has a very
1 Nullsession can give out a vast amount of information to an attacker. The recommended registry
settings to disable a null session and the related security issues in windows 2003 server are :
Hive: HKEY_LOCAL_MACHINE
Key: SYSTEM\CURRENTCONTROLSET\CONTROL\LSA
Name: RestrictAnonymoussam-1
Name: EveryoneIncludesAnonymous-0
high probability to succeed is the ms07-029 issue which exploits a flaw in the MS DNS
RPC interface. This service is enabled by default on the ‘Domain Controllers’.
Case2: You are not allowed to plug your laptop to the target network. You have been given
access to a workstation and a standard domain account.
Things to try:
Search milw0rm for local windows exploit against that particular OS and the service
pack, and try to gain local ‘system’ level access on the workstation and repeat the
processes 1-6 mentioned above.
Try to gain access to command prompt. It is a common practise to not allow access
to cmd.exe. However, in most of the cases it is not very difficult to break this
protection. After you have access to cmd.exe run the net users and the net
localgroup command to identify the admin domain users and try cracking a domain
admin password against services like smb, rdp etc. However, this may/may not work
as you will not have admin access to run these tools.
If the BIOS password is not enabled, you make the workstation book from the CD
released by eeye sysrq2 to gain system level privileges on the workstation and then
repeat process 1-7.
Hopefully, you know now something about pen testing an active directory.
Tools /References:-
• TSgrinder
• THChydra
• Cain (www.oxid.it )
• Cachedump
• Fgdump
• Pwdump
• Nltest
• Lservers
• SYSrq2 (http://research.eeye.com/html/tools/RT20060801-8.html )
• NBtscan