Path: blob/master/Guided Hunting - Azure Resource Explorer.ipynb
3249 views
Guided Hunting - Azure Resource Explorer
 Details...
Notebook Version: 1.0
Python Version: Python 3.7 (including Python 3.6 - AzureML)
Required Packages: kqlmagic, msticpy, pandas, numpy, matplotlib, networkx, ipywidgets, ipython
Platforms Supported:
Azure Notebooks Free Compute
Azure Notebooks DSVM
OS Independent
Azure Machine Learning Notebooks
Data Sources Required:
Log Analytics
SecurityAlert
SignInLogs
AzureActivity
ResourceGraph
Resources
(Optional)
VirusTotal (with API key)
Alienvault OTX (with API key)
IBM Xforce (with API key)
This notebook guides you through an investigation of an Azure Resource of choice and enables you to pivot using functionality from Azure Resource Graphs. The notebook uses SecurityAlert, SignInLogs, and AzureActivity logs.
You can begin with a resource or a security alert you want to investigate or use our queries to find one of interest.
The goal of the notebook is to help you better understand potential malicious behavior in your Azure Resource Graph and to successfully pivot to resources of interest as you hunt.
Notebook initialization
The next cell:
Checks for the correct Python version
Checks versions and optionally installs required packages
Imports the required packages into the notebook
Sets a number of configuration options.
This should complete without errors. If you encounter errors or warnings look at the following two notebooks:
If you are running in the Azure Sentinel Notebooks environment (Azure Notebooks or Azure ML) you can run live versions of these notebooks:
You may also need to do some additional configuration to successfully use functions such as Threat Intelligence service lookup and Geo IP lookup. There are more details about this in the ConfiguringNotebookEnvironment notebook and in these documents:
Get WorkspaceId and Authenticate to Log Analytics and ResourceGraph
Run the cells below to connect to your Log Analytics workspace. If you haven't already, please fill in the relevant information in msticpyconfig.yaml. This file is found in the Azure Sentinel Notebooks folder this notebook is in. There is more information on how to do this in the Notebook Setup section above. You may need to restart the kernel after doing so and rerun any cells you've already run to update to the new information.
If you are unfamiliar with connecting to Log Analytics or want a more in-depth walkthrough, check out the Getting Started with Azure Sentinel Notebook.
If you are running this notebook locally, you may also need to install Azure CLI. You will have to restart your computer and relaunch the notebook if this is done.
Log into Azure
Log into your Azure account by running the following cell.
Connect to your Azure Workspace
Connect to ResourceGraph and LogAnalytics
Select Resource to Investigate
Select Time Range
This time range will be used in all queries that follow in this notebook to retrieve any related alerts connected to your chosen resource.
Select Resource
Enter ResourceID
If you already know which resource you want to investigate, enter its resource ID in the text box after running the following cell.
Skip this cell if you would like to use related alerts to select a resource to investigate. The below cells will provide some context on related alerts and offer you a chance to select a resource directly.
Gather related alert information and select resource
Run the following cells for a summary table of alert activity in your workspace. Resources with more SecurityAlert results may be more likely to be victims of malicious activity.
Run the cell below to see a dropdown listing all resources involved in the alerts shown. Select one that you would like to investigate. Skip this section if you have already entered a ResourceID of interest above.
View Resource Graph
This section of the notebook allows you to investigate resources related to the resource you have chosen and better understand your resource graph environment by generating a visual representation of the graph. You can reselect the resource you want to investigate in the sections above at any time. Rerun the below cells to generate a new graph if you select a different resource.
Run the following cells to generate the resource graph.
Import required graph libraries
Validate selected resource
The following cell will confirm if the resource you selected exists and is valid for generating the investigation graph. If the resource is not found, feel free to use the dropdown or text box to enter a different resource and return to this cell.
Generate graph
The following cells will generate a NetworkX graph of your resource environment. Please run each cell to properly generate the graph. Confirmation that the cell you just ran worked properly will print out once each cell finishes running.
Show Graph
The following graph prints out the graph that the above cells generate. Keep the following in mind for optimal viewing:
The sizes of the circles represent how many alerts are related to the resource that it represents. The resource you selected above to investigate will be in a darker green color than the rest.
Hover over each circle for information on its name, type, and the number of alerts associated with it.
Use the selector tool to choose the types of resources you want displayed in the graph. Be aware the graph will not update unless you also update the slider after updating the selector.
Use the slider to filter by the number of alerts. We recommend clicking rather than sliding to prevent the graph from slowly generating a graph per number you slide onto.
Resource Investigation
The following sections provide context around the resource you selected.
Related Alerts
The following cell shows SecurityAlert event log entries that feature
This includes alerts in which the Compromised Entity is the resource you selected and those that contain the same IP addresses that appear in alerts with the selected compromised entity. A TI search on available IOC data is calculated where available.
Investigate further!
If you would like to pivot further on a certain entity, please check out our Entity Explorer series:
Timeline of related alerts
Parse ResourceGraph
From the dropdown below, pick a resource of interest from the resource graph then run the cell below it to view all information gathered on it.
Investigate further!
To further view a user's access, please check out our Guided Analysis - User Security Metadata notebook.
Location and Resource Type Counts
The following cell prints out summary information about all of the resources and their locations and types in your workspace.
Related AzureActivityLogs Activity
In the following cell, we use a KQL query to see if there are any AzureActivity log entries related to the resource you selected. You can use the results to pivot and check for TI intel results.
AzureActivity Timeline
The following cell prints out a timeline of AzureActivity entries related to the resource you selected to put the results into time context. It also parses any TI data out and results from connected TI sources.