Azure-Sentinel/Playbooks/Block-ExchangeIP/BlockExchangeIP.json

219 строки
11 KiB
JSON

{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"PlaybookName": {
"defaultValue": "PlaybookName",
"type": "string"
},
"UserName": {
"defaultValue": "<username>@<domain>",
"type": "string"
},
"AutomationAccount": {
"defaultValue": "Name of Azure Automation Account",
"type": "string"
},
"HybridWorkGroup": {
"defaultValue": "Hybrid Worker Group configured for Exchange server",
"type": "string"
}
},
"variables": {
"AzureSentinelConnectionName": "[concat('azuresentinel-', parameters('PlaybookName'))]",
"AzureAutomationConnectionName": "[concat('azureautomation-', parameters('PlaybookName'))]",
"RunBookContentsURI":"https://raw.githubusercontent.com/ThijsLecomte/ARM-Templates/master/Block-ExchangeIP.ps1",
"RunBookName":"Block-IPRunbook"
},
"resources": [
{
"type": "Microsoft.Automation/automationAccounts/runbooks",
"apiVersion": "2018-06-30",
"name": "[concat(parameters('AutomationAccount'),'/',variables('RunBookName'))]",
"location": "[resourceGroup().location]",
"properties": {
"runbookType": "PowerShell",
"logVerbose": false,
"logProgress": false,
"logActivityTrace": 0,
"publishContentLink": {
"uri": "[variables('RunBookContentsURI')]"
}
}
},
{
"type": "Microsoft.Web/connections",
"apiVersion": "2016-06-01",
"name": "[variables('AzureSentinelConnectionName')]",
"location": "[resourceGroup().location]",
"properties": {
"displayName": "[parameters('UserName')]",
"customParameterValues": {},
"api": {
"id": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/azuresentinel')]"
}
}
},
{
"type": "Microsoft.Web/connections",
"apiVersion": "2016-06-01",
"name": "[variables('AzureAutomationConnectionName')]",
"location": "[resourceGroup().location]",
"properties": {
"displayName": "[parameters('UserName')]",
"customParameterValues": {},
"api": {
"id": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/azureautomation')]"
}
}
},
{
"type": "Microsoft.Logic/workflows",
"apiVersion": "2017-07-01",
"name": "[parameters('PlaybookName')]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.Web/connections', variables('AzureSentinelConnectionName'))]",
"[resourceId('Microsoft.Web/connections', variables('AzureAutomationConnectionName'))]",
"[concat('Microsoft.Automation/automationAccounts/', parameters('AutomationAccount'), '/runbooks/', variables('RunBookName'))]"
],
"properties": {
"state": "Enabled",
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"$connections": {
"defaultValue": {},
"type": "Object"
}
},
"triggers": {
"When_a_response_to_an_Azure_Sentinel_alert_is_triggered": {
"type": "ApiConnectionWebhook",
"inputs": {
"body": {
"callback_url": "@{listCallbackUrl()}"
},
"host": {
"connection": {
"name": "@parameters('$connections')['azuresentinel']['connectionId']"
}
},
"path": "/subscribe"
}
}
},
"actions": {
"Alert_-_Get_IPs": {
"runAfter": {
"Alert_-_Get_incident": [
"Succeeded"
]
},
"type": "ApiConnection",
"inputs": {
"body": "@triggerBody()?['Entities']",
"host": {
"connection": {
"name": "@parameters('$connections')['azuresentinel']['connectionId']"
}
},
"method": "post",
"path": "/entities/ip"
}
},
"Alert_-_Get_incident": {
"runAfter": {},
"type": "ApiConnection",
"inputs": {
"host": {
"connection": {
"name": "@parameters('$connections')['azuresentinel']['connectionId']"
}
},
"method": "get",
"path": "/Cases/@{encodeURIComponent(triggerBody()?['SystemAlertId'])}/@{encodeURIComponent(triggerBody()?['WorkspaceSubscriptionId'])}/@{encodeURIComponent(triggerBody()?['WorkspaceId'])}/@{encodeURIComponent(triggerBody()?['WorkspaceResourceGroup'])}"
}
},
"For_each": {
"foreach": "@body('Alert_-_Get_IPs')?['IPs']",
"actions": {
"Add_comment_to_incident_(V2)": {
"runAfter": {
"Create_job": [
"Succeeded"
]
},
"type": "ApiConnection",
"inputs": {
"body": {
"Value": "Blocked IP @{items('For_each')?['Address']} on Exchange server"
},
"host": {
"connection": {
"name": "@parameters('$connections')['azuresentinel']['connectionId']"
}
},
"method": "put",
"path": "/Comment/@{encodeURIComponent(triggerBody()?['WorkspaceSubscriptionId'])}/@{encodeURIComponent(triggerBody()?['WorkspaceId'])}/@{encodeURIComponent(triggerBody()?['WorkspaceResourceGroup'])}/@{encodeURIComponent('Incident')}/@{encodeURIComponent(triggerBody()?['SystemAlertId'])}"
}
},
"Create_job": {
"runAfter": {},
"type": "ApiConnection",
"inputs": {
"body": {
"properties": {
"parameters": {
"IPToBeBlocked": "@items('For_each')?['Address']"
},
"runOn": "[parameters('HybridWorkGroup')]"
}
},
"host": {
"connection": {
"name": "@parameters('$connections')['azureautomation']['connectionId']"
}
},
"method": "put",
"path": "/subscriptions/@{encodeURIComponent('23ab6747-a21f-4e9d-ad68-0b0237ad7cd8')}/resourceGroups/@{encodeURIComponent('SecOps')}/providers/Microsoft.Automation/automationAccounts/@{encodeURIComponent('GeneralAutomation')}/jobs",
"queries": {
"runbookName": "[variables('RunBookName')]",
"wait": true,
"x-ms-api-version": "2015-10-31"
}
}
}
},
"runAfter": {
"Alert_-_Get_IPs": [
"Succeeded"
]
},
"type": "Foreach"
}
},
"outputs": {}
},
"parameters": {
"$connections": {
"value": {
"azuresentinel": {
"connectionId": "[resourceId('Microsoft.Web/connections', variables('AzureSentinelConnectionName'))]",
"connectionName": "[variables('AzureSentinelConnectionName')]",
"id": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/azuresentinel')]"
},
"azureautomation": {
"connectionId": "[resourceId('Microsoft.Web/connections', variables('AzureAutomationConnectionName'))]",
"connectionName": "[variables('AzureAutomationConnectionName')]",
"id": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/azureautomation')]"
}
}
}
}
}
}
]
}