Trustwave SpiderLabs Uncovers Unique Cybersecurity Risks in Today's Tech Landscape. Learn More

Trustwave SpiderLabs Uncovers Unique Cybersecurity Risks in Today's Tech Landscape. Learn More

Services
Capture
Managed Detection & Response

Eliminate active threats with 24/7 threat detection, investigation, and response.

twi-managed-portal-color
Co-Managed SOC (SIEM)

Maximize your SIEM investment, stop alert fatigue, and enhance your team with hybrid security operations support.

twi-briefcase-color-svg
Advisory & Diagnostics

Advance your cybersecurity program and get expert guidance where you need it most.

tw-laptop-data
Penetration Testing

Test your physical locations and IT infrastructure to shore up weaknesses before exploitation.

twi-database-color-svg
Database Security

Prevent unauthorized access and exceed compliance requirements.

twi-email-color-svg
Email Security

Stop email threats others miss and secure your organization against the #1 ransomware attack vector.

tw-officer
Digital Forensics & Incident Response

Prepare for the inevitable with 24/7 global breach response in-region and available on-site.

tw-network
Firewall & Technology Management

Mitigate risk of a cyberattack with 24/7 incident and health monitoring and the latest threat intelligence.

Solutions
BY TOPIC
Microsoft Exchange Server Attacks
Stay protected against emerging threats
Rapidly Secure New Environments
Security for rapid response situations
Securing the Cloud
Safely navigate and stay protected
Securing the IoT Landscape
Test, monitor and secure network objects
Why Trustwave
About Us
Awards and Accolades
Trustwave SpiderLabs Team
Trustwave Fusion Security Operations Platform
Trustwave Security Colony
Partners
Technology Alliance Partners
Key alliances who align and support our ecosystem of security offerings
Trustwave PartnerOne Program
Join forces with Trustwave to protect against the most advance cybersecurity threats
SpiderLabs Blog

Tutorial for NTDS goodness (VSSADMIN, WMIS, NTDS.dit, SYSTEM)

I recently performed an internal penetration test where the NTDS.dit file got me thousands of password hashes. After compromising unpatched Microsoft Windows computers on the client's domain, I gained access to a number of domain accounts. Below I'll explain how I did it.

The client had two domain controllers, one Windows 2003 and one Windows 2008. One of the domain accounts obtained via other means (not described by this post) had rights to log-on locally on both domain controllers.

I attempted to dump the Active Directory database, but I couldn't get the SAM file through my usual methods. Eventually, and after much effort, I got the SAM file but found it only contained one hash.

The following actions allowed me to obtain the Active Directory password hashes. This method will work on Windows 2003, Windows 2008 and Windows 2012 servers.

The NTDS.dit file is the Active Directory database. It stores all Active Directory information including password hashes.

I recreated the scenario, to demonstrate it on a Windows 2012 server.

12085_d8b41fd1-3126-4641-9c90-2367a884c357

There are various ways of accessing the NTDS.dit file. It can't just be copied when it is in use (similar to a SAM file).

A technology that is included in Microsoft Windows itself is the Volume Snapshot Service or Volume Shadow Copy Service. It requires the partition to run NTFS, and it is the same technology used to
create a Windows backup or automatic system restore point.

The command line utility I used was VSSADMIN.

The command determines whether there are current volume shadow copies that exist or if we need to create one:

8598_312142bf-4332-45e9-9224-5934365fb13a

As you can see, no shadow copy existed yet. So I created one.

The default path is c:\windows\ntds\ntds.dit. But it could be on any other drive, for example I found it on d:\NTDS\ntds.dit in my test.

10565_8facacfa-2649-4d5c-9e51-e3a8871cd3fe

I also created the SYSTEM file in path c:\windows\system32\.

10545_8eab23d1-d737-4661-a4b4-92cd8d3f6036

A shadow copy of the c: drive had been created.

10280_812e7b1a-c3c2-4481-9720-0efa4b866449

 

Next I copied the NTDS.dit file to a place where it could be retrieved on the main (non-shadowed) drive.

12889_fe52dc2d-73ec-41c7-aca9-faa2bf714831

Then I did the same with the SYSTEM file.

11612_c1a0a1a9-9004-4902-8b97-f62039194fd5

The two files were then copied to the root of the c: drive.

9208_4e5b2bef-0e40-4d43-952b-6a8609c2415c

I used Kali 1.0.5 as my attack platform.

9677_66828a88-9e9e-4be8-aef0-b2b0648d21f9

To use the mount command to mount to the default Windows share, I needed cifs-utils on Kali.

8899_407c11bd-d6ab-435b-a9d4-1b55b2d56198


Then I mounted the network share.

12793_f954559d-762a-48c2-834d-3ad069fb5417


Next I copied the two files to the attack system.

8633_32b6862f-5823-4851-a7a9-dd51e337128f

This can be done remotely without interactively logging-on to the server by using the "wmic" command from any Windows computer. Kali's WMIS package allowed me to do the same.

7842_0af69730-dba5-4836-8ae9-992453761bf8

Next, I ran the VSSADMIN command to list shadows remotely with WMIS.

8901_40865999-348a-4aec-b142-f0df95542062

Next I checked the output.txt file to see what happened.

10701_953eb075-6913-49c3-943d-08620255845e

Then I checked that the root was empty and deleted the previous NTDS.dit and SYSTEM files I copied.

7951_10207462-8b56-41a8-92aa-11fd6b489f8c

I copied the NTDS.dit file, using WMIS.

9579_613b58e6-937c-4c90-8cb3-35f8ed4ced39

Note that the shadow copy folder has three slashes ('\\\').

Next I copied the SYSTEM file using WMIS.

12185_de2251d1-8507-4cc9-bc8a-dc9b06001d21

Then I checked whether the files were copied on the previously mounted drive.

12134_db3c07bd-eee9-43ea-81e1-00347ef3a527

My next step was to get the password hashes.

First I needed to download and unzip ntdsxtract_v1_0.zip from http://www.ntdsxtract.com/.

12546_ee40581f-6cdf-4590-8af1-1ff1ff7b5ffe

9634_644c935b-ca27-42cb-bace-df77a6961654


Second, I needed to download and unzip ntds_dump_hash.zip from http://www.ntdsxtract.com/.

8188_1b68a598-46ba-45b9-8aea-914dec7f3462

12155_dc95a161-9dfa-45f8-83c2-beffe65464da


Then I compiled and made libesedb.

11693_c5b3043d-0c32-4200-a158-2098ea7ff066

12361_e71a7a5c-f022-4d06-a25e-5daba30f6b93

Here I exported tables from NTDS.dit, using the command esedbdumphash.

8215_1cdf5c92-82e3-42c4-94db-146e4beb3772

Other information could also be exported using esedbexport, but I was only interested in Table 4 where the password hashes are.

10758_9836f767-25ba-4d9a-be11-53bbb3f3d442

This took some time and resulted in the creation of a folder called ntds.dit.export containing a file called datatable.

12577_ef77bcf8-1092-4e3c-bb34-e369cec8797b

Then I went to the creddump folder to run the dsdump python script.

8374_260502e7-1889-4edc-8cdb-8671d6ee3612

7682_0360732f-cd1d-40a1-83f0-7d0e15d3ec80

From there, I could output the hashes into a file and use my favorite password-cracking tool to recover the passwords.

Enjoy!

Latest SpiderLabs Blogs

Zero Trust Essentials

This is Part 5 in my ongoing project to cover 30 cybersecurity topics in 30 weekly blog posts. The full series can be found here.

Read More

Why We Should Probably Stop Visually Verifying Checksums

Hello there! Thanks for stopping by. Let me get straight into it and start things off with what a checksum is to be inclusive of all audiences here, from Wikipedia [1]:

Read More

Agent Tesla's New Ride: The Rise of a Novel Loader

Malware loaders, critical for deploying malware, enable threat actors to deliver and execute malicious payloads, facilitating criminal activities like data theft and ransomware. Utilizing advanced...

Read More