This commit is contained in:
Rod Trent 2021-01-21 14:09:12 -05:00 коммит произвёл GitHub
Родитель e2773f9281
Коммит cad156936f
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 307 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,307 @@
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"metadata": {
"comments": "This playbook takes the email address entities of the Incident and compares them against the HaveIBeenPwned API to identify compromised accounts.",
"author": "Rod Trent"
},
"parameters": {
"PlaybookName": {
"defaultValue": "HaveIBeenPwnedEmail",
"type": "string"
},
"UserName": {
"defaultValue": "<username>@<domain>",
"type": "string"
}
},
"variables": {
"AzureSentinelConnectionName": "[concat('azuresentinel-', parameters('PlaybookName'))]"
},
"resources": [
{
"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('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"
}
},
"staticResults": {
"HTTP0": {
"status": "Succeeded",
"outputs": {
"headers": {},
"statusCode": "404"
}
}
},
"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": {
"API_Variable": {
"runAfter": {},
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "hibp-api-key",
"type": "string",
"value": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
]
}
},
"Alert_-_Get_accounts": {
"runAfter": {
"Alert_-_Get_incident": [
"Succeeded"
]
},
"type": "ApiConnection",
"inputs": {
"body": "@triggerBody()?['Entities']",
"host": {
"connection": {
"name": "@parameters('$connections')['azuresentinel']['connectionId']"
}
},
"method": "post",
"path": "/entities/account"
}
},
"Alert_-_Get_incident": {
"runAfter": {
"Query_Return": [
"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'])}"
}
},
"Asterisk_Variable": {
"runAfter": {
"API_Variable": [
"Succeeded"
]
},
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "Asterisk",
"type": "string",
"value": "@"
}
]
}
},
"Email_Address_Variable": {
"runAfter": {
"Asterisk_Variable": [
"Succeeded"
]
},
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "FullEmailAddress",
"type": "string"
}
]
}
},
"For_each_2": {
"foreach": "@body('Alert_-_Get_accounts')?['Accounts']",
"actions": {
"Append_to_string_variable": {
"runAfter": {},
"type": "AppendToStringVariable",
"inputs": {
"name": "FullEmailAddress",
"value": "@{items('For_each_2')?['Name']}@{variables('Asterisk')}@{items('For_each_2')?['UPNSuffix']}"
}
},
"Append_to_string_variable_2": {
"runAfter": {
"HTTP": [
"Succeeded",
"Failed"
]
},
"type": "AppendToStringVariable",
"inputs": {
"name": "Query Return",
"value": "@outputs('HTTP')['statusCode']"
}
},
"Condition": {
"actions": {
"Add_comment_to_incident_(V2)": {
"runAfter": {},
"type": "ApiConnection",
"inputs": {
"body": {
"Value": "Congratulations! @{variables('FullEmailAddress')} was not found in the Pwned Database."
},
"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'])}"
}
}
},
"runAfter": {
"Append_to_string_variable_2": [
"Succeeded"
]
},
"else": {
"actions": {
"Add_comment_to_incident_(V2)_2": {
"runAfter": {},
"type": "ApiConnection",
"inputs": {
"body": {
"Value": "@{variables('FullEmailAddress')} has been identifed as a compromised account by haveibeenpwned."
},
"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": [
"@outputs('HTTP')['statusCode']",
404
]
}
]
},
"type": "If"
},
"HTTP": {
"runAfter": {
"Append_to_string_variable": [
"Succeeded"
]
},
"type": "Http",
"inputs": {
"headers": {
"hibp-api-key": "@variables('hibp-api-key')"
},
"method": "GET",
"uri": "https://haveibeenpwned.com/api/v3/breachedaccount/@{variables('FullEmailAddress')}"
},
"runtimeConfiguration": {
"staticResult": {
"staticResultOptions": "Disabled",
"name": "HTTP0"
}
}
}
},
"runAfter": {
"Alert_-_Get_accounts": [
"Succeeded"
]
},
"type": "Foreach"
},
"Query_Return": {
"runAfter": {
"Email_Address_Variable": [
"Succeeded"
]
},
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "Query Return",
"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')]"
}
}
}
}
}
}
]
}