Path: blob/master/scenario-notebooks/Guided Investigation - MDE Webshell Alerts.ipynb
3250 views
Guided Webshell Investigation - MDE Microsoft Sentinel Enrichments
Notebook Version: 1.0
Python Version: Python 3.6
Data Sources Required: MDE SecurityAlert, W3CIIS Log (or similar web logging)
This notebook investigates Microsoft Defender for Endpoint (MDE) webshell alerts. The notebook will guide you through steps to collect MDE alerts for webshell activity and link them to server access logs to identify potential attackers.
Configuration Required!
This Notebook presumes you have Microsoft Sentinel Workspace settings configured in a config file. If you do not have this in place please read the docs and use this notebook to test.
How to use:
This notebook provides a step-by-step investigation to understand MDE webshell alerts on your server. While our example uses IIS logging this notebook can be converted to support any web log type.
After congiuration you can investigate two scenarios, a webshell file alert or a webshell command execution alert. For each of these we will need to retrieve different data, the notebook contains branching execution at Step 3 to enable this.
Below you'll find a more detailed description of the two types of investigation
Shell File Alert
This alert type will fire when a file that is suspected to be a webshell appears on disk. For this investigation we will start with a known filename that is a suspected shell (e.g. Setconfigure.aspx) and we will try to understand how this webshell was placed on the server.
Shell Command Execution Alert
This alert type will fire when a command is executed on your web server that is suspicious. For this investigation we start with the command line that was executed and the time window that execution took place.
For both of the above alert types this notebook will allow you to find the following information:
- The attacker IP
- The attacker User Agent
- The website name the attacker interacted with
- The location of the shell on your server
Once we have that information this notebook will allow you to investigate the attacker IP, User Agent or both to discover:
- The files the attacker accessed prior to the installation of the shell
- The first time the attacker accessed your server
Notebook Initialization
This 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.
Before you continue!
Now it's time to select which type of investigation you would like to try. Above we have provided a summary of the high-level alert types present on your server, if the above table is blank no alerts were found.
If the table is empty, this notebook has no alerts to work with and will produce errors in subsequent cells.
If you have alerts you have a couple of different options.
You can click the links to jump to the start of the investigation.
Shell file alert Investigation: If you would like to conduct an investigation into an ASPX file that has been detected by Microsoft Defender ATP please run the code block beneath "Begin File Investigation"
Shell command alert Investigation: If you would like to conduct an investigation into suspicious command execution on your web server please run the code block below "Begin Command Investigation"
Step 3: Begin File Investigation
We can now begin our investigation into a webshell file that has been placed on a system in your network. We'll start by collecting relevant events from MDE.
Step 3: Begin Command Investigation
To begin the investigation into a command that has been executed by a webshell on your network, we will begin by collecting MDE data.