Defender Advanced Hunting Query App by GoAhead is an API wrapper tool for Microsoft Defender Advanced Hunting.
The Defender Advanced Hunting uses Kusto Query Language (KQL) and the KQL is passed as kql="" to defkqlg or defkqls custom search command.
defkqls StreamingCommand has an unique KQL converter for reducing the query amount against the API quotas limit!
The credential set of tenantId, appId and appSecret for getting Azure AD Token are needed to utilize this App.
1. Prepare credential set of tenantId, appId and appSecret on Azure AD (See API reference below). This app needs AdvancedQuery.Read.All for Defender for Endpoint API or AdvancedHunting.Read.All for Defender 365 API.
2. Install this App package
3. Set up the credential on the App Setup View. The credentials are encrypted and stored in Secret storage.
Please set your own <tenantId>&<appId>&<appSecret> to Password form.
4. Restarting splunk search head instance may be possibly needed for activating these custom search commands.
5. App Install user needs "admin_all_objects" privilege and Splunk search users need "list_storage_passwords" privilege in order to utilize "Secret storage".
...| defkqlg api="queries" kql="DeviceProcessEvents | where DeviceId = 'xxxxxxxxx' | limit 10"
Output field name
"or" is appended between the passed event values and your input KQL is replaced into the final KQL. It makes the API amount to only one query per this command execution.
Triggered scalar operators to modify your KQL
| makeresults | eval pcname="xxxxxxxx" | defkqls api=queries primary_field=pcname kql="DeviceProcessEvents | where DeviceName == `pcname` | limit 10" | table _time pcname Defender_*
source="pcname_id_timestamp_sample.csv" | defkqls api=queries primary_field=id kql="DeviceProcessEvents | where Timestamp > datetime(`timestamp`) | filter DeviceName =~ `pcname` and DeviceId == `id` | limit 10" | table _time pcname Defender*
source="src_dst_sample.csv" | defkqls api=queries primary_field=srcip kql="DeviceNetworkEvents | where LocalIP == `srcip` or RemoteIP == `dstip` and InitiatingProcessFileName has_cs 'chrome' | project Timestamp,LocalIP,RemoteIP,InitiatingProcessCommandLine,InitiatingProcessFolderPath,InitiatingProcessMD5 | limit 5"
Command usages are also described in searchbnf.conf, thus you can see it on search window by writing the command name on.
The command exception and final KQL query per execution will be dumped in "search.log" or "%SPLUNK_HOME%/var/log/defender_advanced_hunting_query.log".
defkqls command is still beta thus please kindly utilize defkqlg instead at first if you have a trouble on defkqls.
Because defkqlg command is just an API rapper command and we don't touch the input KQL content.
Note. Please use single quote or escaped double quote inside your kql query because simple double quote is interpreted as a part of splunk SPL.
- OK: kql="brabra | where Protocol == \"NTLM\" | fugafuga"
- OK: kql="brabra | where Protocol == 'NTLM' | fugafuga"
NG: kql="brabra | where Protocol == "NTLM" | fugafuga"
Note. 2022.06.05, please refer to the following links for the further update.
429HTTP response code indicates that you've reached a quota, either by number of requests sent, or by allotted running time.
- old one in Microsoft Defender for Endpoint APIs which includes only "Schema", "Results" in the json response.
- new one in Microsoft 365 Defender APIs which includes "Schema", "Results" and "Stats" field in the json response.
Splunk 8.x, this app codes are written in Python3.
1.1.1 and 1.1.2
Copyright 2022 GoAhead Inc.
improvement of defkqls StreamingCommand ,which much operators, primary_field option and a complex condition's conbination were implemented.
As a Splunkbase app developer, you will have access to all Splunk development resources and receive a 10GB license to build an app that will help solve use cases for customers all over the world. Splunkbase has 1000+ apps from Splunk, our partners and our community. Find an app for most any data source and user need, or simply create your own with help from our developer portal.