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

Method PrintLambdas

aws/lambda.go:65–227  ·  view source on GitHub ↗
(outputDirectory string, verbosity int)

Source from the content-addressed store, hash-verified

63}
64
65func (m *LambdasModule) PrintLambdas(outputDirectory string, verbosity int) {
66
67 // These struct values are used by the output module
68 m.output.Verbosity = verbosity
69 m.output.Directory = outputDirectory
70 m.output.CallingModule = "lambda"
71 localAdminMap := make(map[string]bool)
72 m.modLog = internal.TxtLog.WithFields(logrus.Fields{
73 "module": m.output.CallingModule,
74 })
75 if m.AWSProfile == "" {
76 m.AWSProfile = internal.BuildAWSPath(m.Caller)
77 }
78
79 fmt.Printf("[%s][%s] Enumerating lambdas for account %s.\n", cyan(m.output.CallingModule), cyan(m.AWSProfile), aws.ToString(m.Caller.Account))
80 //fmt.Printf("[%s][%s] Attempting to build a PrivEsc graph in memory using local pmapper data if it exists on the filesystem.\n", cyan(m.output.CallingModule), cyan(m.AWSProfile))
81 m.pmapperMod, m.pmapperError = InitPmapperGraph(m.Caller, m.AWSProfile, m.Goroutines, m.PmapperDataBasePath)
82 m.iamSimClient = InitIamCommandClient(m.IAMClient, m.Caller, m.AWSProfile, m.Goroutines)
83
84 // if m.pmapperError != nil {
85 // fmt.Printf("[%s][%s] No pmapper data found for this account. Using cloudfox's iam-simulator for role analysis.\n", cyan(m.output.CallingModule), cyan(m.AWSProfile))
86 // } else {
87 // fmt.Printf("[%s][%s] Found pmapper data for this account. Using it for role analysis.\n", cyan(m.output.CallingModule), cyan(m.AWSProfile))
88 // }
89
90 wg := new(sync.WaitGroup)
91 semaphore := make(chan struct{}, m.Goroutines)
92
93 // Create a channel to signal the spinner aka task status goroutine to finish
94 spinnerDone := make(chan bool)
95 //fire up the the task status spinner/updated
96 go internal.SpinUntil(m.output.CallingModule, &m.CommandCounter, spinnerDone, "regions")
97
98 //create a channel to receive the objects
99 dataReceiver := make(chan Lambda)
100
101 // Create a channel to signal to stop
102 receiverDone := make(chan bool)
103
104 go m.Receiver(dataReceiver, receiverDone)
105
106 for _, region := range m.AWSRegions {
107 wg.Add(1)
108 m.CommandCounter.IncrPending()
109 go m.executeChecks(region, wg, semaphore, dataReceiver)
110
111 }
112 wg.Wait()
113 //time.Sleep(time.Second * 2)
114
115 // Perform role analysis
116 if m.pmapperError == nil {
117 for i := range m.Lambdas {
118 m.Lambdas[i].Admin, m.Lambdas[i].CanPrivEsc = GetPmapperResults(m.SkipAdminCheck, m.pmapperMod, &m.Lambdas[i].Role)
119 }
120 } else {
121 for i := range m.Lambdas {
122 m.Lambdas[i].Admin, m.Lambdas[i].CanPrivEsc = GetIamSimResult(m.SkipAdminCheck, &m.Lambdas[i].Role, m.iamSimClient, localAdminMap)

Callers 2

runLambdasCommandFunction · 0.95
runAllChecksCommandFunction · 0.95

Calls 13

ReceiverMethod · 0.95
executeChecksMethod · 0.95
WriteFullOutputMethod · 0.95
writeLootMethod · 0.95
BuildAWSPathFunction · 0.92
SpinUntilFunction · 0.92
InitPmapperGraphFunction · 0.85
InitIamCommandClientFunction · 0.85
GetPmapperResultsFunction · 0.85
GetIamSimResultFunction · 0.85
removeStringFromSliceFunction · 0.85
AddMethod · 0.80

Tested by

no test coverage detected