Skip to content

Commit

Permalink
updates to the collection function
Browse files Browse the repository at this point in the history
  • Loading branch information
caffix committed Sep 8, 2023
1 parent cb9b043 commit 87f73be
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 57 deletions.
16 changes: 2 additions & 14 deletions cmd/amass/enum.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func defineEnumOptionFlags(enumFlags *flag.FlagSet, args *enumArgs) {
enumFlags.BoolVar(&args.Options.Alterations, "alts", false, "Enable generation of altered names")
enumFlags.BoolVar(&args.Options.NoColor, "nocolor", false, "Disable colorized output")
enumFlags.BoolVar(&args.Options.NoRecursive, "norecursive", false, "Turn off recursive brute forcing")
enumFlags.BoolVar(&args.Options.Passive, "passive", false, "Disable DNS resolution of names and dependent features")
enumFlags.BoolVar(&args.Options.Passive, "passive", false, "Deprecated since passive is the default setting")
enumFlags.BoolVar(&args.Options.Silent, "silent", false, "Disable all output during execution")
enumFlags.BoolVar(&args.Options.Verbose, "v", false, "Output status / debug / troubleshooting info")
}
Expand Down Expand Up @@ -176,12 +176,6 @@ func runEnumCommand(clArgs []string) {
os.Exit(1)
}

if cfg.Passive {
fmt.Fprintf(color.Error, "%s\n", green("Passive mode does not generate output during the enumeration"))
fmt.Fprintf(color.Error, "\t%s\n", green("Obtain your list of FQDNs using the following command:"))
fmt.Fprintf(color.Error, "\t%s\n", green("amass db -names -d "+strings.Join(cfg.Domains(), ",")))
}

// Setup the new enumeration
e := enum.NewEnumeration(cfg, sys, sys.GraphDatabases()[0])
if e == nil {
Expand Down Expand Up @@ -362,7 +356,7 @@ func printOutput(e *enum.Enumeration, args *enumArgs, output chan string, wg *sy
total++
}

if !e.Config.Passive && total == 0 {
if total == 0 {
r.Println("No assets were discovered")
}
}
Expand Down Expand Up @@ -623,12 +617,6 @@ func (e enumArgs) OverrideConfig(conf *config.Config) error {
conf.Active = true
conf.Passive = false
}
if e.Options.Passive {
conf.Passive = true
conf.Active = false
conf.BruteForcing = false
conf.Alterations = false
}
if e.Blacklist.Len() > 0 {
conf.Scope.Blacklist = e.Blacklist.Slice()
}
Expand Down
3 changes: 0 additions & 3 deletions cmd/amass/io.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,6 @@ func extractAssetName(a *types.Asset) string {

// ExtractOutput is a convenience method for obtaining new discoveries made by the enumeration process.
func ExtractOutput(ctx context.Context, g *netmap.Graph, e *enum.Enumeration, filter *stringset.Set, asinfo bool) []*requests.Output {
if e.Config.Passive {
return EventNames(ctx, g, e.Config.Domains(), e.Config.CollectionStartTime, filter)
}
return EventOutput(ctx, g, e.Config.Domains(), e.Config.CollectionStartTime, filter, asinfo, e.Sys.Cache())
}

Expand Down
49 changes: 15 additions & 34 deletions enum/enum.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,24 +65,20 @@ func (e *Enumeration) Start(ctx context.Context) error {
defer cancel()
go e.manageDataSrcRequests()

if !e.Config.Passive {
e.dnsTask = newDNSTask(e, false)
e.valTask = newDNSTask(e, true)
e.store = newDataManager(e)
e.subTask = newSubdomainTask(e)
defer e.subTask.Stop()
defer e.dnsTask.stop()
defer e.valTask.stop()
}
e.dnsTask = newDNSTask(e, false)
e.valTask = newDNSTask(e, true)
e.store = newDataManager(e)
e.subTask = newSubdomainTask(e)
defer e.subTask.Stop()
defer e.dnsTask.stop()
defer e.valTask.stop()

var stages []pipeline.Stage
if !e.Config.Passive {
stages = append(stages, pipeline.FIFO("root", e.valTask.rootTaskFunc()))
stages = append(stages, pipeline.FIFO("dns", e.dnsTask))
stages = append(stages, pipeline.FIFO("validate", e.valTask))
stages = append(stages, pipeline.FIFO("store", e.store))
stages = append(stages, pipeline.FIFO("", e.subTask))
}
stages = append(stages, pipeline.FIFO("root", e.valTask.rootTaskFunc()))
stages = append(stages, pipeline.FIFO("dns", e.dnsTask))
stages = append(stages, pipeline.FIFO("validate", e.valTask))
stages = append(stages, pipeline.FIFO("store", e.store))
stages = append(stages, pipeline.FIFO("", e.subTask))

p := pipeline.NewPipeline(stages...)
// The pipeline input source will receive all the names
Expand All @@ -99,14 +95,9 @@ func (e *Enumeration) Start(ctx context.Context) error {
go e.submitKnownNames()
go e.submitProvidedNames()

var err error
if e.Config.Passive {
err = p.Execute(e.ctx, e.nameSrc, e.makeOutputSink())
} else {
err = p.ExecuteBuffered(e.ctx, e.nameSrc, e.makeOutputSink(), 50)
// Ensure all data has been stored
<-e.store.Stop()
}
err := p.ExecuteBuffered(e.ctx, e.nameSrc, e.makeOutputSink(), 50)
// Ensure all data has been stored
<-e.store.Stop()
return err
}

Expand Down Expand Up @@ -219,16 +210,6 @@ func (e *Enumeration) fireRequest(srv service.Service, req interface{}, finished

func (e *Enumeration) makeOutputSink() pipeline.SinkFunc {
return pipeline.SinkFunc(func(ctx context.Context, data pipeline.Data) error {
if !e.Config.Passive {
return nil
}

req, ok := data.(*requests.DNSRequest)
if ok && req != nil && req.Name != "" && e.Config.IsDomainInScope(req.Name) {
if _, err := e.graph.UpsertFQDN(e.ctx, req.Name); err != nil {
e.Config.Log.Print(err.Error())
}
}
return nil
})
}
Expand Down
2 changes: 1 addition & 1 deletion enum/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func (r *enumSource) Next(ctx context.Context) bool {
case <-t.C:
count := r.pipeline.DataItemCount()
if !r.enum.requestsPending() && count <= 0 {
if r.enum.Config.Passive || r.enum.store.queue.Len() == 0 {
if r.enum.store.queue.Len() == 0 {
r.markDone()
return false
}
Expand Down
6 changes: 1 addition & 5 deletions systems/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,7 @@ func NewLocalSystem(cfg *config.Config) (*LocalSystem, error) {
return nil, errors.New("the system was unable to build the pool of trusted resolvers")
}

pool, num := trusted, num
if !cfg.Passive {
pool, num = untrustedResolvers(cfg)
}

pool, num := untrustedResolvers(cfg)
if pool == nil || num == 0 {
return nil, errors.New("the system was unable to build the pool of untrusted resolvers")
}
Expand Down

0 comments on commit 87f73be

Please sign in to comment.