msticpy

Microsoft Threat Intelligence Security Tools

https://github.com/microsoft/msticpy

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (16.0%) to scientific vocabulary

Keywords from Contributors

cryptocurrencies graph-generation mesh interactive hydrology multi-agents application agents data-profiling dynamic
Last synced: 6 months ago · JSON representation

Repository

Microsoft Threat Intelligence Security Tools

Basic Info
  • Host: GitHub
  • Owner: microsoft
  • License: other
  • Language: Python
  • Default Branch: main
  • Size: 77.6 MB
Statistics
  • Stars: 1,891
  • Watchers: 53
  • Forks: 333
  • Open Issues: 10
  • Releases: 93
Created about 7 years ago · Last pushed 7 months ago
Metadata Files
Readme Contributing License Citation Security

README.md

MSTIC Jupyter and Python Security Tools

GitHub Actions build Azure Pipelines build Downloads BlackHat Arsenal 2020

Microsoft Threat Intelligence Python Security Tools.

msticpy is a library for InfoSec investigation and hunting in Jupyter Notebooks. It includes functionality to:

  • query log data from multiple sources
  • enrich the data with Threat Intelligence, geolocations and Azure resource data
  • extract Indicators of Activity (IoA) from logs and unpack encoded data
  • perform sophisticated analysis such as anomalous session detection and time series decomposition
  • visualize data using interactive timelines, process trees and multi-dimensional Morph Charts

It also includes some time-saving notebook tools such as widgets to set query time boundaries, select and display items from lists, and configure the notebook environment.

Timeline

The msticpy package was initially developed to support Jupyter Notebooks authoring for Azure Sentinel. While Azure Sentinel is still a big focus of our work, we are extending the data query/acquisition components to pull log data from other sources (currently Splunk, Microsoft Defender for Endpoint and Microsoft Graph are supported but we are actively working on support for data from other SIEM platforms). Most of the components can also be used with data from any source. Pandas DataFrames are used as the ubiquitous input and output format of almost all components. There is also a data provider to make it easy to and process data from local CSV files and pickled DataFrames.

The package addresses three central needs for security investigators and hunters:

  • Acquiring and enriching data
  • Analyzing data
  • Visualizing data

We welcome feedback, bug reports, suggestions for new features and contributions.

Installing

For core install:

pip install msticpy

If you are using MSTICPy with Azure Sentinel you should install with the "azsentinel" extra package:

pip install msticpy[azsentinel]

or for the latest dev build

pip install git+https://github.com/microsoft/msticpy

Upgrading

To upgrade msticpy to the latest public non-beta release, run:

pip install --upgrade msticpy

Note it is good practice to copy your msticpyconfig.yaml and store it on your disk but outside of your msticpy folder, referencing it in an environment variable. This prevents you from losing your configurations every time you update your msticpy installation.

Documentation

Full documentation is at ReadTheDocs

Sample notebooks for many of the modules are in the docs/notebooks folder and accompanying notebooks.

You can also browse through the sample notebooks referenced at the end of this document to see some of the functionality used in context. You can play with some of the package functions in this interactive demo on mybinder.org.

Binder


Log Data Acquisition

QueryProvider is an extensible query library targeting Azure Sentinel/Log Analytics, Splunk, OData and other log data sources. It also has special support for Mordor data sets and using local data.

Built-in parameterized queries allow complex queries to be run from a single function call. Add your own queries using a simple YAML schema.

Data Queries Notebook

Data Enrichment

Threat Intelligence providers

The TILookup class can lookup IoCs across multiple TI providers. built-in providers include AlienVault OTX, IBM XForce, VirusTotal and Azure Sentinel.

The input can be a single IoC observable or a pandas DataFrame containing multiple observables. Depending on the provider, you may require an account and an API key. Some providers also enforce throttling (especially for free tiers), which might affect performing bulk lookups.

TIProviders and TILookup Usage Notebook

GeoLocation Data

The GeoIP lookup classes allow you to match the geo-locations of IP addresses using either:

Folium map

GeoIP Lookup and GeoIP Notebook

Azure Resource Data, Storage and Azure Sentinel API

The AzureData module contains functionality for enriching data regarding Azure host details with additional host details exposed via the Azure API. The AzureSentinel module allows you to query incidents, retrieve detector and hunting queries. AzureBlogStorage lets you read and write data from blob storage.

Azure Resource APIs, Azure Sentinel APIs, Azure Storage

Security Analysis

This subpackage contains several modules helpful for working on security investigations and hunting:

Anomalous Sequence Detection

Detect unusual sequences of events in your Office, Active Directory or other log data. You can extract sessions (e.g. activity initiated by the same account) and identify and visualize unusual sequences of activity. For example, detecting an attacker setting a mail forwarding rule on someone's mailbox.

Anomalous Sessions and Anomalous Sequence Notebook

Time Series Analysis

Time series analysis allows you to identify unusual patterns in your log data taking into account normal seasonal variations (e.g. the regular ebb and flow of events over hours of the day, days of the week, etc.). Using both analysis and visualization highlights unusual traffic flows or event activity for any data set.

Time Series anomalies

Time Series

Visualization

Event Timelines

Display any log events on an interactive timeline. Using the Bokeh Visualization Library the timeline control enables you to visualize one or more event streams, interactively zoom into specific time slots and view event details for plotted events.

Timeline

Timeline and Timeline Notebook

Process Trees

The process tree functionality has two main components:

  • Process Tree creation - taking a process creation log from a host and building the parent-child relationships between processes in the data set.
  • Process Tree visualization - this takes the processed output displays an interactive process tree using Bokeh plots.

There are a set of utility functions to extract individual and partial trees from the processed data set.

Process Tree

Process Tree and Process Tree Notebook

Data Manipulation and Utility functions

Pivot Functions

Lets you use MSTICPy functionality in an "entity-centric" way. All functions, queries and lookups that relate to a particular entity type (e.g. Host, IpAddress, Url) are collected together as methods of that entity class. So, if you want to do things with an IP address, just load the IpAddress entity and browse its methods.

Pivot Functions and Pivot Functions Notebook

base64unpack

Base64 and archive (gz, zip, tar) extractor. It will try to identify any base64 encoded strings and try decode them. If the result looks like one of the supported archive types it will unpack the contents. The results of each decode/unpack are rechecked for further base64 content and up to a specified depth.

Base64 Decoding and Base64Unpack Notebook

iocextract

Uses regular expressions to look for Indicator of Compromise (IoC) patterns - IP Addresses, URLs, DNS domains, Hashes, file paths. Input can be a single string or a pandas dataframe.

IoC Extraction and IoCExtract Notebook

eventcluster (experimental)

This module is intended to be used to summarize large numbers of events into clusters of different patterns. High volume repeating events can often make it difficult to see unique and interesting items.

Clustering

This is an unsupervised learning module implemented using SciKit Learn DBScan.

Event Clustering and Event Clustering Notebook

auditdextract

Module to load and decode Linux audit logs. It collapses messages sharing the same message ID into single events, decodes hex-encoded data fields and performs some event-specific formatting and normalization (e.g. for process start events it will re-assemble the process command line arguments into a single string).

syslog_utils

Module to support an investigation of a Linux host with only syslog logging enabled. This includes functions for collating host data, clustering logon events and detecting user sessions containing suspicious activity.

cmd_line

A module to support the detection of known malicious command line activity or suspicious patterns of command line activity.

domain_utils

A module to support investigation of domain names and URLs with functions to validate a domain name and screenshot a URL.

Notebook widgets

These are built from the Jupyter ipywidgets collection and group common functionality useful in InfoSec tasks such as list pickers, query time boundary settings and event display into an easy-to-use format.

Time span Widget

Alert browser


Example MSTICPy notebooks

MSTICPy Notebooks

More Notebooks on Azure Sentinel Notebooks GitHub

Azure Sentinel Notebooks

Example notebooks:

View directly on GitHub or copy and paste the link into nbviewer.org

Notebook examples with saved data

See the following notebooks for more examples of the use of this package in practice:

Supported Platforms and Packages


Contributing

For (brief) developer guidelines, see this wiki article Contributor Guidelines

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Owner

  • Name: Microsoft
  • Login: microsoft
  • Kind: organization
  • Email: opensource@microsoft.com
  • Location: Redmond, WA

Open source projects and samples from Microsoft

GitHub Events

Total
  • Create event: 23
  • Release event: 4
  • Issues event: 30
  • Watch event: 108
  • Delete event: 14
  • Issue comment event: 77
  • Push event: 99
  • Pull request review comment event: 42
  • Pull request review event: 74
  • Pull request event: 78
  • Fork event: 18
Last Year
  • Create event: 23
  • Release event: 4
  • Issues event: 30
  • Watch event: 108
  • Delete event: 14
  • Issue comment event: 77
  • Push event: 99
  • Pull request review comment event: 42
  • Pull request review event: 74
  • Pull request event: 78
  • Fork event: 18

Committers

Last synced: 10 months ago

All Time
  • Total Commits: 1,065
  • Total Committers: 66
  • Avg Commits per committer: 16.136
  • Development Distribution Score (DDS): 0.454
Past Year
  • Commits: 72
  • Committers: 12
  • Avg Commits per committer: 6.0
  • Development Distribution Score (DDS): 0.417
Top Committers
Name Email Commits
Ian Hellen i****e@m****m 582
Pete Bryan p****n@m****m 131
Pete Bryan p****n@m****m 94
FlorianBracq 9****q 52
dependabot[bot] 4****] 34
ashwin-patil a****l@m****m 23
florian.bracq f****q@x****m 14
Thomas Roccia t****a@g****m 12
hackeT 4****a 9
Anthony Shaw a****w@g****m 8
Andres Ramirez a****r@g****m 8
Paul Reid p****d@m****m 8
Liam Kirton l****n@m****m 7
vx3r v****r@1****r 6
ccianelli22 7****2 5
pensivepaddle 1****e 5
Julien j****4 3
luisf l****e@g****m 3
Joey Dreijer j****r@d****m 3
Grant V g****v@g****m 3
Joey Dreijer j****r@s****m 2
Rajamani R r****l@a****m 2
2*yo y****n@l****o 2
Darío Hereñú m****a@g****m 2
Microsoft Open Source m****e 2
ctoma73 c****3@g****m 2
dependabot-preview[bot] 2****] 2
karishma-dixit 6****t 2
Nicolas Bareil n****l@g****m 2
Bruno P. Kinoshita k****w 1
and 36 more...
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 98
  • Total pull requests: 230
  • Average time to close issues: 11 months
  • Average time to close pull requests: about 1 month
  • Total issue authors: 37
  • Total pull request authors: 35
  • Average comments per issue: 1.58
  • Average comments per pull request: 1.24
  • Merged pull requests: 185
  • Bot issues: 1
  • Bot pull requests: 38
Past Year
  • Issues: 11
  • Pull requests: 65
  • Average time to close issues: 13 days
  • Average time to close pull requests: 11 days
  • Issue authors: 5
  • Pull request authors: 7
  • Average comments per issue: 1.64
  • Average comments per pull request: 1.06
  • Merged pull requests: 54
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • ianhelle (20)
  • petebryan (12)
  • Cyb3r-Monk (8)
  • JPvRiel (7)
  • titanicshark (5)
  • ashwin-patil (4)
  • Tatsuya-hasegawa (3)
  • BWC-TomW (3)
  • pensivepaddle (2)
  • PaulWood11 (2)
  • FlorianBracq (2)
  • cindraw (2)
  • juju4 (2)
  • glwallum (2)
  • raggadhub (1)
Pull Request Authors
  • ianhelle (98)
  • dependabot[bot] (41)
  • FlorianBracq (37)
  • vx3r (14)
  • Tatsuya-hasegawa (14)
  • petebryan (7)
  • raj-axe (6)
  • d3vzer0 (5)
  • juju4 (5)
  • ccianelli22 (3)
  • ashwin-patil (3)
  • BWC-TomW (2)
  • ryan-detect-dot-dev (2)
  • rrevuelta (2)
  • pcoccoli (2)
Top Labels
Issue Labels
enhancement (34) bug (32) accepted (13) hackmonth2023 (9) investigate (9) good first issue (7) ti-provider (4) help wanted (4) build_break (2) wontfix (2) dependencies (2) high_severity (1) MSTICPy2.0 (1)
Pull Request Labels
dependencies (41) bug (9) build_break (4) enhancement (2)

Packages

  • Total packages: 2
  • Total downloads:
    • pypi 43,133 last-month
  • Total dependent packages: 1
    (may contain duplicates)
  • Total dependent repositories: 16
    (may contain duplicates)
  • Total versions: 167
  • Total maintainers: 4
pypi.org: msticpy

MSTIC Security Tools

  • Versions: 90
  • Dependent Packages: 1
  • Dependent Repositories: 16
  • Downloads: 43,133 Last month
  • Docker Downloads: 0
Rankings
Docker downloads count: 1.4%
Stargazers count: 1.7%
Downloads: 2.2%
Average: 2.8%
Forks count: 3.2%
Dependent repos count: 3.6%
Dependent packages count: 4.8%
Maintainers (4)
Last synced: 6 months ago
proxy.golang.org: github.com/microsoft/msticpy
  • Versions: 77
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 6.5%
Average: 6.7%
Dependent repos count: 7.0%
Last synced: over 1 year ago

Dependencies

docs/requirements.txt pypi
  • attrs >=18.2.0
  • cryptography *
  • deprecated >=1.2.4
  • docutils <0.18.0
  • httpx >=0.21
  • ipython >=7.1.1
  • jinja2 <3.1.0
  • numpy >=1.15.4
  • pandas >=1.1.5
  • python-dateutil >=2.8.1
  • pytz >=2019.2
  • pyyaml >=3.13
  • readthedocs-sphinx-ext ==2.1.8
  • seed_intersphinx_mapping *
  • sphinx ==5.0.2
  • sphinx-rtd-theme ==1.0.0
  • typing-extensions >=4.2.0
.github/workflows/codeql.yml actions
  • actions/checkout v3 composite
  • github/codeql-action/analyze v2 composite
  • github/codeql-action/autobuild v2 composite
  • github/codeql-action/init v2 composite
.github/workflows/python-package.yml actions
  • actions/cache v3 composite
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
  • actions/upload-artifact v3 composite
  • dacbd/create-issue-action v1 composite
.github/workflows/python-publish.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v3 composite
  • pypa/gh-action-pypi-publish v1.5.1 composite
.github/workflows/tweet.yml actions
  • ethomson/send-tweet-action v1 composite
.devcontainer/Dockerfile docker
  • mcr.microsoft.com/vscode/devcontainers/anaconda latest build
pyproject.toml pypi
requirements-all.txt pypi
  • KqlmagicCustom >=0.1.114.post22
  • attrs >=18.2.0
  • azure-common >=1.1.18
  • azure-core >=1.24.0
  • azure-identity >=1.10.0
  • azure-keyvault-secrets >=4.0.0
  • azure-kusto-data >=4.0.0,<=5.0.0
  • azure-mgmt-compute >=4.6.2
  • azure-mgmt-core >=1.2.1
  • azure-mgmt-keyvault >=2.0.0
  • azure-mgmt-monitor >=2.0.0
  • azure-mgmt-network >=2.7.0
  • azure-mgmt-resource >=16.1.0
  • azure-mgmt-resourcegraph >=8.0.0
  • azure-mgmt-subscription >=3.0.0
  • azure-monitor-query >=1.0.0,<=2.0.0
  • azure-storage-blob >=12.5.0
  • beautifulsoup4 >=4.0.0
  • bokeh >=1.4.0,<4.0.0
  • cryptography >=3.1
  • deprecated >=1.2.4
  • dnspython >=2.0.0,<3.0.0
  • folium >=0.9.0
  • geoip2 >=2.9.0
  • html5lib *
  • httpx >=0.23.0,<1.0.0
  • ipython >=7.23.1
  • ipython >=7.1.1
  • ipywidgets >=7.4.2,<9.0.0
  • keyring >=13.2.1
  • lxml >=4.6.5
  • matplotlib >=3.0.0
  • mo-sql-parsing >=8,<9.0.0
  • msal >=1.12.0
  • msal_extensions >=0.3.0
  • msrest >=0.6.0
  • msrestazure >=0.6.0
  • nest_asyncio >=1.4.0
  • networkx >=2.2
  • numpy >=1.15.4
  • openpyxl >=3.0
  • pandas >=1.4.0,<3.0.0
  • panel >=0.14.4
  • passivetotal >=2.5.3
  • pydantic >=1.8.0,<3.0.0
  • pygments >=2.0.0
  • pyjwt >=2.3.0
  • python-dateutil >=2.8.1
  • pytz >=2019.2
  • pyyaml >=3.13
  • scikit-learn >=1.0.0
  • scipy >=1.1.0
  • setuptools >=40.6.3
  • splunk-sdk >=1.6.0
  • statsmodels >=0.11.1
  • sumologic-sdk >=0.1.11
  • tldextract >=2.2.2
  • tqdm >=4.36.1
  • typing-extensions >=4.2.0
  • urllib3 >=1.23
  • vt-graph-api >=2.0
  • vt-py >=0.6.1
requirements-dev.txt pypi
  • aiohttp >=3.7.4 development
  • async-cache >=1.1.1 development
  • bandit >=1.7.0 development
  • beautifulsoup4 >=4.0.0 development
  • black >=20.8b1 development
  • coverage >=5.5 development
  • docutils <0.20.0 development
  • filelock >=3.0.0 development
  • flake8 >=3.8.4 development
  • isort >=5.10.1 development
  • jsonschema >=4.17.3 development
  • markdown >=3.3.4 development
  • mccabe >=0.6.1 development
  • mypy >=0.812 development
  • nbconvert >=6.1.0 development
  • nbdime >=2.1.0 development
  • pandas >=1.4.0,<3.0.0 development
  • pep8 >=1.7.1 development
  • pep8-naming >=0.10.0 development
  • pipreqs >=0.4.9 development
  • pre-commit >=2.7.1 development
  • pycodestyle >=2.6.0 development
  • pydocstyle >=6.0.0 development
  • pyflakes >=2.2.0 development
  • pygeohash >=1.2.0 development
  • pylint >=2.5.3 development
  • pyroma >=3.1 development
  • pytest >=5.0.1 development
  • pytest-check >=1.0.1 development
  • pytest-cov >=2.11.1 development
  • pytest-xdist >=2.5.0 development
  • readthedocs-sphinx-ext ==2.2.2 development
  • responses >=0.13.2 development
  • respx >=0.20.1 development
  • sphinx >=5.0.1 development
  • sphinx-rtd-theme >=1.0.0 development
  • types-attrs >=19.0.0 development
requirements.txt pypi
  • attrs >=18.2.0
  • azure-common >=1.1.18
  • azure-core >=1.24.0
  • azure-identity >=1.10.0
  • azure-keyvault-secrets >=4.0.0
  • azure-kusto-data >=4.0.0,<=5.0.0
  • azure-mgmt-keyvault >=2.0.0
  • azure-mgmt-subscription >=3.0.0
  • azure-monitor-query >=1.0.0,<=2.0.0
  • beautifulsoup4 >=4.0.0
  • bokeh >=1.4.0,<4.0.0
  • cryptography >=3.1
  • deprecated >=1.2.4
  • dnspython >=2.0.0,<3.0.0
  • folium >=0.9.0
  • geoip2 >=2.9.0
  • html5lib *
  • httpx >=0.23.0,<1.0.0
  • ipython >=7.1.1
  • ipython >=7.23.1
  • ipywidgets >=7.4.2,<9.0.0
  • keyring >=13.2.1
  • lxml >=4.6.5
  • msal >=1.12.0
  • msal_extensions >=0.3.0
  • msrest >=0.6.0
  • msrestazure >=0.6.0
  • nest_asyncio >=1.4.0
  • networkx >=2.2
  • numpy >=1.15.4
  • pandas >=1.4.0,<3.0.0
  • pydantic >=1.8.0,<3.0.0
  • pygments >=2.0.0
  • pyjwt >=2.3.0
  • python-dateutil >=2.8.1
  • pytz >=2019.2
  • pyyaml >=3.13
  • setuptools >=40.6.3
  • tldextract >=2.2.2
  • tqdm >=4.36.1
  • typing-extensions >=4.2.0
  • urllib3 >=1.23
setup.py pypi