
環境を攻撃するためにダウンロードすべきAzureツール集 + クイックヒントとその他の有用な情報
WindowsマシンまたはCloudshellから環境を攻撃するためにAzureツールを取得するためのコレクションです。
PowerShellで全ツールの最新版を自動取得したい場合は、Git for Windowsが必要です。
すべてのモジュールを取得するには、以下を実行してサブモジュールを取得できます:
git clone --recurse-submodules https://github.com/ZephrFish/AzureAttackKit
すばやく必要とする場合は、すべてのサブモジュールのzip版である AZ-AttackKit.zip もあります。
Setup.ps1 には、Azure および関連する各モジュールにアクセスするために必要なモジュールをインストールするための以下の行が含まれています。スクリプトが無効になっている場合は、powershell -ep bypass を実行する必要があるかもしれません。
Install-Module Az -Force -Confirm:$false -AllowClobber -Scope CurrentUser
Install-Module AzureAD -Force -Confirm:$false -AllowClobber -Scope CurrentUser
Install-Module Microsoft.Graph -Force -Confirm:$false -AllowClobber -Scope CurrentUser
Install-Module MSOnline -Force -Confirm:$false -AllowClobber -Scope CurrentUser
Install-Module AzureADPreview -Force -Confirm:$false -AllowClobber -Scope CurrentUser
Install-Module AADInternals -Force -Confirm:$false -AllowClobber -Scope CurrentUser
Import-Module Az
Import-Module AzureAD
Import-Module AADInternals
Import-Module .\MicroBurst-master\MicroBurst.psm1
Import-Module .\AzureRT-master\AzureRT.ps1
Import-Module .\PowerZure\PowerZure.psm1
Import-Module AADInternals
モジュールがインストールされたら、次の3つのコマンドを使用して Azure アカウントに接続する必要があります(Cloudshell を使用している場合は Connect-AzAccount -UseDeviceAuthentication を使用してください):
. .\Setup.ps1
Connect-ADandAZ
上記が失敗した場合は、次を実行してください:
Connect-AzAccount
Connect-AzureAD
Connect-MSolService
アクセスできるすべてのサブスクリプションを取得してから、それらを反復処理します。Get-ARTAccess(AzureRT を使用)を、サブスクリプション全体で実行したい任意のツールに変更してください。
$enabledSubs = Get-AzSubscription | Where-Object{$_.State -eq "Enabled"} | select Id
foreach ($SubName in $enabledSubs) {
$IDOut = $SubName.id
Get-ARTAccess -SubscriptionID $IDOut | Out-File "$IDOut.txt"
}
PowerZure を使用して、各サブスクリプションの runbook コンテンツを取得します:
$enabledSubs = Get-AzSubscription | Where-Object{$_.State -eq "Enabled"} | select Id
foreach ($SubName in $enabledSubs) {
$IDOut = $SubName.id
Set-AzContext -Subscription "$IDOut"
Get-AzureRunbookContent -All
}
追加のクイックウィンについては、Commands ファイルを参照してください。ツールメモ には、このリポジトリでリンクされているツールに加えて、確認すべきツールの役立つヒントもいくつかあります。
description = "Azure Service Principal Client Secret"
regex = '''(?i)(secret|key|password)\s*:?=?\s*['\"][0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}['\"]'''
[[rules]]
description = "Azure DevOps Personal Access Token"
regex = '''(?i)(pat|token)\s*:?=?\s*['\"](https://github.com/zephrfish/azureattackkit/blob/HEAD/%5Ba-z0-9%5D%7B52%7D)['\"]'''
[[rules]]
description = "Azure Account Key"
regex = '''(?i)(secret|key)\s*:?=?\s*['\"](https://github.com/zephrfish/azureattackkit/blob/HEAD/%5Ba-zA-Z0-9!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]{88})['\"]'''
tags = ["Azure Storage Account", "Azure Cosmos DB"]
[[rules]]
description = "Azure Storage Connection String"
regex = '''DefaultEndpointsProtocol=https;AccountName=[a-z0-9]{3,24};AccountKey=[a-zA-Z0-9!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]{88};EndpointSuffix=.+'''
[[rules]]
description = "Azure Cosmos DB Connection String"
regex = '''AccountEndpoint=https:\/\/.+:443\/;AccountKey=[a-zA-Z0-9!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]{88};'''
[[rules]]
description = "Generic Secret"
regex = '''(?i)secret\s*:?=?\s*['\"][0-9a-zA-Z-_/]{8,40}['\"]'''
# rules from trufflehog
[[rules]]
description = "Amazon MWS Auth Token"
regex = '''amzn\\.mws\\.[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'''
[[rules]]
description = "AWS AppSync GraphQL Key"
regex = '''da2-[a-z0-9]{26}'''
[[rules]]
description = "Google OAuth"
regex = '''[0-9]+-[0-9A-Za-z_]{32}\\.apps\\.googleusercontent\\.com'''
tags = ["Cloud Platform", "Drive", "Gmail", "YouTube"]
[[rules]]
description = "Google API Key"
regex = '''AIza[0-9A-Za-z\\-_]{35}'''
tags = ["Cloud Platform", "Drive", "Gmail", "YouTube"]
[[rules]]
description = "Google OAuth Access Token"
regex = '''ya29\\.[0-9A-Za-z\\-_]+'''
[[rules]]
description = "MailChimp API Key"
regex = '''[0-9a-f]{32}-us[0-9]{1,2}'''
[[rules]]
description = "Mailgun API Key"
regex = '''key-[0-9a-zA-Z]{32}'''
[[rules]]
description = "Square Access Token"
regex = '''sq0atp-[0-9A-Za-z\\-_]{22}'''
[[rules]]
description = "Square OAuth Secret"
regex = '''sq0csp-[0-9A-Za-z\\-_]{43}'''
[[rules]]
description = "Telegram Bot API Key"
regex = '''[0-9]+:AA[0-9A-Za-z\\-_]{33}'''
クライアントIDと情報を利用して接続するためのテンプレート
$tenantid = "<INSET TENANT ID>"
$clientid = "<INSERT CLIENT ID/USERNAME>"
$clientsecret = "<INSERT CLIENT SECRET/PASSWORD"
$subscription = "<INSERT SUBCRIPTION>"
$mycred = New-Object System.Management.Automation.PSCredential($clientid,(ConvertTo-SecureString $clientsecret -AsPlainText -Force))
Connect-AzAccount -Credential $mycred -Tenant $tenantid -ServicePrincipal -Subscription $subscription
# Below is if you need to also authenticate to Az as well
az login --service-principal -u $clientid -p $clientsecret --tenant $tenantid