MCPcopy Create free account
hub / github.com/BishopFox/cloudfox / PrintAccessKeys

Method PrintAccessKeys

aws/access-keys.go:41–135  ·  view source on GitHub ↗
(filter string, outputDirectory string, verbosity int)

Source from the content-addressed store, hash-verified

39}
40
41func (m *AccessKeysModule) PrintAccessKeys(filter string, outputDirectory string, verbosity int) {
42 // These struct values are used by the output module
43 m.output.Verbosity = verbosity
44 m.output.Directory = outputDirectory
45 m.output.CallingModule = "access-keys"
46 m.modLog = internal.TxtLog.WithFields(logrus.Fields{
47 "module": m.output.CallingModule,
48 },
49 )
50
51 if m.AWSProfile == "" {
52 m.AWSProfile = internal.BuildAWSPath(m.Caller)
53 }
54
55 fmt.Printf("[%s][%s] Mapping user access keys for account: %s.\n", cyan(m.output.CallingModule), cyan(m.AWSProfile), aws.ToString(m.Caller.Account))
56 m.getAccessKeysForAllUsers()
57
58 // Variables used to draw table output
59 m.output.Headers = []string{
60 "Account",
61 "User Name",
62 "Access Key ID",
63 }
64
65 // Table rows
66 for _, key := range m.AnalyzedUsers {
67 if filter == "none" || key.Key == filter {
68 m.output.Body = append(
69 m.output.Body,
70 []string{
71 aws.ToString(m.Caller.Account),
72 key.Username,
73 key.Key,
74 },
75 )
76 }
77 }
78 // Only create output files if there is output
79 if len(m.output.Body) > 0 {
80
81 // Pretty prints output
82 fmt.Printf("[%s][%s] Only active access keys are shown.\n", cyan(m.output.CallingModule), cyan(m.AWSProfile))
83 //fmt.Printf("[%s][%s] Preparing output.\n\n")
84
85 m.output.FilePath = filepath.Join(outputDirectory, "cloudfox-output", "aws", fmt.Sprintf("%s-%s", m.AWSProfile, aws.ToString(m.Caller.Account)))
86 o := internal.OutputClient{
87 Verbosity: verbosity,
88 CallingModule: m.output.CallingModule,
89 Table: internal.TableClient{
90 Wrap: m.WrapTable,
91 },
92 }
93
94 // If the user specified table columns, use those.
95 // If the user specified -o wide, use the wide default cols for this module.
96 // Otherwise, use the hardcoded default cols for this module.
97 var tableCols []string
98 // If the user specified table columns, use those.

Callers 2

runAccessKeysCommandFunction · 0.95
runAllChecksCommandFunction · 0.95

Calls 4

WriteFullOutputMethod · 0.95
writeLootMethod · 0.95
BuildAWSPathFunction · 0.92

Tested by

no test coverage detected