Threatest 是一个 CLI 和 Go 框架,用于端到端测试威胁检测规则。
Threatest is a CLI and Go framework for testing threat detection end-to-end.
Threatest allows you to detonate an attack technique, and verify that the telemetry you expect was generated in your favorite security platform.
Read the announcement blog post: https://securitylabs.datadoghq.com/articles/threatest-end-to-end-testing-threat-detection/
A detonator describes how and where an attack technique is executed.
Supported detonators:
An matcher is a platform-specific integration that can check if an expected telemetry object was created (for instance, if an alert was triggered), or widely search of any trace it can find.
Supported matchers:
Each detonation is assigned a UUID. This UUID is reflected in the detonation and used to ensure that the matched alert corresponds exactly to this detonation.
The way this is done depends on the detonator; for instance, Stratus Red Team and the AWS Detonator inject it in the user-agent; the SSH detonator uses a parent process containing the UUID.
In addition to asserting that an alert was generated, Threatest can discover telemetry correlated to a detonation. Discovery mode collects all matching objects and dumps them instead of asserting.
Discovery expectations use discover: true and an optional query: field. The `` marker can be used, it is substituted with the detonation UUID:
expectations:
- timeout: 5m
datadogLog:
query: "source:cloudtrail @http.useragent:**"
discover: trueIf no query: is provided, a default correlation query is used. Discovery mode skips cleanup.
Threatest comes with a CLI that you can use to run test scenarios described as YAML, following a specific schema. You can configure this schema in your editor to benefit from in-IDE linting and autocompletion (see documentation for VSCode using the YAML extension).
Install the CLI by downloading a binary release or with Homebrew:
brew tap datadog/threatest https://github.com/datadog/threatest
brew install datadog/threatest/threatestSample usage:
$ threatest lint scenarios.threatest.yaml
All 6 scenarios are syntaxically valid
# Local detonation
$ threatest run local-scenarios.threatest.yaml
# Remote detonation over SSH
$ threatest run scenarios.threatest.yaml --ssh-host test-box --ssh-username vagrant
# Alternatively, specify SSH parameters from environment variables
$ export THREATEST_SSH_HOST=test-box
$ export THREATEST_SSH_USERNAME=vagrant
$ threatest run scenarios.threatest.yamlSample scenario definition files
scenarios:
# Remote detonation over SSH
# Note: SSH configuration is provided using the --ssh-host, --ssh-username and --ssh-keyfile CLI arguments
- name: curl metadata service
detonate:
remoteDetonator:
commands: ["curl http://169.254.169.254 --connect-timeout 1"]
expectations:
- timeout: 1m
datadogSecuritySignal:
name: "Network utility accessed cloud metadata service"
severity: medium……You can output the test results to a JSON file:
…By default, scenarios are run with a maximum parallelism of 5. You can increase this setting using the --parallelism argument.
Note that when using remote SSH detonators, each scenario running establishes a new SSH connection.
See examples for complete programmatic usage example.
threatest := Threatest()
threatest.Scenario("AWS console login").
WhenDetonating(StratusRedTeamTechnique("aws.initial-access.console-login-without-mfa")).
Expect(DatadogSecuritySignal("AWS Console login without MFA", WithSeverity("medium"))).
WithTimeout(15 * time.Minute)
assert.NoError(t, threatest.Run())ssh, _ := NewSSHCommandExecutor("test-box", "", "")
threatest := Threatest()
threatest.Scenario("curl to metadata service").
WhenDetonating(NewCommandDetonator(ssh, "curl http://169.254.169.254 --connect-timeout 1")).
Expect(DatadogSecuritySignal("EC2 Instance Metadata Service Accessed via Network Utility"))
assert.NoError(t, threatest.Run())暂无开放 Issues,或尚未同步最近议题。