icon/x Created with Sketch.

Splunk Cookie Policy

We use our own and third-party cookies to provide you with a great online experience. We also use these cookies to improve our products and services, support our marketing campaigns, and advertise to you on our website and other websites. Some cookies may continue to collect information after you have left our website. Learn more (including how to update your settings) here.
Accept Cookie Policy

We are working on something new...

A Fresh New Splunkbase
We are designing a New Splunkbase to improve search and discoverability of apps. Check out our new and improved features like Categories and Collections. New Splunkbase is currently in preview mode, as it is under active development. We welcome you to navigate New Splunkbase and give us feedback.
Log4Shell Vulnerability: Information and guidance for you. Get resources.

Accept License Agreements

This app is provided by a third party and your right to use the app is in accordance with the license provided by that third-party licensor. Splunk is not responsible for any third-party apps and does not provide any warranty or support. If you have any questions, complaints or claims with respect to this app, please contact the licensor directly.

Thank You

Downloading Defender Advanced Hunting Query App by GoAhead
SHA256 checksum (defender-advanced-hunting-query-app-by-goahead_110.tgz) 976a27769abbc0be4921b92baa3ea2c8ab738afbfa8d1b46130efbb2466f650f
To install your download
For instructions specific to your download, click the Details tab after closing this window.

Flag As Inappropriate

splunk

Defender Advanced Hunting Query App by GoAhead

Overview
Details
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!
Developed by "Tatsuya Hasegawa" in 'GoAhead Inc'.

Enjoy deep dive hunting !

Defender Advanced Hunting Query App by GoAhead

Introduction

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!

Installation

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".

Usage

  1. defkqlg

    • GeneratingCommand for calling Microsoft Defender's AdvancedHunting or AdvancedQuery API.
    • Options
      • api (required): Choose "queries" or "hunting", "queries" means to access to AdvancedQuery API, "hunting" means to access to AdvancedHunting API.
      • kql (required): KQL query to run
    • Output field name
      • the same of field names from defender API result or "Defender_api_error" field only when unexpected error happens.
    • Example
      • ...| defkqlg api="queries" kql="DeviceProcessEvents | where DeviceId = 'xxxxxxxxx' | limit 10"
  2. defkqls

    • StreamingCommand for calling Microsoft Defender's AdvancedHunting or AdvancedQuery API.
    • Options
      • api (required): Choose "queries" or "hunting", "queries" means to access to AdvancedQuery API, "hunting" means to access to AdvancedHunting API.
      • primary_field (required): Splunk field used in where/filter KQL covered with `` and the field value matched to that of defender field in order to append the defender result.
      • kql (required): KQL query to run, the same field name in kql are automatically pass to this kql filtering block.
    • Output field name

      • "Defender_<Defender_field_name>" when API results are good and "Defender_api_error" field shows the API result status and errors.
    • "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

      • "==|>=|<=|>|<|=~|has_cs|has_any|has_all|contains_cs|contains|between|in~|in|endswith_cs|endswith|startswith_cs|startswith|hasprefix_cs|hasprefix|hassuffix_cs|hassuffix|has|!=|!~|!has_cs|!contains_cs|!contains|!between|!in~|!in|!endswith_cs|!endswith|!startswith_cs|!startswith|!hasprefix_cs|!hasprefix|!hassuffix_cs|!hassuffix|!has"
      • Only == or =~ is available for primary_field.
    • Example

      • | 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"

API Quotas Limit from Microsoft documents

Note. 2022.06.05, please refer to the following links for the further update.

  1. Queries explore and return data from the past 30 days.
  2. Results can return up to 100,000 rows.
  3. You can make up to 45 calls per minute per tenant.
  4. Queries are blocked if the tenant has reached 100% until after the next 15-minute cycle.
  5. If a single request runs for more than 10 minutes, it will time out and return an error.
  6. A 429 HTTP response code indicates that you've reached a quota, either by number of requests sent, or by allotted running time.

Microsoft Defender API reference

https://docs.microsoft.com/ja-jp/microsoft-365/security/defender/api-hello-world?view=o365-worldwide

https://docs.microsoft.com/ja-jp/microsoft-365/security/defender/api-supported?view=o365-worldwide

api-advanced-query
- old one in Microsoft Defender for Endpoint APIs which includes only "Schema", "Results" in the json response.

api-advanced-hunting
- new one in Microsoft 365 Defender APIs which includes "Schema", "Results" and "Stats" field in the json response.

Included 3rd party's additional import modules

None

Support

Splunk 8.x, this app codes are written in Python3.

License

LGPLv3

Release Note

  • 1.0.0

    • initial version, implemented defkqlg GeneratingCommand and defkqls StreamingCommand. (passed appinspect "private_app" criteria)
  • 1.1.0

    • improvement of defkqls StreamingCommand ,which much operators, primary_field option and a complex condition's conbination were implemented.
  • 1.1.1 and 1.1.2

    • update appIcon

Copyright

Copyright 2022 GoAhead Inc.

Release Notes

Version 1.1.0
June 7, 2022

improvement of defkqls StreamingCommand ,which much operators, primary_field option and a complex condition's conbination were implemented.


Subscribe Share

Are you a developer?

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.

Follow Us:
Splunk, Splunk>,Turn Data Into Doing, Data-to-Everything, and D2E are trademarks or registered trademarks of Splunk Inc. in the United States and other countries. All other brand names,product names,or trademarks belong to their respective owners.