Azure-Sentinel/Playbooks/Get-IPReputation/azuredeploy.json

393 строки
23 KiB
JSON

{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"metadata":{
"comments": "This playbook will take each IP entity and query VirusTotal for Ip Address Report (https://developers.virustotal.com/reference#ip-address-report). You will need to register to thier community for an API key.",
"author": "Nicholas DiCola"
},
"parameters": {
"PlaybookName": {
"defaultValue": "Get-IPReputation",
"type": "string"
},
"UserName": {
"defaultValue": "<username>@<domain>",
"type": "string"
},
"LogADisplayName": {
"defaultValue": "<LogADisplayName>",
"type": "string"
},
"VirusTotalAPIKey": {
"defaultValue": "<APIKey>",
"type": "string"
}
},
"variables": {
"AzureLogAnalyticsDataCollectorConnectionName": "[concat('azureloganalyticsdatacollector-', parameters('PlaybookName'))]",
"AzureSentinelConnectionName": "[concat('azuresentinel-', parameters('PlaybookName'))]"
},
"resources": [
{
"type": "Microsoft.Web/connections",
"apiVersion": "2016-06-01",
"name": "[variables('AzureLogAnalyticsDataCollectorConnectionName')]",
"location": "[resourceGroup().location]",
"properties": {
"displayName": "[parameters('LogADisplayName')]",
"customParameterValues": {},
"api": {
"id": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/azureloganalyticsdatacollector')]"
}
}
},
{
"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.Logic/workflows",
"apiVersion": "2017-07-01",
"name": "[parameters('PlaybookName')]",
"location": "[resourceGroup().location]",
"tags": {
"LogicAppsCategory": "security"
},
"dependsOn": [
"[resourceId('Microsoft.Web/connections', variables('AzureLogAnalyticsDataCollectorConnectionName'))]",
"[resourceId('Microsoft.Web/connections', variables('AzureSentinelConnectionName'))]"
],
"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": {
"Initialize_variable": [
"Succeeded"
]
},
"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": {
"Condition": {
"actions": {
"Add_comment_to_incident_(V2)": {
"runAfter": {
"Send_Data": [
"Succeeded"
]
},
"type": "ApiConnection",
"inputs": {
"body": {
"Value": "VTIPReport found for @{items('For_each')?['Address']}, Query: VTIPReport_CL | where asn_d == \"@{body('Parse_JSON')?['asn']}\" and country_s == \"@{body('Parse_JSON')?['country']}\""
},
"host": {
"connection": {
"name": "@parameters('$connections')['azuresentinel']['connectionId']"
}
},
"method": "put",
"path": "/Comment/@{encodeURIComponent(triggerBody()?['WorkspaceSubscriptionId'])}/@{encodeURIComponent(triggerBody()?['WorkspaceId'])}/@{encodeURIComponent(triggerBody()?['WorkspaceResourceGroup'])}/@{encodeURIComponent('Incident')}/@{encodeURIComponent(body('Alert_-_Get_incident')?['properties']?['CaseNumber'])}"
}
},
"Send_Data": {
"runAfter": {},
"type": "ApiConnection",
"inputs": {
"body": "@{body('HTTP')}",
"headers": {
"Log-Type": "VTIPReport",
"time-generated-field": "@{utcNow()}"
},
"host": {
"connection": {
"name": "@parameters('$connections')['azureloganalyticsdatacollector']['connectionId']"
}
},
"method": "post",
"path": "/api/logs"
}
}
},
"runAfter": {
"Parse_JSON": [
"Succeeded"
]
},
"else": {
"actions": {
"Add_comment_to_incident_(V2)_2": {
"runAfter": {},
"type": "ApiConnection",
"inputs": {
"body": {
"Value": "VTIPReport was not found for @{items('For_each')?['Address']}"
},
"host": {
"connection": {
"name": "@parameters('$connections')['azuresentinel']['connectionId']"
}
},
"method": "put",
"path": "/Comment/@{encodeURIComponent(triggerBody()?['WorkspaceSubscriptionId'])}/@{encodeURIComponent(triggerBody()?['WorkspaceId'])}/@{encodeURIComponent(triggerBody()?['WorkspaceResourceGroup'])}/@{encodeURIComponent('Incident')}/@{encodeURIComponent(body('Alert_-_Get_incident')?['properties']?['CaseNumber'])}"
}
}
}
},
"expression": {
"and": [
{
"equals": [
"@body('Parse_JSON')?['response_code']",
1
]
}
]
},
"type": "If"
},
"HTTP": {
"runAfter": {},
"type": "Http",
"inputs": {
"method": "GET",
"uri": "https://www.virustotal.com/vtapi/v2/ip-address/report?apikey=@{variables('APIKey')}&ip=@{items('For_each')?['Address']}"
}
},
"Parse_JSON": {
"runAfter": {
"HTTP": [
"Succeeded"
]
},
"type": "ParseJson",
"inputs": {
"content": "@body('HTTP')",
"schema": {
"properties": {
"content": {
"properties": {
"as_owner": {
"type": "string"
},
"asn": {
"type": "integer"
},
"country": {
"type": "string"
},
"detected_downloaded_samples": {
"type": "array"
},
"detected_urls": {
"items": {
"properties": {
"positives": {
"type": "integer"
},
"scan_date": {
"type": "string"
},
"total": {
"type": "integer"
},
"url": {
"type": "string"
}
},
"type": "object"
},
"type": "array"
},
"resolutions": {
"items": {
"properties": {
"hostname": {
"type": "string"
},
"last_resolved": {
"type": "string"
}
},
"type": "object"
},
"type": "array"
},
"response_code": {
"type": "integer"
},
"undetected_downloaded_samples": {
"type": "array"
},
"undetected_urls": {
"items": {
"type": "array"
},
"type": "array"
},
"verbose_msg": {
"type": "string"
}
},
"type": "object"
},
"schema": {
"properties": {
"properties": {
"properties": {
"asn": {
"properties": {
"type": {
"type": "string"
}
},
"type": "object"
},
"country": {
"properties": {
"type": {
"type": "string"
}
},
"type": "object"
},
"response_code": {
"properties": {
"type": {
"type": "string"
}
},
"type": "object"
},
"verbose_msg": {
"properties": {
"type": {
"type": "string"
}
},
"type": "object"
}
},
"type": "object"
},
"type": {
"type": "string"
}
},
"type": "object"
}
},
"type": "object"
}
}
}
},
"runAfter": {
"Alert_-_Get_IPs": [
"Succeeded"
]
},
"type": "Foreach"
},
"Initialize_variable": {
"runAfter": {},
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "APIKey",
"type": "String",
"value": "[parameters('VirusTotalAPIKey')]"
}
]
}
}
},
"outputs": {}
},
"parameters": {
"$connections": {
"value": {
"azureloganalyticsdatacollector": {
"connectionId": "[resourceId('Microsoft.Web/connections', variables('AzureLogAnalyticsDataCollectorConnectionName'))]",
"connectionName": "[variables('AzureSentinelConnectionName')]",
"id": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/azureloganalyticsdatacollector')]"
},
"azuresentinel": {
"connectionId": "[resourceId('Microsoft.Web/connections', variables('AzureSentinelConnectionName'))]",
"connectionName": "[variables('AzureSentinelConnectionName')]",
"id": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/azuresentinel')]"
}
}
}
}
}
}
]
}