Path: blob/master/Entity Explorer - IP Address.ipynb
3249 views
Entity Explorer: IP Address
Notebook details...
Notebook Version: 2.0
Python Version: Python 3.10
Required Packages: msticpy, msticnb
Data Sources Required:
MS Sentinel (mostly optional)
Heartbeat
SecurityAlert
CommonSecurityLog
Azure AD Signin Logs
Azure Activity Logs
Office 356 Activity
AzureNetworkAnalytics_CL
MS Defender
VMComputer
External
VirusTotal (with API key)
Alienvault OTX (with API key)
IBM Xforce (with API key)
This notebook brings together a series of queries and visualizations to help you assess the security state of an IP address.
It works with both internal addresses and public addresses.
For internal addresses it focuses on traffic patterns and activity of the host using that IP address.
For public IPs it lets you perform threat intelligence lookups, passive dns, whois and other checks.
It also allows you to examine Azure/Office activity, network traffic, host behavior
and other data about the IP Address (subject to data availability).
The notebook uses the MSTIC notebooklets package to run most of the functionality. Summarized data is returned when it is run and more detailed information is contained in the returned result class.
Table of Contents
Hunting Hypothesis
Notebook Initialization
Get WorkspaceId and Authenticate to MS Sentinel
Import and initialize notebooklets
Enter the IP Address and query time window
Run the main ip_summary notebooklet
Browse alerts
View Threat Intel results
Map view of IP Address
Additional properties of the the result object
Viewing the Results class
Using Pivots to get more context information
User other notebooks and pivot functions to drill down on other entities
Hunting Hypothesis
Our broad initial hunting hypothesis is that a we have received IP address entity which is suspected to be compromized internal host or external public address to whom internal hosts are communicating in malicious manner, we will need to hunt from a range of different positions to validate or disprove this hypothesis.
Notebook initialization
This should complete without errors. If you encounter errors or warnings look at the following notebooks:
If you are running in the Azure Sentinel Notebooks environment (Azure Notebooks or Azure ML) you can run live versions of these notebooks:
[Getting Started](./A Getting Started Guide For Azure Sentinel ML Notebooks.ipynb)
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 MS Sentinel
msticpyconfig.yaml create a connection string with your AAD TENANT_ID and
your WORKSPACE_ID (these should both be quoted UUID strings).
e.g.
Then in the Authentication cell replace the call to qry_prov.connect with the following:
The cell should now look like this:
On successful authentication you should see a popup schema button. To find your Workspace Id go to Log Analytics. Look at the workspace properties to find the ID.
Note: in VSCode (bug) the options may display in the VSCode status bar (bottom left)
Authentication and Configuration problems?
If you are having problems, expand the details section below
Click for details about configuring your authentication parameters
The notebook is expecting your Azure Sentinel Tenant ID and Workspace ID to be configured in one of the following places:
msticpyconfig.yamlin the current folder or location specified byMSTICPYCONFIGenvironment variable.config.jsonin the current folder
For help with setting up your configuration (if this hasn't been done automatically) see the [Getting Started](./A Getting Started Guide For Azure Sentinel ML Notebooks.ipynb) notebook in the root folder of your Azure-Sentinel-Notebooks project.
Import and initialize notebooklets
This imports the msticnb package and the notebooklets classes.
These are needed for the notebook operations
Enter the IP Address and query time window
Type the IP address you want to search for and the time bounds over which search.
You can specify the IP address value in the widget e.g. 192.168.1.1
Run the main ip_summary notebooklet run method to retrieve IP information
The notebooklet will query a variety of Sentinel tables and external data sources including:
MS Defender device information
Active Directory, Office and Azure Activity
Geo Location
WhoIs
Threat Intelligence providers
A summary of the data is displayed as it runs. You can run view the notebooklet result class to view the whole content or use individual data properties (DataFrames) to view detailed information.
See later in the notebook for how to access these.
Options you can use in the run method
Default options for the ip_address_summary function:
geoip: Get geo location information for IP address.
alerts: Get any alerts listing the IP address.
host_logons: Find any hosts with logons using this IP address as a source.
related_accounts: Find any accounts using this IP address in AAD or host logs.
device_info: Find any devices associated with this IP address.
device_network: Find any devices communicating with this IP address.
Other Options
bookmarks: Get any hunting bookmarks listing the IP address.
heartbeat: Get the latest heartbeat record for for this IP address.
az_net_if: Get the latest Azure network analytics interface data for this IP address.
vmcomputer: Get the latest VMComputer record for this IP address.
az_netflow: Get netflow information from AzureNetworkAnalytics table.
passive_dns: Force fetching passive DNS data from a TI Provider even if IP is internal.
az_activity: AAD sign-ins and Azure Activity logs.
office_365: Office 365 activity.
common_security: Get records from common security log.
ti: Force get threat intelligence reports even for internal public IPs.
Include additional options by prefixing the option with a "+"
See the code in the next cell for an example. To remove an option, include in the list prefixed with a "-"
The pivot function `account_summary` is in the `nblt` container of the `Account` entity.
Note: this can also be run as a pivot function from the IpAddress entity.
The pivot functionip_summaryis in thenbltcontainer of theAccountentity.
Browse alerts
View any recent alerts featuring the IP Address
View Threat Intel results
View the full TI reports, if any, for the IP Address.
Map view of IP Address
Show the location of the IP address on a map
Other data and methods available for the IP notebooklet result
The notebooklet result has a number of data properties
Appendix - Additional properties from the Notebooklet result
These are static properties - usually DataFrames or visualizations. You can access each of these to see or manipulate the retrieved data.
To see help on the available attributes type:
To see the available methods type:
Note, for the IP Summary notebooklet, the main data retrieval method is:
run
There are several other methods that allow you to view individual plots or subsets of the data (such as alerts).
To view help on a specific method type:
Viewing the Result class
You can view all of the data in the results class by "running" it in a cell
Note: This produces a lot of output.
Due to the way Jupyter display Javascript objects the plots may appear out of order.
Most of the properties of the results class are pandas DataFrames - you can use these directly for further analysis. Other property types include entities and visualizations.
The DataFrames displayed by running the result object are truncated to the first five rows.
You can also access individual data properties of the result as follows:
Using Pivots to get more context information
You can run a pivot function on the summary results to get additional context on the data.
Here is an example of looking up Whois information for Azure IPAddress requests.
Use other notebooklets and pivots functions to drill down on other entities
You may want to drill down on other entities in the data. You can use methods of the IpAddress or Host entities, for example, to look at these in more detail.
Run the ip_address_summary notebooklet pivot