2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Defender for Resouce Manager に対して、攻撃シミュレーションを行いアラートを発砲させる

Posted at

1. はじめに

Microsoft Defender for Cloud で提供されている Defender for Resouce Manager(ARM) は、Azure Resource Management Layer (ポータル、RESTAPI、PowerShell) の悪意のある使用に対する脅威検出を行うことができます。このプランをサブスクリプション単位で有効化しているユーザーは多いと思いますが、実際に攻撃テストをどのように行えばよいか情報が少ないため、Microsoft 社のナレッジ情報を元にテストしてみました。

2. 事前準備

  • 対象のサブスクリプションに対して、Defender for Resouce Manager を有効化すること
  • サブスクリプションに対して、Reader 権限を持つユーザーが有ること
  • Powershell 環境

3. 試してみる

3.1 Defender for Resouce Manager の有効化

Microsoft Defender for Cloud より、設定画面から対象のサブスクリプションに対して Defender for Resource Manager を有効化しておきます。
image.png

3.2 Powershell 環境の準備

  • 自 PC 端末でテストする場合は、Az Powershell モジュールをインストールします
PS C:\> Install-Module -Name Az -AllowClobber -Scope AllUsers
  • 現ユーザーに対して、実行ポリシーを許可しておきます
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Force

3.3 スクリプトの作成

  • VisualCode Studio などでスクリプトを作成します
# Script to alert ARM_MicroBurst.AzDomainInfo alert
#Import-Module Az

# Login to the Azure account and get a random Resource group
$accountContext = Connect-AzAccount -AuthScope MicrosoftGraphEndpointResourceId
$subscriptionId = $accountContext.Context.Subscription.Name
$resourceGroup = Get-AzResourceGroup | Get-Random
$rg = $resourceGroup.ResourceGroupName
Write-Output "[*] Dumping information`nSubscription: $subscriptionId`nResource group: $rg."

Write-Output "[*] Scanning Storage Accounts..."
$storageAccountLists = Get-AzStorageAccount -ResourceGroupName $rg | select StorageAccountName,ResourceGroupName

Write-Output "[*] Scanning Azure Resource Groups..."
$resourceGroups = Get-AzResourceGroup

Write-Output "[*] Scanning Azure Resources..."
$resourceLists = Get-AzResource

Write-Output "[*] Scanning AzureSQL Resources..."
$azureSQLServers = Get-AzResource | where {$_.ResourceType -Like "Microsoft.Sql/servers"}

Write-Output "[*] Scanning Azure App Services..."
$appServs = Get-AzWebApp -ResourceGroupName $rg

Write-Output "[*] Scanning Azure App Services #2..."
$appServs = Get-AzWebApp -ResourceGroupName $rg

Write-Output "[*] Scanning Azure Disks..."
$disks = (Get-AzDisk | select ResourceGroupName, ManagedBy, Zones, TimeCreated, OsType, HyperVGeneration, DiskSizeGB, DiskSizeBytes, UniqueId, EncryptionSettingsCollection, ProvisioningState, DiskIOPSReadWrite, DiskMBpsReadWrite, DiskIOPSReadOnly, DiskMBpsReadOnly, DiskState, MaxShares, Id, Name, Location -ExpandProperty Encryption)

Write-Output "[*] Scanning Azure Deployments and Parameters..."
$idk = Get-AzResourceGroupDeployment -ResourceGroupName $rg

Write-Output "[*] Scanning Virtual Machines..."
$VMList = Get-AzVM

Write-Output "[*] Scanning Virtual Machine Scale Sets..."
$scaleSets = Get-AzVmss

Write-Output "[*] Scanning Network Interfaces..."
$NICList = Get-AzNetworkInterface

Write-Output "[*] Scanning Public IPs for each Network Interface..."
$pubIPs = Get-AzPublicIpAddress | select Name,IpAddress,PublicIpAllocationMethod,ResourceGroupName

Write-Output "[*] Scanning Network Security Groups..."
$NSGList = Get-AzNetworkSecurityGroup | select Name, ResourceGroupName, Location, SecurityRules, DefaultSecurityRules
    
Write-Output "[*] Scanning RBAC Users and Roles..."    
$roleAssignment = Get-AzRoleAssignment

Write-Output "[*] Scanning Roles Definitions..." 
$roles = Get-AzRoleDefinition 

Write-Output "[*] Scanning Automation Account Runbooks and Variables..."
$autoAccounts = Get-AzAutomationAccount

Write-Output "[*] Scanning Tenant Information..."
$tenantID = Get-AzTenant | select TenantId

Write-Output "[!] Done Running."

3.4 攻撃シミュレーション - スクリプトの実行

  • スクリプトを実行すると、connect-AzAccount コマンドにてユーザー認証が立ち上がるので、認証を実施の上、評価対象とするサブスクリプションを選択します
    image.png
  • サブスクリプションを選択すると、スクリプトはランダムに対象のリソースをスキャンしていきます
    image.png

3.5 Defender for Cloud 側でアラートをチェックする

スクリプトが完了してからアラートが表示されるまでに、最大 60 分の遅延が発生する場合があります (平均 45 分)。アラートは「MicroBurst exploitation toolkit used to enumerate resources in your subscriptions」名でセキュティ警告に表示されます。

image.png

4. まとめ

Defender for Resource Manager の検知テストとしては PowerZure を用いる方法も考えましたが、ナレッジ側に紹介されているリソースをランダムにスキャンする方法が分かりやすいので試してみました。本記事がどなたかの参考になれば幸いです。

*本稿は、個人の見解に基づいた内容であり、所属する会社の公式見解ではありません。また、いかなる保証を与えるものでもありません。正式な情報は、各製品の販売元にご確認ください。

参考情報

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?