(outputDirectory string, verbosity int)
| 63 | } |
| 64 | |
| 65 | func (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) |
no test coverage detected