Skip to content

Commit 9e42b53

Browse files
authored
Merge pull request #104 from sethsec/main
v1.16.0 - Addes multiple resource types to resource-trusts command thanks to @edops973
2 parents b28ed6a + 0e7b006 commit 9e42b53

24 files changed

+1143
-244
lines changed

Makefile

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,28 +32,34 @@ release: clean
3232
mkdir -p ./cloudfox
3333

3434
GOOS=windows GOARCH=amd64 go build -o ./cloudfox/cloudfox.exe .
35-
zip ./cloudfox/cloudfox-windows-amd64.zip ./cloudfox/cloudfox.exe
36-
rm -rf ./cloudfox/cloudfox.exe
35+
sha1sum ./cloudfox/cloudfox.exe > ./cloudfox/sha1sum.txt
36+
zip ./cloudfox/cloudfox-windows-amd64.zip ./cloudfox/cloudfox.exe ./cloudfox/sha1sum.txt
37+
rm -rf ./cloudfox/cloudfox.exe ./cloudfox/sha1sum.txt
3738

3839
GOOS=linux GOARCH=amd64 go build -o ./cloudfox/cloudfox .
39-
zip ./cloudfox/cloudfox-linux-amd64.zip ./cloudfox/cloudfox .
40-
rm -rf ./cloudfox/cloudfox
40+
sha1sum ./cloudfox/cloudfox > ./cloudfox/sha1sum.txt
41+
zip ./cloudfox/cloudfox-linux-amd64.zip ./cloudfox/cloudfox ./cloudfox/sha1sum.txt
42+
rm -rf ./cloudfox/cloudfox ./cloudfox/sha1sum.txt
4143

4244
GOOS=linux GOARCH=386 go build -o ./cloudfox/cloudfox .
43-
zip ./cloudfox/cloudfox-linux-386.zip ./cloudfox/cloudfox .
44-
rm -rf ./cloudfox/cloudfox
45+
sha1sum ./cloudfox/cloudfox > ./cloudfox/sha1sum.txt
46+
zip ./cloudfox/cloudfox-linux-386.zip ./cloudfox/cloudfox ./cloudfox/sha1sum.txt
47+
rm -rf ./cloudfox/cloudfox ./cloudfox/sha1sum.txt
4548

4649
GOOS=linux GOARCH=arm64 go build -o ./cloudfox/cloudfox .
47-
zip ./cloudfox/cloudfox-linux-arm64.zip ./cloudfox/cloudfox .
48-
rm -rf ./cloudfox/cloudfox
50+
sha1sum ./cloudfox/cloudfox > ./cloudfox/sha1sum.txt
51+
zip ./cloudfox/cloudfox-linux-arm64.zip ./cloudfox/cloudfox ./cloudfox/sha1sum.txt
52+
rm -rf ./cloudfox/cloudfox ./cloudfox/sha1sum.txt
4953

5054
GOOS=darwin GOARCH=amd64 go build -o ./cloudfox/cloudfox .
51-
zip ./cloudfox/cloudfox-macos-amd64.zip ./cloudfox/cloudfox
52-
rm -rf ./cloudfox/cloudfox
55+
sha1sum ./cloudfox/cloudfox > ./cloudfox/sha1sum.txt
56+
zip ./cloudfox/cloudfox-macos-amd64.zip ./cloudfox/cloudfox ./cloudfox/sha1sum.txt
57+
rm -rf ./cloudfox/cloudfox ./cloudfox/sha1sum.txt
5358

5459
GOOS=darwin GOARCH=arm64 go build -o ./cloudfox/cloudfox .
55-
zip ./cloudfox/cloudfox-macos-arm64.zip ./cloudfox/cloudfox
56-
rm -rf ./cloudfox/cloudfox
60+
sha1sum ./cloudfox/cloudfox > ./cloudfox/sha1sum.txt
61+
zip ./cloudfox/cloudfox-macos-arm64.zip ./cloudfox/cloudfox ./cloudfox/sha1sum.txt
62+
rm -rf ./cloudfox/cloudfox ./cloudfox/sha1sum.txt
5763

5864
clean:
5965
rm -rf ./cloudfox

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ Additional policy notes (as of 09/2022):
133133
| AWS | [pmapper](https://github.com/BishopFox/cloudfox/wiki/AWS-Commands#pmapper) | Looks for pmapper data stored on the local filesystem, [in the locations defined here](https://github.com/nccgroup/PMapper/wiki/Frequently-Asked-Questions#where-does-pmapper-store-its-data). If pmapper data has been found (you already ran `pmapper graph create`), then this command will use this data to build a graph in cloudfox memory let you know who can privesc to admin.
134134
| AWS | [principals](https://github.com/BishopFox/cloudfox/wiki/AWS-Commands#principals) | Enumerates IAM users and Roles so you have the data at your fingertips. |
135135
| AWS | [ram](https://github.com/BishopFox/cloudfox/wiki/AWS-Commands#ram) | List all resources in this account that are shared with other accounts, or resources from other accounts that are shared with this account. Useful for cross-account attack paths. |
136-
| AWS | [resource-trusts](https://github.com/BishopFox/cloudfox/wiki/AWS-Commands#resource-trusts) | Looks through multiple services that support resource policies and helps you find any overly permissive resource trusts.|
136+
| AWS | [resource-trusts](https://github.com/BishopFox/cloudfox/wiki/AWS-Commands#resource-trusts) | Looks through multiple services that support resource policies and helps you find any overly permissive resource trusts. KMS is supported but disabled by default. To include KMS resource policies in the output, add this flag to the command: `cloudfox aws resource-trusts --include-kms`.|
137137
| AWS | [role-trusts](https://github.com/BishopFox/cloudfox/wiki/AWS-Commands#role-trusts) | Enumerates IAM role trust policies so you can look for overly permissive role trusts or find roles that trust a specific service. |
138138
| AWS | [route53](https://github.com/BishopFox/cloudfox/wiki/AWS-Commands#route53) | Enumerate all records from all route53 managed zones. Use this for application and service enumeration. |
139139
| AWS | [secrets](https://github.com/BishopFox/cloudfox/wiki/AWS-Commands#secrets) | List secrets from SecretsManager and SSM. Look for interesting secrets in the list and then see who has access to them using use `cloudfox iam-simulator` and/or `pmapper`. |

aws/ecs-tasks.go

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ type MappedECSTask struct {
5050
Cluster string
5151
TaskDefinitionName string
5252
TaskDefinitionContent string
53+
ContainerName string
5354
LaunchType string
5455
ID string
5556
ExternalIP string
@@ -145,6 +146,7 @@ func (m *ECSTasksModule) printECSTaskData(outputDirectory string, dataReceiver c
145146
"Account",
146147
"Cluster",
147148
"TaskDefinition",
149+
"ContainerName",
148150
"LaunchType",
149151
"ID",
150152
"External IP",
@@ -171,6 +173,7 @@ func (m *ECSTasksModule) printECSTaskData(outputDirectory string, dataReceiver c
171173
"Account",
172174
"Cluster",
173175
"TaskDefinition",
176+
"ContainerName",
174177
"LaunchType",
175178
"ID",
176179
"External IP",
@@ -184,6 +187,7 @@ func (m *ECSTasksModule) printECSTaskData(outputDirectory string, dataReceiver c
184187
tableCols = []string{
185188
"Cluster",
186189
"TaskDefinition",
190+
"ContainerName",
187191
"LaunchType",
188192
"External IP",
189193
"Internal IP",
@@ -206,6 +210,7 @@ func (m *ECSTasksModule) printECSTaskData(outputDirectory string, dataReceiver c
206210
aws.ToString(m.Caller.Account),
207211
ecsTask.Cluster,
208212
ecsTask.TaskDefinitionName,
213+
ecsTask.ContainerName,
209214
ecsTask.LaunchType,
210215
ecsTask.ID,
211216
ecsTask.ExternalIP,
@@ -368,7 +373,7 @@ func (m *ECSTasksModule) loadTasksData(clusterARN string, taskARNs []string, reg
368373
return
369374
}
370375

371-
eniIDs := []string{}
376+
var eniIDs []string
372377
for _, task := range Tasks {
373378
eniID := getElasticNetworkInterfaceIDOfECSTask(task)
374379
if eniID != "" {
@@ -394,6 +399,7 @@ func (m *ECSTasksModule) loadTasksData(clusterARN string, taskARNs []string, reg
394399
Cluster: getNameFromARN(clusterARN),
395400
TaskDefinitionName: getNameFromARN(aws.ToString(task.TaskDefinitionArn)),
396401
TaskDefinitionContent: getTaskDefinitionContent(taskDefinition),
402+
ContainerName: getContainerNamesFromECSTask(task),
397403
LaunchType: string(task.LaunchType),
398404
ID: getIDFromECSTask(aws.ToString(task.TaskArn)),
399405
PrivateIP: getPrivateIPv4AddressFromECSTask(task),
@@ -505,8 +511,18 @@ func getIDFromECSTask(arn string) string {
505511
return tokens[2]
506512
}
507513

514+
func getContainerNamesFromECSTask(task types.Task) string {
515+
var names []string
516+
517+
for _, container := range task.Containers {
518+
names = append(names, aws.ToString(container.Name))
519+
}
520+
521+
return strings.Join(names, "|")
522+
}
523+
508524
func getPrivateIPv4AddressFromECSTask(task types.Task) string {
509-
ips := []string{}
525+
var ips []string
510526

511527
for _, attachment := range task.Attachments {
512528
if aws.ToString(attachment.Type) != "ElasticNetworkInterface" || aws.ToString(attachment.Status) != "ATTACHED" {

aws/ecs-tasks_test.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ func TestECSTasks(t *testing.T) {
2323
outputDirectory: ".",
2424
verbosity: 2,
2525
testModule: ECSTasksModule{
26-
2726
AWSProfile: "default",
2827
AWSRegions: []string{"us-east-1", "us-west-1"},
2928
Caller: sts.GetCallerIdentityOutput{Arn: aws.String("arn:aws:iam::123456789012:user/cloudfox_unit_tests")},
@@ -33,10 +32,11 @@ func TestECSTasks(t *testing.T) {
3332
ECSClient: &sdk.MockedECSClient{},
3433
},
3534
expectedResult: []MappedECSTask{{
36-
Cluster: "MyCluster",
37-
ID: "74de0355a10a4f979ac495c14EXAMPLE",
38-
ExternalIP: "203.0.113.12",
39-
Role: "test123",
35+
Cluster: "MyCluster",
36+
ID: "74de0355a10a4f979ac495c14EXAMPLE",
37+
ContainerName: "web",
38+
ExternalIP: "203.0.113.12",
39+
Role: "test123",
4040
}},
4141
},
4242
}
@@ -48,6 +48,9 @@ func TestECSTasks(t *testing.T) {
4848
if expectedTask.Cluster != subtest.testModule.MappedECSTasks[index].Cluster {
4949
log.Fatal("Cluster name does not match expected value")
5050
}
51+
if expectedTask.ContainerName != subtest.testModule.MappedECSTasks[index].ContainerName {
52+
log.Fatal("Container name does not match expected value")
53+
}
5154
}
5255
})
5356
}

0 commit comments

Comments
 (0)