Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
rangertaha committed Nov 21, 2024
1 parent ca08166 commit b95ed41
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 7 deletions.
20 changes: 19 additions & 1 deletion internal/engine/filters.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,25 @@ func DedupFilter() func(in <-chan internal.Domain, c *config.Config) <-chan inte
out <- domain
}
}
c.Count(len(variants))
close(out)
}()
return out
}
}

func GetTotal() func(in <-chan internal.Domain, c *config.Config) <-chan internal.Domain {
return func(in <-chan internal.Domain, c *config.Config) <-chan internal.Domain {
out := make(chan internal.Domain)

go func() {
var count int
for domain := range in {
count++

out <- domain

}
c.Count(count)
close(out)
}()
return out
Expand Down
78 changes: 75 additions & 3 deletions internal/engine/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,6 @@ func (u *Urlinsane) CollectorChain(funcs []internal.Collector, in <-chan interna
ctx, cancel = context.WithCancel(context.Background())
}

// acc := NewAccumulator(out)
u.runner(ctx, xfunc, variant, out)
cancel()
}
Expand Down Expand Up @@ -449,8 +448,10 @@ func (u *Urlinsane) Progress(in <-chan internal.Domain) <-chan internal.Domain {
func (u *Urlinsane) Output(in <-chan internal.Domain) {
logger := log.WithFields(log.Fields{"output": u.cfg.Output().Id()})
output := u.cfg.Output()
var total int64

for c := range in {
total++
logger.WithFields(log.Fields{"d": c.String()}).
Debug("Sending to output")

Expand Down Expand Up @@ -486,13 +487,53 @@ func (u *Urlinsane) Output(in <-chan internal.Domain) {
summary := map[string]string{
" TIME:": u.elapsed.String(),
text.FgGreen.Sprintf("%s", " LIVE:"): fmt.Sprintf("%d", u.live),
text.FgRed.Sprintf("%s", " OFFLINE"): fmt.Sprintf("%d", u.total-u.live),
" TOTAL:": fmt.Sprintf("%d", u.total),
text.FgRed.Sprintf("%s", " OFFLINE"): fmt.Sprintf("%d", total-u.live),
" TOTAL:": fmt.Sprintf("%d", total),
}
output.Summary(summary)
}
}

func (u *Urlinsane) Details(in <-chan internal.Domain) {
// logger := log.WithFields(log.Fields{"output": u.cfg.Output().Id()})
// output := u.cfg.Output()

// for c := range in {
// logger.WithFields(log.Fields{"d": c.String()}).
// Debug("Sending to output")

// // Save domain to directory
// if u.cfg.AssetDir() != "" {
// if c.Live() {
// if err := c.Save(u.cfg.AssetDir()); err != nil {
// logger.Error("Saving: ", err)
// }
// }

// }
// }

// // Writes output if it can't stream
// output.Write()

// // Save typo records collected by the output plugin
// if fname := u.cfg.File(); fname != "" {
// output.Save(fname)
// }

// // Print summary
// if u.cfg.Summary() {
// u.elapsed = time.Since(u.started)
// summary := map[string]string{
// " TIME:": u.elapsed.String(),
// text.FgGreen.Sprintf("%s", " LIVE:"): fmt.Sprintf("%d", u.live),
// text.FgRed.Sprintf("%s", " OFFLINE"): fmt.Sprintf("%d", total-u.live),
// " TOTAL:": fmt.Sprintf("%d", total),
// }
// output.Summary(summary)
// }
}

func (u *Urlinsane) Close() {
// Initialize information plugins if needed
for _, info := range u.cfg.Collectors() {
Expand Down Expand Up @@ -528,6 +569,36 @@ func (u *Urlinsane) Execute() (err error) {
return
}

func (u *Urlinsane) Scan() (err error) {
typos := u.Init()
typos = u.Target(typos)
typos = u.Algorithms(typos)
typos = u.Constraints(typos,
DedupFilter,
RegexFilter,
LevenshteinFilter,
ReadCacheFilter,
)
typos = u.Collectors(typos)
typos = u.WriteCache(typos)
typos = u.PostFilters(typos)
typos = u.Analyzers(typos)
typos = u.Progress(typos)
u.Output(typos)
u.Close()

return
}

func (u *Urlinsane) Fetch() (err error) {
typos := u.Init()
typos = u.Target(typos)
typos = u.Collectors(typos)
u.Details(typos)
u.Close()
return
}

func (u *Urlinsane) Stream() <-chan internal.Domain {
typos := u.Init()
typos = u.Target(typos)
Expand All @@ -537,6 +608,7 @@ func (u *Urlinsane) Stream() <-chan internal.Domain {
RegexFilter,
LevenshteinFilter,
ReadCacheFilter,
GetTotal,
)
typos = u.Collectors(typos)
typos = u.WriteCache(typos)
Expand Down
8 changes: 5 additions & 3 deletions internal/plugins/collectors/ns/ns.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,11 @@ func (i *Plugin) Exec(acc internal.Accumulator) (err error) {
for _, record := range records {
dns.Add("NS", 0, record.Host)
}
acc.SetMeta("NS", dns.String("NS"))
acc.SetJson("DNS", dns.Json())
acc.Domain().Live(true)
if len(records) > 0 {
acc.SetMeta("NS", dns.String("NS"))
acc.SetJson("DNS", dns.Json())
acc.Domain().Live(true)
}

return acc.Next()
}
Expand Down
2 changes: 2 additions & 0 deletions internal/plugins/collectors/web/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ func (p *Plugin) Exec(acc internal.Accumulator) (err error) {

})

// p.client.Visit(fmt.Sprintf("http://%s/robot.txt", acc.Domain().String()))
// p.client.Visit(fmt.Sprintf("https://%s/robot.txt", acc.Domain().String()))
p.client.Visit(fmt.Sprintf("http://%s", acc.Domain().String()))
p.client.Visit(fmt.Sprintf("https://%s", acc.Domain().String()))

Expand Down

0 comments on commit b95ed41

Please sign in to comment.