Skip to content

Commit

Permalink
Fixes for the intel subcommand
Browse files Browse the repository at this point in the history
Committer: caffix <caffix@users.noreply.github.com>
  • Loading branch information
caffix committed Jun 23, 2022
1 parent 8a7cd5d commit 40bdd3d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 32 deletions.
9 changes: 7 additions & 2 deletions cmd/amass/intel.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,9 @@ func runIntelCommand(clArgs []string) {
go func() { _ = ic.HostedDomains(ctx) }()
}

processIntelOutput(ic, &args)
if !processIntelOutput(ic, &args) {
os.Exit(1)
}
}

func printNetblocks(asns []int, cfg *config.Config, sys systems.System) {
Expand All @@ -279,7 +281,7 @@ func printNetblocks(asns []int, cfg *config.Config, sys systems.System) {
}
}

func processIntelOutput(ic *intel.Collection, args *intelArgs) {
func processIntelOutput(ic *intel.Collection, args *intelArgs) bool {
var err error
dir := config.OutputDirectory(ic.Config.Dir)

Expand All @@ -303,6 +305,7 @@ func processIntelOutput(ic *intel.Collection, args *intelArgs) {
_, _ = outptr.Seek(0, 0)
}

var found bool
// Collect all the names returned by the intelligence collection
for out := range ic.Output {
source, _, ips := format.OutputLineParts(out, args.Options.Sources,
Expand All @@ -317,7 +320,9 @@ func processIntelOutput(ic *intel.Collection, args *intelArgs) {
if outptr != nil {
fmt.Fprintf(outptr, "%s%s%s\n", source, out.Domain, ips)
}
found = true
}
return found
}

// Obtain parameters from provided input files
Expand Down
19 changes: 1 addition & 18 deletions intel/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,24 +57,7 @@ func (r *intelSource) Next(ctx context.Context) bool {
default:
}

if !r.queue.Empty() {
return true
}

t := time.NewTimer(r.timeout)
defer t.Stop()

for {
select {
case <-t.C:
close(r.done)
return false
case <-r.queue.Signal():
if !r.queue.Empty() {
return true
}
}
}
return !r.queue.Empty()
}

// Data implements the pipeline InputSource interface.
Expand Down
18 changes: 6 additions & 12 deletions intel/intel.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import (
)

const (
maxDnsPipelineTasks int = 15000
maxActivePipelineTasks int = 25
maxDnsPipelineTasks int = 2000
maxActivePipelineTasks int = 50
)

// Collection is the object type used to execute a open source information gathering with Amass.
Expand Down Expand Up @@ -76,16 +76,12 @@ func (c *Collection) HostedDomains(ctx context.Context) error {
return err
}

defer close(c.Output)
// Setup the context used throughout the collection
var cancel context.CancelFunc
c.ctx, cancel = context.WithCancel(ctx)
defer cancel()

go func() {
<-ctx.Done()
close(c.Output)
}()

var stages []pipeline.Stage
stages = append(stages, pipeline.DynamicPool("", c.makeDNSTaskFunc(), maxDnsPipelineTasks))
if c.Config.Active {
Expand All @@ -104,11 +100,9 @@ func (c *Collection) HostedDomains(ctx context.Context) error {
continue
}

go func(n *net.IPNet) {
for _, addr := range amassnet.AllHosts(n) {
source.InputAddress(&requests.AddrRequest{Address: addr.String()})
}
}(cidr)
for _, addr := range amassnet.AllHosts(cidr) {
source.InputAddress(&requests.AddrRequest{Address: addr.String()})
}
}

return pipeline.NewPipeline(stages...).Execute(ctx, source, c.makeOutputSink())
Expand Down

0 comments on commit 40bdd3d

Please sign in to comment.