# T1070.006 - Indicator Removal on Host: Timestomp

## Description from ATT&CK

> Adversaries may modify file time attributes to hide new files 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 and blend malicious files with legitimate files.
> 
> In Windows systems, both the `$STANDARD_INFORMATION` (`$SI`) and `$FILE_NAME` (`$FN`) attributes record times in a Master File Table (MFT) file.(Citation: Inversecos Timestomping 2022) `$SI` (dates/time stamps) is displayed to the end user, including in the File System view, while `$FN` is dealt with by the kernel.(Citation: Magnet Forensics)
> 
> Modifying the `$SI` attribute is the most common method of timestomping because it can be modified at the user level using API calls. `$FN` timestomping, however, typically requires interacting with the system kernel or moving or renaming a file.(Citation: Inversecos Timestomping 2022)
> 
> Adversaries modify timestamps on files so that they do not appear conspicuous to forensic investigators or file analysis tools. In order to evade detections that rely on identifying discrepancies between the `$SI` and `$FN` attributes, adversaries may also engage in “double timestomping” by modifying times on both attributes simultaneously.(Citation: Double Timestomping)
> 
> In Linux systems and on ESXi servers, threat actors may attempt to perform timestomping using commands such as `touch -a -m -t <timestamp> <filename>` (which sets access and modification times to a specific value) or `touch -r <filename> <filename>` (which sets access and modification times to match those of another file).(Citation: Inversecos Linux Timestomping)(Citation: Juniper Networks ESXi Backdoor 2022)
> 
> Timestomping may be used along with file name [Masquerading](https://attack.mitre.org/techniques/T1036) to hide malware and tools.(Citation: WindowsIR Anti-Forensic Techniques)

[Source](https://attack.mitre.org/techniques/T1070/006)

## Atomic Tests

- [Atomic Test #1: Set a file's access timestamp](#atomic-test-1-set-a-files-access-timestamp)
- [Atomic Test #2: Set a file's modification timestamp](#atomic-test-2-set-a-files-modification-timestamp)
- [Atomic Test #3: Set a file's creation timestamp](#atomic-test-3-set-a-files-creation-timestamp)
- [Atomic Test #4: Modify file timestamps using reference file](#atomic-test-4-modify-file-timestamps-using-reference-file)
- [Atomic Test #5: Windows - Modify file creation timestamp with PowerShell](#atomic-test-5-windows---modify-file-creation-timestamp-with-powershell)
- [Atomic Test #6: Windows - Modify file last modified timestamp with PowerShell](#atomic-test-6-windows---modify-file-last-modified-timestamp-with-powershell)
- [Atomic Test #7: Windows - Modify file last access timestamp with PowerShell](#atomic-test-7-windows---modify-file-last-access-timestamp-with-powershell)
- [Atomic Test #8: Windows - Timestomp a File](#atomic-test-8-windows---timestomp-a-file)
- [Atomic Test #9: MacOS - Timestomp Date Modified](#atomic-test-9-macos---timestomp-date-modified)
- [Atomic Test #10: Event Log Manipulations- Time slipping via Powershell](#atomic-test-10-event-log-manipulations--time-slipping-via-powershell)

### Atomic Test #1: Set a file's access timestamp

Stomps on the access timestamp of a file

**Supported Platforms:** Linux, macOS

**auto_generated_guid:** `5f9113d5-ed75-47ed-ba23-ea3573d05810`

#### Inputs

| Name | Description | Type | Default Value |
|------|-------------|------|---------------|
| target_filename | Path of file that we are going to stomp on last access time | path | /tmp/T1070.006-access.txt|

#### Attack Commands: Run with `sh`!

```sh
touch -a -t[PII_REDACTED]00.00 #{target_filename}
```

#### Cleanup Commands

```sh
rm -f #{target_filename}
```

#### Dependencies: Run with `sh`!

##### Description: The file must exist in order to be timestomped

###### Check Prereq Commands

```sh
test -e #{target_filename} && exit 0 || exit 1
```

###### Get Prereq Commands

```sh
echo 'T1070.006 file access timestomp test' > #{target_filename}
```

### Atomic Test #2: Set a file's modification timestamp

Stomps on the modification timestamp of a file

**Supported Platforms:** Linux, macOS

**auto_generated_guid:** `20ef1523-8758-4898-b5a2-d026cc3d2c52`

#### Inputs

| Name | Description | Type | Default Value |
|------|-------------|------|---------------|
| target_filename | Path of file that we are going to stomp on last access time | path | /tmp/T1070.006-modification.txt|

#### Attack Commands: Run with `sh`!

```sh
touch -m -t[PII_REDACTED]00.00 #{target_filename}
```

#### Cleanup Commands

```sh
rm -f #{target_filename}
```

#### Dependencies: Run with `sh`!

##### Description: The file must exist in order to be timestomped

###### Check Prereq Commands

```sh
test -e #{target_filename} && exit 0 || exit 1
```

###### Get Prereq Commands

```sh
echo 'T1070.006 file modification timestomp test' > #{target_filename}
```

### Atomic Test #3: Set a file's creation timestamp

Stomps 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

**auto_generated_guid:** `8164a4a6-f99c-4661-ac4f-80f5e4e78d2b`

#### Inputs

| Name | Description | Type | Default Value |
|------|-------------|------|---------------|
| target_filename | Path of file that we are going to stomp on last access time | path | /tmp/T1070.006-creation.txt|

#### Attack Commands: Run with `sh`! Elevation Required (e.g. root or admin)

```sh
NOW=$(date +%m%d%H%M%Y)
date[PII_REDACTED]71
touch #{target_filename}
date "$NOW"
stat #{target_filename}
```

#### Cleanup Commands

```sh
rm -f #{target_filename}
```
### 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

**auto_generated_guid:** `631ea661-d661-44b0-abdb-7a7f3fc08e50`

#### Inputs

| Name | Description | Type | Default Value |
|------|-------------|------|---------------|
| target_file_path | Path of file to modify timestamps of | path | /tmp/T1070.006-reference.txt|
| reference_file_path | Path of reference file to read timestamps from | path | /bin/sh|

#### Attack Commands: Run with `sh`!

```sh
touch #{target_file_path}
touch -acmr #{reference_file_path} #{target_file_path}
```

#### Cleanup Commands

```sh
rm -f #{target_file_path}
```
### 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