334 строки
18 KiB
JSON
334 строки
18 KiB
JSON
{
|
|
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
|
|
"contentVersion": "1.0.0.0",
|
|
"metadata": {
|
|
"comments": "This playbook uses the HYAS Insight connector to automatically enrich incidents generated by Sentinel with geolocation information. You need a valid subscription in order to use the connector and playbook. Learn more about the integration via the https://docs.microsoft.com/connectors/hyasinsight/ or visit https://www.hyas.com/contact to request a trial key.",
|
|
"author": "Paul van Gool, HYAS Infosec"
|
|
},
|
|
"parameters": {
|
|
"PlaybookName": {
|
|
"defaultValue": "Enrich-Sentinel-Incident-HYAS-Insight-IPv4-Device-Geo",
|
|
"type": "string"
|
|
},
|
|
"UserName": {
|
|
"defaultValue": "<username>@<domain>",
|
|
"type": "string"
|
|
}
|
|
},
|
|
"variables": {
|
|
"HYASInsightApiKey": "[concat('hyasinsight-', parameters('PlaybookName'))]",
|
|
"AzureSentinelConnectionName": "[concat('azuresentinel-', parameters('PlaybookName'))]"
|
|
},
|
|
"resources": [
|
|
{
|
|
"type": "Microsoft.Web/connections",
|
|
"apiVersion": "2016-06-01",
|
|
"name": "[variables('AzureSentinelConnectionName')]",
|
|
"location": "[resourceGroup().location]",
|
|
"properties": {
|
|
"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('HYASInsightApiKey')]",
|
|
"location": "[resourceGroup().location]",
|
|
"properties": {
|
|
"displayName": "[parameters('UserName')]",
|
|
"customParameterValues": {},
|
|
"api": {
|
|
"id": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/hyasinsight')]"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"type": "Microsoft.Logic/workflows",
|
|
"apiVersion": "2017-07-01",
|
|
"name": "[parameters('PlaybookName')]",
|
|
"location": "[resourceGroup().location]",
|
|
"dependsOn": [
|
|
"[resourceId('Microsoft.Web/connections', variables('HYASInsightApiKey'))]",
|
|
"[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": {
|
|
"Entities_-_Get_IPs": {
|
|
"runAfter": {},
|
|
"type": "ApiConnection",
|
|
"inputs": {
|
|
"body": "@triggerBody()?['Entities']",
|
|
"host": {
|
|
"connection": {
|
|
"name": "@parameters('$connections')['azuresentinel']['connectionId']"
|
|
}
|
|
},
|
|
"method": "post",
|
|
"path": "/entities/ip"
|
|
}
|
|
},
|
|
"JSON_Output_Variable": {
|
|
"runAfter": {
|
|
"Entities_-_Get_IPs": [
|
|
"Succeeded"
|
|
]
|
|
},
|
|
"type": "InitializeVariable",
|
|
"inputs": {
|
|
"variables": [
|
|
{
|
|
"name": "Json Output",
|
|
"type": "array"
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"Looping_Through_Sentinel_IPs": {
|
|
"foreach": "@body('Entities_-_Get_IPs')?['IPs']",
|
|
"actions": {
|
|
"Add_comment_to_incident_(V2)_2": {
|
|
"runAfter": {
|
|
"Checking_If_the_Response_Returned_Data": [
|
|
"Succeeded"
|
|
]
|
|
},
|
|
"type": "ApiConnection",
|
|
"inputs": {
|
|
"body": {
|
|
"Value": "HYAS Insight Device Geo enrichment data for the IPv4 \"@{items('Looping_Through_Sentinel_IPs')?['Address']}\" :\n\n@{replace(variables('Comment'), '"', '')}\n\nFor detailed information, see https://insight.hyas.com/static/details?ipv4=@{items('Looping_Through_Sentinel_IPs')?['Address']}"
|
|
},
|
|
"host": {
|
|
"connection": {
|
|
"name": "@parameters('$connections')['azuresentinel']['connectionId']"
|
|
}
|
|
},
|
|
"method": "put",
|
|
"path": "/Comment/@{encodeURIComponent(triggerBody()?['WorkspaceSubscriptionId'])}/@{encodeURIComponent(triggerBody()?['WorkspaceId'])}/@{encodeURIComponent(triggerBody()?['WorkspaceResourceGroup'])}/@{encodeURIComponent('Alert')}/@{encodeURIComponent(triggerBody()?['SystemAlertId'])}"
|
|
}
|
|
},
|
|
"Checking_If_the_Response_Returned_Data": {
|
|
"actions": {
|
|
"Assigning_Table_Formatted_Output_to_Incident_Comment_Variable": {
|
|
"runAfter": {
|
|
"Create_HTML_table": [
|
|
"Succeeded"
|
|
]
|
|
},
|
|
"type": "SetVariable",
|
|
"inputs": {
|
|
"name": "Comment",
|
|
"value": "@body('Create_HTML_table')"
|
|
}
|
|
},
|
|
"Checking_If_The_Length_Of_The_Data_Is_More_Than_Max_Comment_Length": {
|
|
"actions": {
|
|
"Truncating_the_Table_to_Match_the_Required_Length_for_the_Incident_Comment": {
|
|
"runAfter": {},
|
|
"type": "SetVariable",
|
|
"inputs": {
|
|
"name": "Comment",
|
|
"value": "@{concat(substring(body('Create_HTML_table'), 0, 2800), '...')}"
|
|
}
|
|
}
|
|
},
|
|
"runAfter": {
|
|
"Assigning_Table_Formatted_Output_to_Incident_Comment_Variable": [
|
|
"Succeeded"
|
|
]
|
|
},
|
|
"expression": {
|
|
"and": [
|
|
{
|
|
"greater": [
|
|
"@length(body('Create_HTML_table'))",
|
|
3000
|
|
]
|
|
}
|
|
]
|
|
},
|
|
"type": "If"
|
|
},
|
|
"Create_HTML_table": {
|
|
"runAfter": {
|
|
"Looping_Through_Response_Object": [
|
|
"Succeeded"
|
|
]
|
|
},
|
|
"type": "Table",
|
|
"inputs": {
|
|
"format": "HTML",
|
|
"from": "@variables('Json Output')"
|
|
}
|
|
},
|
|
"Looping_Through_Response_Object": {
|
|
"foreach": "@body('Retrieve_Device_Geo_information_for_IPv4_address')",
|
|
"actions": {
|
|
"Creating_JSON_Output_Variable_Object": {
|
|
"runAfter": {},
|
|
"type": "AppendToArrayVariable",
|
|
"inputs": {
|
|
"name": "Json Output",
|
|
"value": {
|
|
"BSSID": "@items('Looping_Through_Response_Object')?['wifi_bssid']",
|
|
"Timestamp": "@items('Looping_Through_Response_Object')?['datetime']"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"runAfter": {},
|
|
"type": "Foreach"
|
|
}
|
|
},
|
|
"runAfter": {
|
|
"Setting_Response_Length_Variable": [
|
|
"Succeeded"
|
|
]
|
|
},
|
|
"else": {
|
|
"actions": {
|
|
"No_Records_Found": {
|
|
"runAfter": {},
|
|
"type": "SetVariable",
|
|
"inputs": {
|
|
"name": "Comment",
|
|
"value": "No records found in HYAS Insight for IP \"@{items('Looping_Through_Sentinel_IPs')?['Address']}\"."
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"expression": {
|
|
"and": [
|
|
{
|
|
"greater": [
|
|
"@variables('RecordsLength')",
|
|
0
|
|
]
|
|
}
|
|
]
|
|
},
|
|
"type": "If"
|
|
},
|
|
"Retrieve_Device_Geo_information_for_IPv4_address": {
|
|
"runAfter": {},
|
|
"type": "ApiConnection",
|
|
"inputs": {
|
|
"body": {
|
|
"applied_filters": {
|
|
"ipv4": "@items('Looping_Through_Sentinel_IPs')?['Address']"
|
|
}
|
|
},
|
|
"host": {
|
|
"connection": {
|
|
"name": "@parameters('$connections')['hyasinsight']['connectionId']"
|
|
}
|
|
},
|
|
"method": "post",
|
|
"path": "/device_geo"
|
|
}
|
|
},
|
|
"Setting_Response_Length_Variable": {
|
|
"runAfter": {
|
|
"Retrieve_Device_Geo_information_for_IPv4_address": [
|
|
"Succeeded"
|
|
]
|
|
},
|
|
"type": "SetVariable",
|
|
"inputs": {
|
|
"name": "RecordsLength",
|
|
"value": "@length(body('Retrieve_Device_Geo_information_for_IPv4_address'))"
|
|
}
|
|
}
|
|
},
|
|
"runAfter": {
|
|
"Sentinel_Incident_Comment_Variable": [
|
|
"Succeeded"
|
|
]
|
|
},
|
|
"type": "Foreach"
|
|
},
|
|
"Response_Length_Variable": {
|
|
"runAfter": {
|
|
"JSON_Output_Variable": [
|
|
"Succeeded"
|
|
]
|
|
},
|
|
"type": "InitializeVariable",
|
|
"inputs": {
|
|
"variables": [
|
|
{
|
|
"name": "RecordsLength",
|
|
"type": "integer",
|
|
"value": 0
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"Sentinel_Incident_Comment_Variable": {
|
|
"runAfter": {
|
|
"Response_Length_Variable": [
|
|
"Succeeded"
|
|
]
|
|
},
|
|
"type": "InitializeVariable",
|
|
"inputs": {
|
|
"variables": [
|
|
{
|
|
"name": "Comment",
|
|
"type": "string"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
},
|
|
"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')]"
|
|
},
|
|
"hyasinsight": {
|
|
"connectionId": "[resourceId('Microsoft.Web/connections', variables('HYASInsightApiKey'))]",
|
|
"connectionName": "[variables('HYASInsightApiKey')]",
|
|
"id": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/hyasinsight')]"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|