Skip to content

Latest commit

 

History

History
301 lines (143 loc) · 8.07 KB

T1222.002.md

File metadata and controls

301 lines (143 loc) · 8.07 KB

T1222.002 - Linux and Mac File and Directory Permissions Modification

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), and chmod (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 Tests


Atomic Test #1 - chmod - Change file or folder mode (numeric mode)

Changes a file or folder's permissions using chmod and a specified numeric mode.

Supported Platforms: macOS, Linux

Inputs:

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

Attack Commands: Run with bash!

chmod #{numeric_mode} #{file_or_folder}


Atomic Test #2 - chmod - Change file or folder mode (symbolic mode)

Changes a file or folder's permissions using chmod and a specified symbolic mode.

Supported Platforms: macOS, Linux

Inputs:

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

Attack Commands: Run with bash!

chmod #{symbolic_mode} #{file_or_folder}


Atomic Test #3 - chmod - Change file or folder mode (numeric mode) recursively

Changes a file or folder's permissions recursively using chmod and a specified numeric mode.

Supported Platforms: macOS, Linux

Inputs:

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

Attack Commands: Run with bash!

chmod #{numeric_mode} #{file_or_folder} -R


Atomic Test #4 - chmod - Change file or folder mode (symbolic mode) recursively

Changes a file or folder's permissions recursively using chmod and a specified symbolic mode.

Supported Platforms: macOS, Linux

Inputs:

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

Attack Commands: Run with bash!

chmod #{symbolic_mode} #{file_or_folder} -R


Atomic Test #5 - chown - Change file or folder ownership and group

Changes a file or folder's ownership and group information using chown.

Supported Platforms: macOS, Linux

Inputs:

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

Attack Commands: Run with bash!

chown #{owner}:#{group} #{file_or_folder}


Atomic Test #6 - chown - Change file or folder ownership and group recursively

Changes a file or folder's ownership and group information recursively using chown.

Supported Platforms: macOS, Linux

Inputs:

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

Attack Commands: Run with bash!

chown #{owner}:#{group} #{file_or_folder} -R


Atomic Test #7 - chown - Change file or folder mode ownership only

Changes a file or folder's ownership only using chown.

Supported Platforms: macOS, Linux

Inputs:

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

Attack Commands: Run with bash!

chown #{owner} #{file_or_folder}


Atomic Test #8 - chown - Change file or folder ownership recursively

Changes a file or folder's ownership only recursively using chown.

Supported Platforms: macOS, Linux

Inputs:

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

Attack Commands: Run with bash!

chown #{owner} #{file_or_folder} -R


Atomic Test #9 - chattr - Remove immutable file attribute

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

Inputs:

Name Description Type Default Value
file_to_modify Path of the file path /var/spool/cron/root

Attack Commands: Run with sh!

chattr -i #{file_to_modify}