-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
azure vm-custom-script-extension: rework detonation code
- Loading branch information
1 parent
07c93b5
commit 80a318a
Showing
5 changed files
with
68 additions
and
31 deletions.
There are no files selected for viewing
41 changes: 32 additions & 9 deletions
41
docs/attack-techniques/azure/azure.execution.vm-custom-script-extension.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,66 @@ | ||
--- | ||
title: Execute Commands on Virtual Machine using Custom Script Extension | ||
title: Execute Command on Virtual Machine using Custom Script Extension | ||
--- | ||
|
||
# Execute Commands on Virtual Machine using Custom Script Extension | ||
# Execute Command on Virtual Machine using Custom Script Extension | ||
|
||
<span class="smallcaps w3-badge w3-orange w3-round w3-text-sand" title="This attack technique might be slow to warm up or detonate">slow</span> | ||
<span class="smallcaps w3-badge w3-blue w3-round w3-text-white" title="This attack technique can be detonated multiple times">false</span> | ||
|
||
|
||
Platform: Azure | ||
|
||
## MITRE ATT&CK Tactics | ||
|
||
|
||
- Execution | ||
|
||
## Description | ||
|
||
|
||
By utilizing the 'CustomScriptExtension' extension on a Virtual Machine, an attacker can pass PowerShell commands to the VM as SYSTEM. | ||
|
||
References: | ||
|
||
- https://docs.microsoft.com/en-us/azure/virtual-machines/extensions/custom-script-windows | ||
- https://github.com/hausec/Azure-Attack-Matrix/blob/main/Execution/AZT201/AZT201-2.md | ||
|
||
<span style="font-variant: small-caps;">Warm-up</span>: | ||
<span style="font-variant: small-caps;">Warm-up</span>: | ||
|
||
- Create a virtual machine | ||
|
||
<span style="font-variant: small-caps;">Detonation</span>: | ||
<span style="font-variant: small-caps;">Detonation</span>: | ||
|
||
- Configure and provision a Custom Script Extension for the virtual machine | ||
- Configure a custom script extension for the virtual machine | ||
|
||
|
||
## Instructions | ||
|
||
```bash title="Detonate with Stratus Red Team" | ||
stratus detonate azure.execution.vm-custom-script-extension | ||
``` | ||
|
||
## Detection | ||
|
||
1. Look for <code>Microsoft.Compute/virtualMachines/extensions/write</code> events in Azure Activity logs | ||
2. Review files on disk located in <code>C:\Packages\Plugins\Microsoft.Compute.CustomScriptExtension</code> | ||
|
||
Identify Azure events of type <code>Microsoft.Compute/virtualMachines/extensions/write</code>. Sample below (redacted for clarity). | ||
|
||
```json hl_lines="7" | ||
{ | ||
"duration": 0, | ||
"resourceId": "/SUBSCRIPTIONS/<your-subscription-id>/RESOURCEGROUPS/RG-HAT6H48Q/PROVIDERS/MICROSOFT.COMPUTE/VIRTUALMACHINES/VM-HAT6H48Q/EXTENSIONS/CUSTOMSCRIPTEXTENSION-STRATUS-EXAMPLE", | ||
"evt": { | ||
"category": "Administrative", | ||
"outcome": "Start", | ||
"name": "MICROSOFT.COMPUTE/VIRTUALMACHINES/EXTENSIONS/WRITE" | ||
}, | ||
"resource_name": "customscriptextension-stratus-example", | ||
"time": "2022-06-18T19:57:27.8617215Z", | ||
"properties": { | ||
"hierarchy": "ecc2b97b-844b-414e-8123-b925dddf87ed/<your-subscription-id>", | ||
"message": "Microsoft.Compute/virtualMachines/extensions/write", | ||
"eventCategory": "Administrative", | ||
"entity": "/subscriptions/<your-subscription-id>/resourceGroups/rg-hat6h48q/providers/Microsoft.Compute/virtualMachines/vm-hat6h48q/extensions/CustomScriptExtension-Stratus-Example" | ||
}, | ||
} | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters