T1078.004 - Valid Accounts: Cloud Accounts
Valid accounts in cloud environments may allow adversaries to perform actions to achieve Initial Access, Persistence, Privilege Escalation, or Defense Evasion. Cloud accounts are those created and configured by an organization for use by users, remote support, services, or for administration of resources within a cloud service provider or SaaS application. Cloud Accounts can exist solely in the cloud; alternatively, they may be hybrid-joined between on-premises systems and the cloud through syncing or federation with other identity sources such as Windows Active Directory. (Citation: AWS Identity Federation)(Citation: Google Federating GC)(Citation: Microsoft Deploying AD Federation)
Service or user accounts may be targeted by adversaries through [Brute Force](https://attack.mitre.org/techniques/T1110), [Phishing](https://attack.mitre.org/techniques/T1566), or various other means to gain access to the environment. Federated or synced accounts may be a pathway for the adversary to affect both on-premises systems and cloud environments - for example, by leveraging shared credentials to log onto [Remote Services](https://attack.mitre.org/techniques/T1021). High privileged cloud accounts, whether federated, synced, or cloud-only, may also allow pivoting to on-premises environments by leveraging SaaS-based [Software Deployment Tools](https://attack.mitre.org/techniques/T1072) to run commands on hybrid-joined devices.
An adversary may create long lasting [Additional Cloud Credentials](https://attack.mitre.org/techniques/T1098/001) on a compromised cloud account to maintain persistence in the environment. Such credentials may also be used to bypass security controls such as multi-factor authentication.
Cloud accounts may also be able to assume [Temporary Elevated Cloud Access](https://attack.mitre.org/techniques/T1548/005) or other privileges through various means within the environment. Misconfigurations in role assignments or role assumption policies may allow an adversary to use these mechanisms to leverage permissions outside the intended scope of the account. Such over privileged accounts may be used to harvest sensitive data from online storage accounts and databases through [Cloud API](https://attack.mitre.org/techniques/T1059/009) or other methods.
Atomic Tests
Atomic Test #1 - Creating GCP Service Account and Service Account Key
GCP Service Accounts can be used to gain intial access as well as maintain persistence inside Google Cloud.
Supported Platforms: Google-workspace, Iaas:gcp
auto_generated_guid: 9fdd83fd-bd53-46e5-a716-9dec89c8ae8e
| Name | Description | Type | Default Value |
|——|————-|——|—————|
| project-id | ID of the project, you want to create service account as well as service account key for | string | art-project-1|
| service-account-name | Name of the service account | string | gcp-art-service-account-1|
| service-account-email | Email of the service account | string | gcp-art-service-account-1@art-project-1.iam.gserviceaccount.com|
| output-key-file | Email of the service account | string | gcp-art-service-account-1.json|
Attack Commands: Run with
!
1
2
3
| gcloud config set project #{project-id}
gcloud iam service-accounts create #{service-account-name}
gcloud iam service-accounts keys create #{output-key-file} --iam-account=#{service-account-email}
|
Cleanup Commands:
1
| gcloud iam service-accounts delete #{service-account-email} --quiet
|
Dependencies: Run with
!
Description: Requires gcloud
Check Prereq Commands:
1
| if [ -x "$(command -v gcloud)" ]; then exit 0; else exit 1; fi;
|
Get Prereq Commands:
1
| echo "Please Install Google Cloud SDK before running this atomic test : https://cloud.google.com/sdk/docs/install"
|
Description: Check if user is logged in
Check Prereq Commands:
1
| gcloud config get-value account
|
Get Prereq Commands:
1
| gcloud auth login --no-launch-browser
|
Atomic Test #2 - Azure Persistence Automation Runbook Created or Modified
Identifies when an Azure Automation runbook is created or modified. An adversary may create or modify an Azure
Automation runbook to execute malicious code and maintain persistence in their target’s environment.
Supported Platforms: Iaas:azure
auto_generated_guid: 348f4d14-4bd3-4f6b-bd8a-61237f78b3ac
| Name | Description | Type | Default Value |
|——|————-|——|—————|
| username | Azure username | string | |
| password | Azure password | string | |
| resource_group | Name of the resource group | string | |
| runbook_name | Name of the runbook name | string | |
| automation_account_name | Name of the automation account name | string | |
Attack Commands: Run with
!
1
2
3
4
| $secure_pwd = "#{password}" | ConvertTo-SecureString -AsPlainText -Force
$creds = New-Object System.Management.Automation.PSCredential -ArgumentList "#{username}", $secure_pwd
Connect-AzAccount -Credential $creds
New-AzAutomationRunbook -Name #{runbook_name} -Type PowerShell -ResourceGroupName #{resource_group} -Description 'my-test-runbook' -AutomationAccountName #{automation_account_name}
|
Cleanup Commands:
1
2
3
| Remove-AzAutomationRunbook -AutomationAccountName #{automation_account_name} -Name #{runbook_name} -ResourceGroupName #{resource_group} -Force
cd "$PathToAtomicsFolder/T1078.004/src/T1078.004-2/"
terraform destroy -auto-approve
|
Dependencies: Run with
!
Check Prereq Commands:
Get Prereq Commands:
1
| echo Please install terraform.
|
Description: Install-Module -Name Az
Check Prereq Commands:
1
| try {if (Get-InstalledModule -Name Az -ErrorAction SilentlyContinue) {exit 0} else {exit 1}} catch {exit 1}
|
Get Prereq Commands:
1
| Install-Module -Name Az -Scope CurrentUser -Force
|
Description: Check if the user is logged into Azure.
Check Prereq Commands:
Get Prereq Commands:
1
| echo Configure your Azure account using: az login.
|
Check Prereq Commands:
1
| try {if (Test-Path "$PathToAtomicsFolder/T1078.004/src/T1078.004-2/terraform.tfstate" ){ exit 0 } else {exit 1}} catch {exit 1}
|
Get Prereq Commands:
1
2
3
| cd "$PathToAtomicsFolder/T1078.004/src/T1078.004-2/"
terraform init
terraform apply -auto-approve
|
Atomic Test #3 - GCP - Create Custom IAM Role
This atomic will create a new IAM role. The default role permissions are: IAM Service Account Get. The idea for this Atomic came from a Rule published by the Elastic team.
Identifies an Identity and Access Management (IAM) custom role creation in Google Cloud Platform (GCP).
Custom roles are user-defined, and allow for the bundling of one or more supported permissions to meet specific needs.
Custom roles will not be updated automatically and could lead to privilege creep if not carefully scrutinized.
This atomic will create a new IAM role. The default role permissions are: IAM Service Account Get
Reference: https://github.com/elastic/detection-rules/blob/main/rules/integrations/gcp/initial_access_gcp_iam_custom_role_creation.toml
Supported Platforms: Iaas:gcp
auto_generated_guid: 3a159042-69e6-4398-9a69-3308a4841c85
| Name | Description | Type | Default Value |
|——|————-|——|—————|
| project-id | ID of the GCP Project you to execute the command against. | string | atomic-test-1|
| role-name | The name of the role to be created. | string | AtomicRedTeamRole|
| role-description | The description of the role to be created. | string | Atomic Red Team Custom IAM Role|
| roles | List of roles to be applied | string | iam.serviceAccounts.get|
Attack Commands: Run with
!
1
2
| gcloud config set project #{project-id}
gcloud iam roles create #{role-name} --description="#{role-description}" --permissions=#{roles} --project=#{project-id}
|
Cleanup Commands:
1
| gcloud iam roles delete #{role-name} --project=#{project-id}
|
Dependencies: Run with
!
Description: Requires gcloud
Check Prereq Commands:
1
| if [ -x "$(command -v gcloud)" ]; then exit 0; else exit 1; fi;
|
Get Prereq Commands:
1
| echo "Please Install Google Cloud SDK before running this atomic test : https://cloud.google.com/sdk/docs/install"
|
Description: Check if user is logged in
Check Prereq Commands:
1
| gcloud config get-value account
|
Get Prereq Commands:
1
| gcloud auth login --no-launch-browser
|