Skip to content

Commit 032d74d

Browse files
committed
fix: adds WaitForInstancesToRegisterInSSM to ec2-enumerate-from-instance technique
1 parent a0c4124 commit 032d74d

File tree

1 file changed

+11
-3
lines changed
  • v2/internal/attacktechniques/aws/discovery/ec2-enumerate-from-instance

1 file changed

+11
-3
lines changed

v2/internal/attacktechniques/aws/discovery/ec2-enumerate-from-instance/main.go

+11-3
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@ import (
44
"context"
55
_ "embed"
66
"errors"
7+
"fmt"
8+
"log"
9+
"strings"
10+
"time"
11+
712
"github.com/aws/aws-sdk-go-v2/aws"
813
"github.com/aws/aws-sdk-go-v2/service/ssm"
14+
"github.com/datadog/stratus-red-team/v2/internal/utils"
915
"github.com/datadog/stratus-red-team/v2/pkg/stratus"
1016
"github.com/datadog/stratus-red-team/v2/pkg/stratus/mitreattack"
1117
"github.com/datadog/stratus-red-team/v2/pkg/stratus/useragent"
12-
"log"
13-
"strings"
14-
"time"
1518
)
1619

1720
//go:embed main.tf
@@ -67,6 +70,11 @@ func detonate(params map[string]string, providers stratus.CloudProviders) error
6770
awsProvider := providers.AWS()
6871
ssmClient := ssm.NewFromConfig(awsProvider.GetConnection())
6972
instanceId := params["instance_id"]
73+
74+
if err := utils.WaitForInstancesToRegisterInSSM(ssmClient, []string{instanceId}); err != nil {
75+
return fmt.Errorf("failed to wait for instances to register in SSM: %v", err)
76+
}
77+
7078
commands := []string{
7179
"export AWS_EXECUTION_ENV=" + useragent.GetStratusUserAgentForUUID(awsProvider.UniqueCorrelationId), // propagate detonation UID
7280
"aws sts get-caller-identity || true", // Note: we need the || true to ensure the command exits with status 0, even if the instance role doesn't have the permission

0 commit comments

Comments
 (0)