Path: blob/master/tutorials-and-examples/deprecated-notebooks/Entity Explorer - Linux Host.ipynb
3253 views
Entity Explorer - Linux Host
Details...
Notebook Version: 1.1
Python Version: Python 3.6 (including Python 3.6 - AzureML)
Required Packages: kqlmagic, msticpy, pandas, pandas_bokeh, numpy, matplotlib, networkx, seaborn, datetime, ipywidgets, ipython, dnspython, ipwhois, folium, maxminddb_geolite2
Data Sources Required:
Log Analytics/Microsoft Sentinel - Syslog, Secuirty Alerts, Auditd, Azure Network Analytics.
(Optional) - AlienVault OTX (requires account and API key)
This Notebooks brings together a series of tools and techniques to enable threat hunting within the context of a singular Linux host. The notebook utilizes a range of data sources to achieve this but in order to support the widest possible range of scenarios this Notebook prioritizes using common Syslog data. If there is detailed auditd data available for a host you may wish to edit the Notebook to rely primarily on this dataset, as it currently stands auditd is used when available to provide insight not otherwise available via Syslog.
Hunting Hypothesis:
Our broad initial hunting hypothesis is that a particular Linux host in our environment has been compromised, we will need to hunt from a range of different positions to validate or disprove this hypothesis.
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 Microsoft 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
Use the following syntax if you are authenticating using an Azure Active Directory AppId and Secret:
instead of
Note: you may occasionally see a JavaScript error displayed at the end of the authentication - you can safely ignore 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.
Set Hunting Time Frame
To begin the hunt we need to et the time frame in which you wish to test your compromised host hunting hypothesis within. Use the widget below to select your start and end time for the hunt.
Select Host to Investigate
Select the host you want to test your hunting hypothesis against, only hosts with Syslog data within the time frame you specified are available. If the host you wish to select is not present try adjusting your time frame.
Host Summary
Below is a overview of the selected host based on available data sources.
Host Alerts & Bookmarks
This section provides an overview of any security alerts or Hunting Bookmarks in Microsoft Sentinel related to this host, this will help scope and guide our hunt.
Re-scope Hunting Time Frame
Based on the security alerts for this host we can choose to re-scope our hunting time frame.
How to use this Notebook
Whilst this notebook is linear in layout it doesn't need to be linear in usage. We have selected our host to investigate and set an initial hunting time-frame to work within. We can now start to test more specific hunting hypothesis with the aim of validating our broader initial hunting hypothesis. To do this we can start by looking at:
You can choose to start below with a hunt in host logon events or choose to jump to one of the other sections listed above. The order in which you choose to run each of these major sections doesn't matter, they are each self contained. You may also choose to rerun sections based on your findings from running other sections.
This notebook uses external threat intelligence sources to enrich data. The next cell loads the TILookup class.
Note: to use TILookup you will need configuration settings in your msticpyconfig.yaml
see TIProviders documenation
and Configuring Notebook Environment notebook
or ConfiguringNotebookEnvironment (GitHub static view)
Host Logon Events
Hypothesis: That an attacker has gained legitimate access to the host via compromised credentials and has logged into the host to conduct malicious activity.
This section provides an overview of logon activity for the host within our hunting time frame, the purpose of this is to allow for the identification of anomalous logons or attempted logons.
Logon Sessions
Based on the detail above if you wish to focus your hunt on a particular user jump to the User Activity section. Alternatively to further further refine our hunt we need to select a logon session to view in more detail. Select a session from the list below to continue. Sessions that occurred at the time an alert was raised for this host, or where the user has a abnormal ratio of failed to successful login attempts are highlighted.
Session Details
Raw data from user session
Use this syslog message data to further investigate suspicous activity during the session
Process Tree from session
Click here to start a process/application focused hunt or continue with session based hunt below by selecting a sudo session to investigate.
Sudo Session Investigation
Sudo activity is often required by an attacker to conduct actions on target, and more granular data is avalibale for sudo sessions allowing for deeper level hunting within these sesions.
User Activity
Hypothesis: That an attacker has gained access to the host and is using a user account to conduct actions on the host.
This section provides an overview of activity by user within our hunting time frame, the purpose of this is to allow for the identification of anomalous activity by a user. This hunt can be driven be investigation of suspected users or as a hunt across all users seen on the host.
Application Activity
Hypothesis: That an attacker has compromised an application running on the host and is using the applications process to conduct actions on the host.
This section provides an overview of activity by application within our hunting time frame, the purpose of this is to allow for the identification of anomalous activity by an application. This hunt can be driven be investigation of suspected applications or as a hunt across all users seen on the host.
Display process tree
Due to the large volume of data involved you may wish to make you query window smaller
Application Logs with associated Threat Intelligence
These logs are associated with the process being investigated and include IOCs that appear in our TI feeds.
Network Activity
Hypothesis: That an attacker is remotely communicating with the host in order to compromise the host or for C2 or data exfiltration purposes after compromising the host.
This section provides an overview of network activity to and from the host during hunting time frame, the purpose of this is to allow for the identification of anomalous network traffic. If you wish to investigate a specific IP in detail it is recommended that you use the IP Explorer Notebook (include link).
Choose ASNs/IPs to Check for Threat Intel Reports
Choose from the list of Selected ASNs for the IPs you wish to check on. Then select the IP(s) that you wish to check against Threat Intelligence data. The Source list is populated with all ASNs found in the syslog and network flow data.
Configuration
msticpyconfig.yaml configuration File
You can configure primary and secondary TI providers and any required parameters in the msticpyconfig.yaml file. This is read from the current directory or you can set an environment variable (MSTICPYCONFIG) pointing to its location.
To configure this file see the ConfigureNotebookEnvironment notebook