Adversaries may modify file or directory permissions/attributes to evade access control lists (ACLs) and access protected files.(Citation: Hybrid Analysis Icacls1 June 2018)(Citation: Hybrid Analysis Icacls2 May 2018) File and directory permissions are commonly managed by ACLs configured by the file or directory owner, or users with the appropriate permissions. File and directory ACL implementations vary by platform, but generally explicitly designate which users or groups can perform which actions (read, write, execute, etc.).Most Linux and Linux-based platforms provide a standard set of permission groups (user, group, and other) and a standard set of permissions (read, write, and execute) that are applied to each group. While nuances of each platform’s permissions implementation may vary, most of the platforms provide two primary commands used to manipulate file and directory ACLs:
chown
(short for change owner), andchmod
(short for change mode).Adversarial may use these commands to make themselves the owner of files and directories or change the mode if current permissions allow it. They could subsequently lock others out of the file. Specific file and directory modifications may be a required step for many techniques, such as establishing Persistence via Unix Shell Configuration Modification or tainting/hijacking other instrumental binary/configuration files via Hijack Execution Flow.
-
Atomic Test #1 - chmod - Change file or folder mode (numeric mode)
-
Atomic Test #2 - chmod - Change file or folder mode (symbolic mode)
-
Atomic Test #3 - chmod - Change file or folder mode (numeric mode) recursively
-
Atomic Test #4 - chmod - Change file or folder mode (symbolic mode) recursively
-
Atomic Test #5 - chown - Change file or folder ownership and group
-
Atomic Test #6 - chown - Change file or folder ownership and group recursively
-
Atomic Test #7 - chown - Change file or folder mode ownership only
-
Atomic Test #8 - chown - Change file or folder ownership recursively
Changes a file or folder's permissions using chmod and a specified numeric mode.
Supported Platforms: macOS, Linux
Name | Description | Type | Default Value |
---|---|---|---|
numeric_mode | Specified numeric mode value | string | 755 |
file_or_folder | Path of the file or folder | path | /tmp/AtomicRedTeam/atomics/T1222.002 |
chmod #{numeric_mode} #{file_or_folder}
Changes a file or folder's permissions using chmod and a specified symbolic mode.
Supported Platforms: macOS, Linux
Name | Description | Type | Default Value |
---|---|---|---|
symbolic_mode | Specified symbolic mode value | string | a+w |
file_or_folder | Path of the file or folder | path | /tmp/AtomicRedTeam/atomics/T1222.002 |
chmod #{symbolic_mode} #{file_or_folder}
Changes a file or folder's permissions recursively using chmod and a specified numeric mode.
Supported Platforms: macOS, Linux
Name | Description | Type | Default Value |
---|---|---|---|
numeric_mode | Specified numeric mode value | string | 755 |
file_or_folder | Path of the file or folder | path | /tmp/AtomicRedTeam/atomics/T1222.002 |
chmod #{numeric_mode} #{file_or_folder} -R
Changes a file or folder's permissions recursively using chmod and a specified symbolic mode.
Supported Platforms: macOS, Linux
Name | Description | Type | Default Value |
---|---|---|---|
symbolic_mode | Specified symbolic mode value | string | a+w |
file_or_folder | Path of the file or folder | path | /tmp/AtomicRedTeam/atomics/T1222.002 |
chmod #{symbolic_mode} #{file_or_folder} -R
Changes a file or folder's ownership and group information using chown.
Supported Platforms: macOS, Linux
Name | Description | Type | Default Value |
---|---|---|---|
owner | Username of desired owner | string | root |
file_or_folder | Path of the file or folder | path | /tmp/AtomicRedTeam/atomics/T1222.002/T1222.002.yaml |
group | Group name of desired group | string | root |
chown #{owner}:#{group} #{file_or_folder}
Changes a file or folder's ownership and group information recursively using chown.
Supported Platforms: macOS, Linux
Name | Description | Type | Default Value |
---|---|---|---|
owner | Username of desired owner | string | root |
file_or_folder | Path of the file or folder | path | /tmp/AtomicRedTeam/atomics/T1222.002 |
group | Group name of desired group | string | root |
chown #{owner}:#{group} #{file_or_folder} -R
Changes a file or folder's ownership only using chown.
Supported Platforms: macOS, Linux
Name | Description | Type | Default Value |
---|---|---|---|
owner | Username of desired owner | string | root |
file_or_folder | Path of the file or folder | path | /tmp/AtomicRedTeam/atomics/T1222.002/T1222.002.yaml |
chown #{owner} #{file_or_folder}
Changes a file or folder's ownership only recursively using chown.
Supported Platforms: macOS, Linux
Name | Description | Type | Default Value |
---|---|---|---|
owner | Username of desired owner | string | root |
file_or_folder | Path of the file or folder | path | /tmp/AtomicRedTeam/atomics/T1222.002 |
chown #{owner} #{file_or_folder} -R
Remove's a file's immutable
attribute using chattr
.
This technique was used by the threat actor Rocke during the compromise of Linux web servers.
Supported Platforms: macOS, Linux
Name | Description | Type | Default Value |
---|---|---|---|
file_to_modify | Path of the file | path | /var/spool/cron/root |
chattr -i #{file_to_modify}