homepage
Menu
Open menu
  • Training
    Go one level top Back

    Training

    • Courses

      Build cyber prowess with training from renowned experts

    • Hands-On Simulations

      Hands-on learning exercises keep you at the top of your cyber game

    • Certifications

      Demonstrate cybersecurity expertise with GIAC certifications

    • Ways to Train

      Multiple training options to best fit your schedule and preferred learning style

    • Training Events & Summits

      Expert-led training at locations around the world

    • Free Training Events

      Upcoming workshops, webinars and local events

    • Security Awareness

      Harden enterprise security with end-user and role-based training

    Featured: Solutions for Emerging Risks

    Discover tailored resources that translate emerging threats into actionable strategies

    Risk-Based Solutions

    Can't find what you are looking for?

    Let us help.
    Contact us
  • Learning Paths
    Go one level top Back

    Learning Paths

    • By Focus Area

      Chart your path to job-specific training courses

    • By NICE Framework

      Navigate cybersecurity training through NICE framework roles

    • DoDD 8140 Work Roles

      US DoD 8140 Directive Frameworks

    • By European Skills Framework

      Align your enterprise cyber skills with ECSF profiles

    • By Skills Roadmap

      Find the right training path based on critical skills

    • New to Cyber

      Give your cybersecurity career the right foundation for success

    • Leadership

      Training designed to help security leaders reduce organizational risk

    • Degree and Certificate Programs

      Gain the skills, certifications, and confidence to launch or advance your cybersecurity career.

    Featured

    New to Cyber resources

    Start your career
  • Community Resources
    Go one level top Back

    Community Resources

    Watch & Listen

    • Webinars
    • Live Streams
    • Podcasts

    Read

    • Blog
    • Newsletters
    • White Papers
    • Internet Storm Center

    Download

    • Open Source Tools
    • Posters & Cheat Sheets
    • Policy Templates
    • Summit Presentations
    • SANS Community Benefits

      Connect, learn, and share with other cybersecurity professionals

    • CISO Network

      Engage, challenge, and network with fellow CISOs in this exclusive community of security leaders

  • For Organizations
    Go one level top Back

    For Organizations

    Team Development

    • Why Partner with SANS
    • Group Purchasing
    • Skills & Talent Assessments
    • Private & Custom Training

    Leadership Development

    • Leadership Courses & Accreditation
    • Executive Cybersecurity Exercises
    • CISO Network

    Security Awareness

    • End-User Training
    • Phishing Simulation
    • Specialized Role-Based Training
    • Risk Assessments
    • Public Sector Partnerships

      Explore industry-specific programming and customized training solutions

    • Sponsorship Opportunities

      Sponsor a SANS event or research paper

    Interested in developing a training plan to fit your organization’s needs?

    We're here to help.
    Contact us
  • Talk with an expert
  • Log In
  • Join - it's free
  • Account
    • Account Dashboard
    • Log Out
  1. Home >
  2. Blog >
  3. De-mystifying Defrag: Identifying When Defrag Has Been Used for Anti-Forensics (Part 1 - Windows XP)
370x370_Chad-Tilbury.jpg
Chad Tilbury

De-mystifying Defrag: Identifying When Defrag Has Been Used for Anti-Forensics (Part 1 - Windows XP)

August 5, 2009

I have seen the following Windows Prefetch entries in nearly every Windows XP / Vista machine that I have reviewed over the past several years.Their existence always reminds me of the imperfect nature of information gained via individual artifacts.Does this mean that a user ran the Microsoft Defragmenter application on July 16, 2009 at 1:19PM?Or was the defragmenter started automatically by Windows?The defragmenter tool has been used very effectively as an anti-forensic tool since it was first introduced.In cases where data spoliation could be important, it is critical for the examiner to be able to identify any overt actions by a user.Complicating this is that starting with Windows XP, the operating system conducts limited defragmentation approximately every three days. [1] This post seeks to identify forensic artifacts which can help us determine if a user initiated the defrag application.

Figure_1
Figure 1: Defrag entries in C:\Windows\Prefetch directory

We will focus on two primary methods a user can invoke the Windows Defragmenter tool:

  1. Running defragmenter from a graphical user interface (GUI)
  2. Running defrag from the command line using defrag.exe

Defragmenter Artifacts in Windows XP — Identifying GUI Usage

The GUI defragmenter tool leaves a wealth of artifacts that can distinguish user execution of defrag from system execution.It is commonly accessed from the Start Menu -> Accessories -> System Tools menu.We will query the following artifacts to identify user actions:

  1. Prefetch Entries
  2. UserAssist Registry Key
  3. Registry MMC Recent File list
  4. File Access Timestamps

Prefetch Entries

The addition of Windows Prefetch in XP has provided investigators with an excellent artifact for identifying applications executed on a system.While it won't give us everything we need in this situation, it is an excellent starting point.Entries are located in the C:\Windows\Prefetch directory and can be parsed using Mark McKinnon's Prefetch Parser or your favorite forensic suite.

When the defragmenter is run using the GUI, only the dfrgntfs.exe entry is updated within the Prefetch directory (with an updated access time stamp and execution count).This immediately reveals that the artifacts shown in Figure 1 were not left by the GUI tool.It may also explain why we often see higher execution counts for dfrgntfs.exe than defrag.exe when parsing the Prefetch entries.As an aside, it is interesting to note that I found differences in how the execution count was updated.When using the GUI, the execution value for dfrgntfs.exe was incremented by one and when using the command line application, the counts were incremented by three.

Since the GUI version of the defragmenter is essentially a Microsoft Management Console (MMC) snap-in, an entry for MMC.exe is also created in the Prefetch folder.It is important to note that MMC.exe can be present in the Prefetch due to the use of other snap-ins (such as viewing the event logs).Its proximity to the dfrgntfs.exe entry is one clue, but Prefetch files can also show what was loaded by the application, and further investigation reveals that dfrgres.dll and dfrgui.dll are both loaded by MMC.exe whenever it facilitates the defragmenter snap-in.

Figure_2
Figure 2: Prefetch entries indicating the GUI defragmenter tool was run

UserAssist Registry Key

Prefetch can indicate that the GUI application was run, but it gives no information regarding user attribution.Luckily we have an artifact available in the NTUSER.dat hive file that does both.The UserAssist registry key, HKCU\Software\Microsoft\Windows\Currentversion\Explorer\UserAssist\{GUID}\Count, stores information on applications run per user.This is a terrific artifact for proving user activity and can be easily viewed using UserAssist.exe written by Didier Stevens.Evidence of manual execution can be found within this registry key when the defragmenter is accessed via the GUI interface.You should be looking for entries for "Disk Defragmenter.lnk" and "mmc.exe".The "Last" time indicates when the application was last run by the user.One unfortunate limitation of this artifact is that applications run from the command line are not recorded.

Figure_3
Figure 3: Using UserAssist.exe to parse the registry values

Registry MMC Recent File List

Since we know that the MMC is utilized by the defragmenter GUI, there is an additional registry artifact dedicated to recording MMC usage.Looking at HKCU\Software\Microsoft\Microsoft Management Console\Recent File List, we should see an entry for dfrg.msc, which is the Microsoft Common Console file for the defragmenter snap-in.If this is the last value recorded, the key last write time will indicate when the defragmenter was last run.Additionally, note that this registry key is under HKey_Current_User (NTUSER.dat hive), giving us another artifact for proving user attribution.

Figure_4
Figure 4: MMC Recent File List reviewed using regedit.exe

File Access Timestamps

Finally, we can tie everything together neatly by doing a timestamp analysis.The access timestamps for the following files indicate when these files were last run.Any mismatch with the times indicated in the Prefetch and UserAssist artifacts can tell us if there was any additional defrag activity after the GUI was run:

  • C:\Windows\System32\Dfrgntfs.exe
  • C:\Windows\System32\Dfrg.msc
  • C:\Documents and Settings\All Users\Start Menu\Programs\Accessories\SystemTools\Disk Defragmenter.lnk

Defragmenter Artifacts in Windows XP — Identifying Command Line Usage

In contrast to our investigation of artifacts generated by the GUI interface, command line use of the defrag tool gives us much fewer artifacts to work with.We will be required to focus on:

  1. Prefetch entries (including timestamps)
  2. Timeline analysis of contemporaneous events
  3. Layout.ini
Figure_5
Figure 5: Example of running defrag.exe from the XP command line

Prefetch Entries

Unlike the artifacts for the GUI defragmenter, the Prefetch artifacts left by command line execution of defrag.exe are the same as those left by the Windows automated process.Upon command line execution both defrag.exe and dfrgntfs.exe are created in the Prefetch directory.Further, their last access times are updated to the time the application was run.This tells us when the defrag tool was last run, but does not allow us to differentiate between system defrags and user generated activity.Therefore we will need to turn to timeline analysis.

Timeline Analysis

With very limited artifacts, old fashioned timeline analysis will likely be our best bet to identify user defrag activity.This is not a theoretical exercise.We have seen instances of the defrag tool used as an anti-forensics tool in recent intrusion cases.Often this plays out with the intruder installing their payload on the system, deleting it, and then running defrag.exe to prevent the malware from being recovered by incident responders.

Figure_6
Figure 6: Sorting Prefetch entries by last accessed time and reviewing nearby applications

In this situation we will often be looking for the opening of a command shell (cmd.exe) near the time that defrag.exe was run.This is a key differentiator since Windows does not require an interactive command shell when kicking off automated processes.Figure 6 shows how this might look in the Prefetch directory.In addition to just Prefetch entries, other timeline entries like created and deleted files can provide further context.Admittedly, this evidence is very temporal and presumes that collection occurs as close a possible to the time the intrusion occurred.

Layout.ini

The layout.ini file is located in the C:\Windows\Prefetch directory and is used by the Prefetch process to more efficiently place system and frequently used applications during the limited defrag sequence.It is not used during a standard manual defragmentation.Therefore it can be a good indicator for distinguishing between user and system actions.In the example shown in Figure 7, the modification time of the layout.ini coincides with the defrag applications and indicates that they were run by the operating system (not the user).

A Note Regarding Event Logs

In Windows XP, there is no native capability to record defragmenter usage in the event logs.[2]Thus we will not be able to leverage this source of information as we could for other actions like task scheduler usage.

Conclusion

We stand our best chance of tying defragmenter execution to a user account if it was conducted via the GUI interface.Many of our most valuable Windows artifacts are not updated when an application is run from the command line.However, we will often be able to turn to old-fashioned timeline analysis to assist in these circumstances.

It should be noted that there are plenty of legitimate reasons for running the defragmenter tool.Other contemporaneous actions need to be reviewed to assess a user's true intent.

The Vista operating system changes many of the artifacts covered in this post.Part 2 will cover performing this analysis on a Vista system.

References

  1. http://msdn.microsoft.com/en-us/magazine/cc302206.aspx
  2. http://support.microsoft.com/kb/294743

Chad Tilbury, GCFA, has spent over ten years conducting computer crime investigations ranging from hacking to espionage to multi-million dollar fraud cases. He teaches FOR408 Windows Forensics and FOR508 Advanced Computer Forensic Analysis and Incident Response for the SANS Institute. Find him on Twitter @chadtilbury or at http://ForensicMethods.com.

Share:
TwitterLinkedInFacebook
Copy url Url was copied to clipboard
Subscribe to SANS Newsletters
Receive curated news, vulnerabilities, & security awareness tips
United States
Canada
United Kingdom
Spain
Belgium
Denmark
Norway
Netherlands
Australia
India
Japan
Singapore
Afghanistan
Aland Islands
Albania
Algeria
American Samoa
Andorra
Angola
Anguilla
Antarctica
Antigua and Barbuda
Argentina
Armenia
Aruba
Austria
Azerbaijan
Bahamas
Bahrain
Bangladesh
Barbados
Belarus
Belize
Benin
Bermuda
Bhutan
Bolivia
Bonaire, Sint Eustatius, and Saba
Bosnia And Herzegovina
Botswana
Bouvet Island
Brazil
British Indian Ocean Territory
Brunei Darussalam
Bulgaria
Burkina Faso
Burundi
Cambodia
Cameroon
Cape Verde
Cayman Islands
Central African Republic
Chad
Chile
China
Christmas Island
Cocos (Keeling) Islands
Colombia
Comoros
Cook Islands
Costa Rica
Cote D'ivoire
Croatia (Local Name: Hrvatska)
Curacao
Cyprus
Czech Republic
Democratic Republic of the Congo
Djibouti
Dominica
Dominican Republic
East Timor
Ecuador
Egypt
El Salvador
Equatorial Guinea
Eritrea
Estonia
Eswatini
Ethiopia
Falkland Islands (Malvinas)
Faroe Islands
Fiji
Finland
France
French Guiana
French Polynesia
French Southern Territories
Gabon
Gambia
Georgia
Germany
Ghana
Gibraltar
Greece
Greenland
Grenada
Guadeloupe
Guam
Guatemala
Guernsey
Guinea
Guinea-Bissau
Guyana
Haiti
Heard And McDonald Islands
Honduras
Hong Kong
Hungary
Iceland
Indonesia
Iraq
Ireland
Isle of Man
Israel
Italy
Jamaica
Jersey
Jordan
Kazakhstan
Kenya
Kiribati
Korea, Republic Of
Kosovo
Kuwait
Kyrgyzstan
Lao People's Democratic Republic
Latvia
Lebanon
Lesotho
Liberia
Liechtenstein
Lithuania
Luxembourg
Macau
Madagascar
Malawi
Malaysia
Maldives
Mali
Malta
Marshall Islands
Martinique
Mauritania
Mauritius
Mayotte
Mexico
Micronesia, Federated States Of
Moldova, Republic Of
Monaco
Mongolia
Montenegro
Montserrat
Morocco
Mozambique
Myanmar
Namibia
Nauru
Nepal
Netherlands Antilles
New Caledonia
New Zealand
Nicaragua
Niger
Nigeria
Niue
Norfolk Island
North Macedonia
Northern Mariana Islands
Oman
Pakistan
Palau
Palestine
Panama
Papua New Guinea
Paraguay
Peru
Philippines
Pitcairn
Poland
Portugal
Puerto Rico
Qatar
Reunion
Romania
Russian Federation
Rwanda
Saint Bartholemy
Saint Kitts And Nevis
Saint Lucia
Saint Martin
Saint Vincent And The Grenadines
Samoa
San Marino
Sao Tome And Principe
Saudi Arabia
Senegal
Serbia
Seychelles
Sierra Leone
Sint Maarten
Slovakia
Slovenia
Solomon Islands
South Africa
South Georgia and the South Sandwich Islands
South Sudan
Sri Lanka
St. Helena
St. Pierre And Miquelon
Suriname
Svalbard And Jan Mayen Islands
Sweden
Switzerland
Taiwan
Tajikistan
Tanzania, United Republic Of
Thailand
Togo
Tokelau
Tonga
Trinidad And Tobago
Tunisia
Turkey
Turkmenistan
Turks And Caicos Islands
Tuvalu
Uganda
Ukraine
United Arab Emirates
United States Minor Outlying Islands
Uruguay
Uzbekistan
Vanuatu
Vatican City State
Venezuela
Vietnam
Virgin Islands (British)
Virgin Islands (U.S.)
Wallis And Futuna Islands
Western Sahara
Yemen
Zambia
Zimbabwe

By providing this information, you agree to the processing of your personal data by SANS as described in our Privacy Policy.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Tags:
  • Digital Forensics, Incident Response & Threat Hunting

Related Content

Blog
Blog Teaser: Shoplifting2.0 340x340.jpg
Digital Forensics, Incident Response & Threat Hunting
May 21, 2025
Shoplifting 2.0: When it’s Data the Thieves Steal
Identify steps organisations can implement to protect against Scattered Spider and DragonForce
Adam Harrison
Adam Harrison
read more
Blog
emerging threats summit 340x340.png
Digital Forensics, Incident Response & Threat Hunting, Offensive Operations, Pen Testing, and Red Teaming, Cyber Defense, Industrial Control Systems Security, Cybersecurity Leadership
May 14, 2025
Visual Summary of SANS Emerging Threats Summit 2025
Check out these graphic recordings created in real-time throughout the event for SANS Emerging Threats Summit 2025
No Headshot Available
Alison Kim
read more
Blog
powershell_option_340x340.jpg
Cyber Defense, Digital Forensics, Incident Response & Threat Hunting, Cybersecurity and IT Essentials, Offensive Operations, Pen Testing, and Red Teaming
July 12, 2022
Month of PowerShell - Windows File Server Enumeration
In this Month of PowerShell article we look at several commands to interrogate Windows SMB servers as part of our incident response toolkit.
Josh Wright - Headshot - 370x370 2025.jpg
Joshua Wright
read more
  • Company
  • Mission
  • Instructors
  • About
  • FAQ
  • Press
  • Contact Us
  • Careers
  • Policies
  • Training Programs
  • Work Study
  • Academies & Scholarships
  • Public Sector Partnerships
  • Law Enforcement
  • SkillsFuture Singapore
  • Degree Programs
  • Get Involved
  • Join the Community
  • Become an Instructor
  • Become a Sponsor
  • Speak at a Summit
  • Join the CISO Network
  • Award Programs
  • Partner Portal
Subscribe to SANS Newsletters
Receive curated news, vulnerabilities, & security awareness tips
United States
Canada
United Kingdom
Spain
Belgium
Denmark
Norway
Netherlands
Australia
India
Japan
Singapore
Afghanistan
Aland Islands
Albania
Algeria
American Samoa
Andorra
Angola
Anguilla
Antarctica
Antigua and Barbuda
Argentina
Armenia
Aruba
Austria
Azerbaijan
Bahamas
Bahrain
Bangladesh
Barbados
Belarus
Belize
Benin
Bermuda
Bhutan
Bolivia
Bonaire, Sint Eustatius, and Saba
Bosnia And Herzegovina
Botswana
Bouvet Island
Brazil
British Indian Ocean Territory
Brunei Darussalam
Bulgaria
Burkina Faso
Burundi
Cambodia
Cameroon
Cape Verde
Cayman Islands
Central African Republic
Chad
Chile
China
Christmas Island
Cocos (Keeling) Islands
Colombia
Comoros
Cook Islands
Costa Rica
Cote D'ivoire
Croatia (Local Name: Hrvatska)
Curacao
Cyprus
Czech Republic
Democratic Republic of the Congo
Djibouti
Dominica
Dominican Republic
East Timor
Ecuador
Egypt
El Salvador
Equatorial Guinea
Eritrea
Estonia
Eswatini
Ethiopia
Falkland Islands (Malvinas)
Faroe Islands
Fiji
Finland
France
French Guiana
French Polynesia
French Southern Territories
Gabon
Gambia
Georgia
Germany
Ghana
Gibraltar
Greece
Greenland
Grenada
Guadeloupe
Guam
Guatemala
Guernsey
Guinea
Guinea-Bissau
Guyana
Haiti
Heard And McDonald Islands
Honduras
Hong Kong
Hungary
Iceland
Indonesia
Iraq
Ireland
Isle of Man
Israel
Italy
Jamaica
Jersey
Jordan
Kazakhstan
Kenya
Kiribati
Korea, Republic Of
Kosovo
Kuwait
Kyrgyzstan
Lao People's Democratic Republic
Latvia
Lebanon
Lesotho
Liberia
Liechtenstein
Lithuania
Luxembourg
Macau
Madagascar
Malawi
Malaysia
Maldives
Mali
Malta
Marshall Islands
Martinique
Mauritania
Mauritius
Mayotte
Mexico
Micronesia, Federated States Of
Moldova, Republic Of
Monaco
Mongolia
Montenegro
Montserrat
Morocco
Mozambique
Myanmar
Namibia
Nauru
Nepal
Netherlands Antilles
New Caledonia
New Zealand
Nicaragua
Niger
Nigeria
Niue
Norfolk Island
North Macedonia
Northern Mariana Islands
Oman
Pakistan
Palau
Palestine
Panama
Papua New Guinea
Paraguay
Peru
Philippines
Pitcairn
Poland
Portugal
Puerto Rico
Qatar
Reunion
Romania
Russian Federation
Rwanda
Saint Bartholemy
Saint Kitts And Nevis
Saint Lucia
Saint Martin
Saint Vincent And The Grenadines
Samoa
San Marino
Sao Tome And Principe
Saudi Arabia
Senegal
Serbia
Seychelles
Sierra Leone
Sint Maarten
Slovakia
Slovenia
Solomon Islands
South Africa
South Georgia and the South Sandwich Islands
South Sudan
Sri Lanka
St. Helena
St. Pierre And Miquelon
Suriname
Svalbard And Jan Mayen Islands
Sweden
Switzerland
Taiwan
Tajikistan
Tanzania, United Republic Of
Thailand
Togo
Tokelau
Tonga
Trinidad And Tobago
Tunisia
Turkey
Turkmenistan
Turks And Caicos Islands
Tuvalu
Uganda
Ukraine
United Arab Emirates
United States Minor Outlying Islands
Uruguay
Uzbekistan
Vanuatu
Vatican City State
Venezuela
Vietnam
Virgin Islands (British)
Virgin Islands (U.S.)
Wallis And Futuna Islands
Western Sahara
Yemen
Zambia
Zimbabwe

By providing this information, you agree to the processing of your personal data by SANS as described in our Privacy Policy.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
  • Privacy Policy
  • Terms and Conditions
  • Do Not Sell/Share My Personal Information
  • Contact
  • Careers
© 2025 The Escal Institute of Advanced Technologies, Inc. d/b/a SANS Institute. Our Terms and Conditions detail our trademark and copyright rights. Any unauthorized use is expressly prohibited.
  • Twitter
  • Facebook
  • Youtube
  • LinkedIn