Incident Response - Filesystem Timeline Generation
There is no doubt that a well-generated and well-analysed timeline of events is key to understanding any intrusion. Building a timeline is a key skill for anyone working in Digital Forensics or Incident Response (DFIR).
The most basic method (and the one we all used to rely on until fairly recently) was for the investigator to copy/paste timestamps into a spreadsheet and then add some text explaining what happened. This definitely works well, but is the opposite of fast or efficient.
Speed and efficiency are so crucial in DFIR that you need to use tooling to generate timelines today. The difference is pretty stark. Instead of spending 2-3 hours to create a manual timeline, you can generate a filesystem timeline in a few minutes at most.
In this post, I will look at some of the common command line tools used to generate timelines. There are, as with most things, lots of other choices, but these tools are an excellent starting point. The main thing to remember is that your choice of tool is likely to be constrained by the filesystem you are analysing!
Note: Throughout this, I am going to assume you are analysing the output as a CSV and opening it in a tool such as Timeline Explorer. I will also assume you can install any tools you need.
Windows - NTFS Timelines
Using MFTECmd.exe and TSK
This is probably the best, and fastest, approach for NTFS timelines.
Requirements
Workflow
First, run mftecmd.exe against the $MFT to generate a "bodyfile". An example of the command line for this is: (assuming the evidence is the MFT for the C:\ drive of a target system)
MFTECmd.exe -f "\path\to\$MFT" --body "\path\to\outputfolder" --bodyf filename.body --blf --bdl C:
In use, it will look something like this:
This will produce a "body" file timeline. Bodyfiles are a machine-readable timeline. We can use this as our "final" timeline but it isn't always the easiest thing to read - for example, the entries look like this:
To make life easier, we can convert this to a human-readable CSV document with the mactime command from The Sleuth Kit. The syntax is
mactime -z UTC -y -d -b /path/to/bodyfile STARTDATE..ENDDATE > /path/to/output/filesystem-timeline.csv
The arguments used here are:
In use, the output will look something like this.
Now you have a CSV version of the timeline, you can easily open it in Timeline Explorer and analyse away!
An alternative approach - The Sleuthkit Only
This actually takes about the same time to generate, however, it does require you to have a full disk image (E01, RAW, AFF). Collecting this can take a lot longer than a Triage collection of the $MFT.
Requirements
Workflow
The main change is that instead of using mftecmd.exe, you use fls to create the timeline. The command would be something similar to: (this example assumes you are running it from a Linux investigation system)
fls -r -m C: /path/to/evidence > /path/to/bodyfile
(note: there is a space between the drive letter - C: here - and the start of the path)
Once you have built the bodyfile, you convert it into a human-readable (normally CSV) format with mactime as shown above.
Linux Filesystems.
Generating timelines from Linux evidence is a little bit more complicated, and this is really because there isn't really an equivalent for the $MFT. Most of the time, this means we need to run it against a live system or a full disk image, rather than having the relative ease of using a triage collection or just capturing the $MFT via EDR.
Another important consideration is that there are always limitations in the tools we use, and different filesystems lead to different issues. Some key considerations include:
With that out of the way, the approaches we will consider are: Using The Sleuth Kit and using a triage collection tool called UAC. The second option (UAC), gives us an effective way to build timelines on XFS, Btrfs and other Linux files systems even if they aren't supported by TSK.
领英推荐
Using The Sleuth Kit against EXT4
If you have a full disk image, this is very, very quick to run. It works best on EXT4 but in principle, it can be used on EXT3 (you just won't get creation timestamps).
Requirements
Workflow
This is very similar to how you would run it against MS Windows evidence. First run fls to create the bodyfile, then convert it with mactime.
fls -r -m / /path/to/evidence > /path/to/bodyfile
mactime -z UTC -y -d -b /path/to/bodyfile STARTDATE..ENDDATE > /path/to/output/filesystem-timeline.csv
An example of this is shown below.
As with Windows, it is often better to use Timeline Explorer from the Zimmerman tools to read this.
Using UAC against live systems or captured data (works on XFS/Btrfs)
UAC (Unix-like Artifacts Collector) is an incredible tool for rapidly collecting data from live systems or mounted images. The biggest advantage here is that it will analyse XFS and Btrfs data if you can mount the system.
At a very high level, UAC uses a collection profile (a predefined list of artifacts) to collect data from a target.
The profiles currently available are:
Full and ir_triage are similar, although the ir_triage profile collects less data and can be faster to run. Both also include recovering data from the /proc filesystem (memory), which is pointless on a mounted evidence item. However, as you can imagine, the offline profile skips this and is much more effective running against a mounted image.
In use, the syntax is pretty consistent.
uac -p {profile} (and/or) -a {artifact} EVIDENCEITEM OUTPUT
With an offline profile, also use --mount-point to specify where the evidence is mounted.
This is an example of the output when running UAC an offline collection profile against an XFS formatted evidence item mounted at /mnt/xfs and storing the data in /tmp.
When it finishes, there will be a .tar.gz file in the output folder (/tmp in our example above) which contains a bodyfile folder. In here there is bodyfile.txt - which should look like this.
This is a timeline of the system data in bodyfile format. Now you can use mactime to convert this as previously identified.
mactime -z UTC -y -d -b /path/to/bodyfile STARTDATE..ENDDATE > /path/to/output/filesystem-timeline.csv
When it runs, you should end up with CSV formatted output.
Using UAC against a live system is similar, but the arguments change - for example:
./uac -a bodyfile/bodyfile.yaml /tmp
This command will run the bodyfile artifact against the live system it is run on and store the data in /tmp.
Tools
Summary
Timelines are effectively a "forensic superpower," and being able to quickly build one is an essential skill for any incident responder. While you may have a go-to commercial tool, it definitely helps if you have the ability to rapidly build one using alternative methods.
When it comes to DFIR, the more tools and techniques you have available, the better you will be able to adapt to a given incident and resolve any issues quickly. If you are working in a Linux or multi-OS environment, one of the biggest challenges is finding support for filesystems other than EXT!
In Windows, we have a lot of options. One of the most efficient is to pull the $MFT with a triage tool and then use MFTECmd.exe and mactime. If you have a full disk image, then you can also just use The Sleuth Kit.
Linux is more complex. If it is an EXT family full disk image, then The Sleuth Kit is still an option. However, a faster way (and possibly the only way if you have XFS/Btrfs etc) might be to use UAC to build the bodyfile, then mactime to convert it.
#DFIR #timeline #infosec #cybersecurity #forensics #incidentresponse #cyber #security
DFIR Lead | Sekkop
5 个月Excellent write-up as always. Thanks Taz Wake
Cyber Threat Blue Team Operations at Royal Mail: Unless otherwise stated, any opinions I express are my own, and not representative of any organisation.
5 个月Samuel Langley - for your learnings! :)
Technology Consultant & Founder ?? IBM Champion 2023, 2024 & 2025
5 个月When I was in Operations I would often ask the new starts in our team to note the time of any action/activity It is so helpful to keep a timeline even for notifying senior Account Leads / Directors of impact and making sure the timing is correct and the impact update is accurate
Senior Digital Forensics team leader | Incident Handler | Cyber crime expert
5 个月Looks great!
Lead - Security Response & Incident Management
5 个月Solid article, but I'm surprised Plaso didn't make any appearances. It's so nice to be able to shove a disk image at it, get coffee, then come back to an ordered timeline of all the events. :D