# SetFile

> Set attributes of files and directories.

Uses the CommandLine/Terminal to set file and or directory attributes. It can set attributes, creator, creation date, modification date, and file type for multiple files at a time.

- Page: https://loobins.io/binaries/setfile/
- Author: Chris Campbell (@texasbe2trill)
- Created: 2023-04-23
- Tactics: Persistence, Stealth

## Paths

- `/usr/bin/SetFile`

## Example Use Cases

### Set a file or directory attribute to invisible

A bash or zsh oneliner can allow an attacker to set the file attribute to invisible. This action can establish persistence and evade detection for malicious files on the system.

```bash
for FILE in ~/*; do echo $(SetFile -a V $FILE && echo $(GetFileInfo $FILE)) >> /tmp/fileinfo.txt; sleep 2; done
```

- Tactics: Persistence, Stealth
- ATT&CK techniques: T1564.001
- Tags: bash, zsh, oneliner

### Change a file's creation and modification timestamps

Setfile can be used with the -d and -m arguments to alter a file's creation and modification date, respectively.

```bash
SetFile -d "04/25/2023 11:11:00" -m "04/25/2023 11:12:00" targetfile.txt
```

- Tactics: Stealth
- ATT&CK techniques: T1070.006
- Tags: bash, zsh, oneliner

## Detections

- No detections at time of publishing

## Resources

- [The Invisible Bit](https://daringfireball.net/2008/04/the_invisible_bit)
