
위협 탐지 규칙의 종단 간 테스트를 위한 CLI 및 Go 프레임워크입니다. Datadog 및 Elastic Security와 같은 보안 플랫폼에서 공격 기술을 실행하고 알림을 확인합니다.
Threatest는 위협 탐지를 종단간(end-to-end)으로 테스트하기 위한 CLI 및 Go 프레임워크입니다.
Threatest를 사용하면 공격 기술을 **실행(detonate)**하고, 예상한 알림이 선호하는 보안 플랫폼에서 생성되었는지 확인할 수 있습니다.
발표 블로그 게시물 읽기: https://securitylabs.datadoghq.com/articles/threatest-end-to-end-testing-threat-detection/
**디토네이터(detonator)**는 공격 기술이 어떻게 그리고 어디서 실행되는지를 설명합니다.
지원되는 디토네이터:
**알림 매처(alert matcher)**는 예상된 알림이 트리거되었는지 확인할 수 있는 플랫폼별 통합입니다.
지원되는 알림 매처:
각 디토네이션에는 UUID가 할당됩니다. 이 UUID는 디토네이션에 반영되며, 일치하는 알림이 정확히 이 디토네이션에 해당하는지 확인하는 데 사용됩니다.
이 방식은 디토네이터에 따라 다릅니다. 예를 들어, Stratus Red Team과 AWS 디토네이터는 User-Agent에 UUID를 주입하고, SSH 디토네이터는 UUID를 포함하는 부모 프로세스를 사용합니다.
Threatest는 특정 스키마를 따르는 YAML로 작성된 테스트 시나리오를 실행할 수 있는 CLI를 제공합니다. 이 스키마를 편집기에서 구성하여 IDE 내 린팅 및 자동 완성 기능을 활용할 수 있습니다 (YAML 확장을 사용한 VSCode 문서 참조).
CLI를 바이너리 릴리스를 다운로드하거나 Homebrew를 통해 설치하세요:
brew tap datadog/threatest https://github.com/datadog/threatest
brew install datadog/threatest/threatest
샘플 사용법:
$ threatest lint scenarios.threatest.yaml
모든 6개 시나리오가 구문적으로 유효합니다.
# 로컬 디토네이션
$ threatest run local-scenarios.threatest.yaml
# SSH를 통한 원격 디토네이션
$ threatest run scenarios.threatest.yaml --ssh-host test-box --ssh-username vagrant
# 또는 환경 변수에서 SSH 매개변수 지정
$ export THREATEST_SSH_HOST=test-box
$ export THREATEST_SSH_USERNAME=vagrant
$ threatest run scenarios.threatest.yaml
샘플 시나리오 정의 파일
scenarios:
# SSH를 통한 원격 디토네이션
# 참고: SSH 구성은 --ssh-host, --ssh-username 및 --ssh-keyfile CLI 인수를 사용하여 제공됩니다.
- name: curl 메타데이터 서비스
detonate:
remoteDetonator:
commands: ["curl http://169.254.169.254 --connect-timeout 1"]
expectations:
- timeout: 1m
datadogSecuritySignal:
name: "네트워크 유틸리티가 클라우드 메타데이터 서비스에 접근함"
severity: 중간
scenarios:
# Stratus Red Team 디토네이션
# 참고: 실행하기 전에 관련 클라우드 공급자에 인증되어 있어야 합니다.
# 아래 예제는 수동으로 "stratus detonate aws.exfiltration.ec2-security-group-open-port-22-ingress"를 실행하는 것과 동일합니다.
- name: 보안 그룹을 인터넷에 개방
detonate:
stratusRedTeamDetonator:
attackTechnique: aws.exfiltration.ec2-security-group-open-port-22-ingress
expectations:
- timeout: 15m
datadogSecuritySignal:
name: "AWS 보안 그룹을 통해 전 세계에 잠재적 관리 포트 개방"
scenarios:
# AWS CLI 디토네이션
# 참고: 실행하기 전에 AWS에 인증되어 있어야 하며 AWS CLI가 설치되어 있어야 합니다.
- name: 보안 그룹을 인터넷에 개방
detonate:
awsCliDetonator:
script: |
set -e
# 설정
vpc=$(aws ec2 create-vpc --cidr-block 10.0.0.0/16 --query Vpc.VpcId --output text)
sg=$(aws ec2 create-security-group --group-name sample-sg --description "테스트 보안 그룹" --vpc-id $vpc --query GroupId --output text)
# 보안 그룹 개방
aws ec2 authorize-security-group-ingress --group-id $sg --protocol tcp --port 22 --cidr 0.0.0.0/0
# 정리
aws ec2 delete-security-group --group-id $sg
aws ec2 delete-vpc --vpc-id $vpc
expectations:
- timeout: 15m
datadogSecuritySignal:
name: "AWS 보안 그룹을 통해 전 세계에 잠재적 관리 포트 개방"
테스트 결과를 JSON 파일로 출력할 수 있습니다:
$ threatest run scenarios.threatest.yaml --output test-results.json
$ cat test-results.json
[
{
"description": "change user password",
"isSuccess": true,
"errorMessage": "",
"durationSeconds": 22.046627348,
"timeDetonated": "2022-11-15T22:26:14.182844+01:00"
},
{
"description": "adding an SSH key",
"isSuccess": true,
"errorMessage": "",
"durationSeconds": 23.604699625,
"timeDetonated": "2022-11-15T22:26:14.182832+01:00"
},
{
"description": "change user password",
"isSuccess": false,
"errorMessage": "At least one scenario failed:\n\nchange user password returned: change user password: 1 assertions did not pass\n =\u003e Did not find Datadog security signal 'bar'\n",
"durationSeconds": 3.505294235,
"timeDetonated": "2022-11-15T22:26:36.229349+01:00"
}
]
기본적으로 시나리오는 최대 5개의 병렬 처리로 실행됩니다. --parallelism 인수를 사용하여 이 설정을 늘릴 수 있습니다. 원격 SSH 디토네이터를 사용할 때는 각 실행 시나리오가 새로운 SSH 연결을 설정합니다.
전체 프로그래매틱 사용 예제는 예제를 참조하세요.
threatest := Threatest()
threatest.Scenario("AWS 콘솔 로그인").
WhenDetonating(StratusRedTeamTechnique("aws.initial-access.console-login-without-mfa")).
Expect(DatadogSecuritySignal("AWS Console login without MFA", WithSeverity("중간"))).
WithTimeout(15 * time.Minute)
assert.NoError(t, threatest.Run())
ssh, _ := NewSSHCommandExecutor("test-box", "", "")
threatest := Threatest()
threatest.Scenario("메타데이터 서비스에 curl").
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())