How To Find Mft Entry Attributes

Posted by admin

This past week I was reading a paper about the ZeroAccess Trojan when a section about a clever data hiding technique caught my eye. The paper was Sophos’s and I’m referring to the Services.exe section which stated (on page 6):'If installed on Windows Vista or higher ZeroAccess will attempt to patch the Windows file services.exe. A subroutine inside services.exe is overwritten with shellcode that is carried inside the ZeroAccess dropper.A large amount of binary data is also written to the NTFS Extended Attributes of services.exe. Extended Attributes are a feature of NTFS similar in nature to Alternate Data Streams where extra information about the file can be stored on the file system. ZeroAccess uses this feature to hide a whole PE file as well as shellcode that loads the PE file. The overwritten subroutine in services.exe reads in all the data from the Extended Attributes and executes it.

The shellcode then loads and executes the embedded PE file. This file is a DLL that has equivalent functionality to the main component, so the services.exe modifications provide a backup means for the bot to function if the two main components are discovered and removed.' I was already fascinated about the Trojan’s use of two separate DLLs to maintain persistence but what I read opened my eyes. ZeroAccess leveraged a third DLL for persistence that was hidden inside the NTFS Extended Attributes. A Google search lead me to a third article by Symantec -. I then remembered a few months back someone from the posted the write-up – which also discussed ZeroAccess hiding data inside NTFS Extended Attribute.

  • The MFT resides at the root of the Windows volume. Master File Table Structure. Each file on the volume has an entry contained within the MFT. Each MFT entry is made up of a header and several attributes. Here is the complete list of all the attributes found in MFT entries as described by Microsoft’s MSDN site.
  • Filename attributes are a structure of NTFS that contain forensically relevant metadata. Investigators should use filename attribute timestamps to augment their timelines and identify anomalies.

At the time, I read the HitmanPro article and bookmarked it amongst my malware references but I didn’t give it too much thought. Now my eyes are open and the use of the NTFS Extended Attribute had my full attention. A few thoughts were running through my head (yes in this order)1.

Table of contents of identifiers (MFT entry or file record) Recognized as a file itself Contains one or more attributes each proceeded by its own header Unused space = slack.

This is a really cool technique2. The articles don’t mention how to extract the data from the Extended Attribute.

I wonder how you can do it.3. Hiding data in the Extended Attribute is brilliant since antivirus software might not check there. Come to think about it most digital forensic tools don’t parse the data inside Extended Attributes either.4. Wait a second; I never look at the NTFS Extended Attributes during my examinations. I need to come up with a way to do it and add it to my examination process. It could be a check underneath my.5.

Alight, this is definitely cool.In this post I’m providing answers to all the questions that were racing through my mind. The post is broken up into the sections:- What Are NTFS Extended Attributes- My Testing Environment- Extracting Data from NTFS Extended Attributes- Extracting ZeroAccess from NTFS Extended Attributes- Locating Other ZeroAccess Files on SystemWhat Are NTFS Extended AttributesThe NTFS filesystem is the default for the Microsoft Windows server operating systems as well as Windows 2000, XP, Vista, and 7. The Master File Table ($MFT) is the component in NTFS containing information about all the files and folders on the volume. “.” The entry basically consists of a header and attributes.

Two attributes are the $EA index and $EAINFORMATION which are the NTFS Extended Attributes.The File System Forensic Analysis book shows the $EAINFORMATION type identifier as 208 and $EA identifier as 224 (credit goes to Harlan for this reference). The book further stated both attributes are “used for backward compatibility with OS/2 applications (HPFS).” In addition, the book stated “extended attributes are name/value pairs and aren’t normally used but are provided for backward compatibility with OS/2 applications”. The references provide a little more clarity about what the author of ZeroAccess is doing. They are using hardly used $MFT attributes meant for backward compatibility as a place to hide data. The cool factor with this technique went up a few notches.Testing EnvironmentBefore diving into the answers to all my questions I wanted to provide information about my testing environment.

Knowing the testing environment makes it easier for others to see exactly what I did and how to replicate my testing. For those looking for the “good stuff” skip ahead to the section Extracting Data from NTFS Extended Attributes.Finding the ZeroAccess SampleIn all the articles about ZeroAccess using the NTFS Extended Attributes I noticed one commonality; this technique was used in an updated version of the Trojan. Check out the commonality: HitmanPro posted their write up on June 25, 2012, Symantec did theirs on August 14, 2012, and Sophos report was released in September 2012. Furthermore, Sophos stated in their opening sentence “since our last paper on ZeroAccess, The ZeroAccess Rootkit, its authors have made significant changes.” The point was crystal clear, I needed to find a recent ZeroAccess sample in order to find one leveraging the $EA hiding technique.I searched for samples in the as you will see why shortly. A generic search for “zeroaccess” wasn’t to helpful since it resulted in 6,056 results. I needed a more focused search so I turned to Symantec’s detection. It reduced my search results to 9 samples.A nice feature about Virus-Share is it provides links to each sample’s VirusTotal’s report.

I used the VT report to further narrow down my samples. On VirusTotal’s Additional Information section, I first looked to see when each sample was first seen. I narrowed my samples down to five based on the above checks. Not every ZeroAccess Trojan will modify the services.exe and store binary data in the NTFS Extended Attribute. So I started executing one sample after another to see if any modified the services.exe MFT record. I didn’t do any dynamic analysis; I pretty much just ran a sample and then looked at the services.exe MFT record to see if the Extended Attributes were added.

How to find mft entry attributes free

On the third sample I hit pay dirt. The leveraged the NTFS Extended Attributes.Side note: I mentioned in the Win4n6 group I was looking for ZeroAccess samples that used the NTFS Extended Attributes.

Stefan replied with not only the MD5 hash c6e7a41da8bef0db342400 but links to the article and the. This sample is the next one I’m going to check out.Configuring my Test SystemThe Sophos report indicated the services.exe is only patched if ZeroAccess is installed on a system with Windows Vista or higher.

I selected for my test system Windows 7 Ultimate 32 bit which I was running inside VMware. I used a fresh install and the only configuration change I made was to disable the User Account Control. I wanted to avoid making ZeroAccess elevate its privileges. I also installed the program as a quick way to see changes made to the file system.Extracting Data from NTFS Extended AttributesI had to answer my first question before I could go forward with any testing. How do I extract the binary data from the NTFS Extended Attributes?

I reached out to the Win4n6 group for suggestions and pointed me to the promise land. He suggested I used the; specifically istat to see what attributes a MFT record has and icat to dump the data in an attribute. The process needed to extract data stored inside NTFS Extended Attributes with TSK is as follows:Note: the TSK tools can be ran against a forensic image or a mounted drive. My examples throughout the post are against a mounted drive (.PHYSICALDRIVE#) but the path to a forensic image could be used instead.1. Identify the starting sector of the partition where services.exe is located. Typically, the first sector for Vista and 7 is 2048 (XP is 63). The TSK tool to use is mmls and the command is.PHYSICALDRIVE#2.

Identify the inode number for the C:WindowsSystem32services.exe file. The TSK tool to use is ifind and the command is:-o 2048 -n 'Windows/System32/services.exe'.PHYSICALDRIVE#Command explanation: the –o switch is to specify the sector offset that was discovered with mmls and the –n switch is the file name to get the inode for.3. Review the attributes associated with the MFT record for C:WindowsSystem32services.exe. The TSK tool to use is istat and the command is:-o 2048.PHYSICALDRIVE3 12345Command explanation: the –o switch is the sector offset and the 12345 is the place where the inode number goes. The attributes of interest are $EAINFORMATION (208) and $EA (224).4. If present, make note of the NTFS Extended Attributes. In istat’s output, next to the attribute name will be a value inside parentheses.

The value in my test appeared as $EA (224-4)5. Dump the contents from the $EA and $EAINFORMATION and redirect it to a file. The TSK tool to use is icat and the commands are:-o 2048.PHYSICALDRIVE# 12345-208-#  EAINFO.txt-o 2048.PHYSICALDRIVE# 12345-224-#  EA.txtCommand explanation: the –o switch is the sector offset and the number at the end is the inode number with the attribute value added. The 208-# dumps $EAINFORMATION and 224-# dumps $EA.The above process can be used to either read a MFT’s record attributes or dump the data stored in those attributes.Extracting ZeroAccess from NTFS Extended AttributesTo completely answer my first question about how to extract the ZeroAccess Trojan from NTFS Extended Attributes I actually had to do it.

This is what I ended up doing:- Determined what a clean MFT services record looks like- Located an infected MFT services record- Extracted ZeroAccess from the MFT services record- Created the ZeroAccess binaryWhat Does a Clean MFT Services.exe Record Look like?It’s always good to know what normal looks like so it’s easier to see what is abnormal. This was my thinking and why I first looked at a clean MFT services.exe record. Here’s what I did and what it looked like. I highlighted in blue values of interest.1.

Confirmed the starting sector for the partition.mmls.PHYSICALDRIVE2DOS Partition TableOffset Sector: 0Units are in 512-byte sectorsSlot Start End Length Description00: Meta Primary Table (#0)01: - Unallocated02: 09967424 NTFS (0x07)03: - Unallocated2. Identified the inode number for the C:WindowsSystem32services.exe file.ifind -o 2048 -n 'Windows/System32/services.exe'.PHYSICALDRIVE2192113.

Reviewed the attributes associated with the C:WindowsSystem32services.exe MFT record. I located the MZ signature at offset 1684 so I copied out the binary data from offset 1684 to the end of the file. The resulting file was SHA256 ee14dcd20b2ee118618e3a28db72cce92ccd9e85dd8410e02479d9d624934b13 which was.Locating Other ZeroAccess Files on SystemLocating the infected services.exe file and extracting the binary data from the NTFS Extended Attributes only addresses one part of the infection. ZeroAccess drops other files on a system and I wanted to find these as well. However, I didn’t want to cheat by looking at my Capture.bat log file.

I wanted to verify how a system timeline worked by using the services.exe as a starting point to find the other malicious files.Timelines are my go to tool when I’m trying find files associated with an infection. A timeline can reveal other activity occurring on a system around a certain time of interest. In this case, I was interested in seeing the activity around the time when the services.exe file was last modified as shown below. (the timeline was created with ).

The timeline showed the services.exe file was modified on 12/06/12 at 18:05:09. The activity beforehand included the creation of files and folders in both the C:WindowsInstaller and C:UsersLabAppDataLocal folders. The file named n in both locations is the ZeroAcess Trojan.SummaryStoring data inside the NTFS Extended Attributes is a clever way to hide data.

Based on the reports I read, ZeroAccess started to use this technique within the last year. So far it appears as if this is not a commonly used technique to hide data among malware. The only reports I could find only talked about ZeroAccess. However, in time I would not be surprised to see other malware families trying to use NTFS Extended Attributes. To see why just think about these two questions: how many tools are checking the NTFS Extended Attributes for every file and how many DFIR practitioners and IT staff are actually aware that malware can be hidden there? If I was a betting man I’d put my money on both answers being “very few”. My eyes are opened to this hiding technique and I added a check underneath my Malware Searches examination step to account for it.

If I ever need to determine if something is leveraging NTFS Extended Attributes then this is the process I will use.1. Parse the MFT so that NTFS Extended Attributes are shown for every file.

One tool to use is AnalyzeMFT with the commandanalyzeMFT.py -f $MFT -o parsedmft.txtImport analyzeMFT’s output into Excel or Calc (output is comma delimited format). Apply a sort on the $EA attribute being true to show every file with a NTFS Extended Attribute. Locate the files’ of interest MFT records. AnalyzeMFT’s output contains this information.3. Identify the partition’s starting sector. One tool to use is TSK’s mmls with the command:mmls.PHYSICALDRIVE#4.

Review the attributes associated with any files of interest. One tool to use is TSK’s istat with the commandistat -o 2048.PHYSICALDRIVE3 123455. Make note of the NTFS Extended Attributes $EAINFORMATION and $EA. In istat’s output, next to the attribute name will be a value inside parentheses.6. Dump the data from the $EA and $EAINFORMATION for closer inspection. Use TSK’s icat with the commands:icat -o 2048.PHYSICALDRIVE# 12345-208-#  EAINFO.txticat -o 2048.PHYSICALDRIVE# 12345-224-#  EA.txtHappy Hunting. The Sophos report I linked to.Ah, yes, so it does.thanks.So, it overwrites an existing value within the Registry.which means it can be searched for.

After all, how many values beneath CLSID do you think start with '.globalroot.' Instead of '%systemroot%?' I like this statement:'If either of these two main components are discovered and removed, the other will independently assume control and carry out the bot activities.'

What Is The Mft Number Of The $mft File?

How many times do you see redundancy?The services.exe should load on system start.True.Thanks. Corey,Thanks for sharing the MFT from the system you infected.There are some very interesting findings, particularly with respect to the time stamps of the files and folders in question.First, looking at the infected services.exe file, we can clearly see the effect of file system tunneling. That's pretty cool.Something else that jumped out at me is that your timeline for locating the other ZeroAccess files is based on the time stamps from the $FILENAME attributes.the time stamps in the $STANDARDINFORMATION attributes suggest that there is some timestomping going on.