forked from owasp-amass/amass
/
sitedossier.go
80 lines (65 loc) · 1.76 KB
/
sitedossier.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// Copyright 2017 Jeff Foley. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
package sources
import (
"fmt"
"github.com/OWASP/Amass/amass/core"
"github.com/OWASP/Amass/amass/utils"
)
// SiteDossier is the Service that handles access to the SiteDossier data source.
type SiteDossier struct {
core.BaseService
SourceType string
}
// NewSiteDossier returns he object initialized, but not yet started.
func NewSiteDossier(config *core.Config, bus *core.EventBus) *SiteDossier {
s := &SiteDossier{SourceType: core.SCRAPE}
s.BaseService = *core.NewBaseService(s, "SiteDossier", config, bus)
return s
}
// OnStart implements the Service interface
func (s *SiteDossier) OnStart() error {
s.BaseService.OnStart()
go s.processRequests()
return nil
}
func (s *SiteDossier) processRequests() {
for {
select {
case <-s.Quit():
return
case req := <-s.DNSRequestChan():
if s.Config().IsDomainInScope(req.Domain) {
s.executeQuery(req.Domain)
}
case <-s.AddrRequestChan():
case <-s.ASNRequestChan():
case <-s.WhoisRequestChan():
}
}
}
func (s *SiteDossier) executeQuery(domain string) {
re := s.Config().DomainRegex(domain)
if re == nil {
return
}
s.SetActive()
url := s.getURL(domain)
page, err := utils.RequestWebPage(url, nil, nil, "", "")
if err != nil {
s.Config().Log.Printf("%s: %s: %v", s.String(), url, err)
return
}
for _, sd := range re.FindAllString(page, -1) {
s.Bus().Publish(core.NewNameTopic, &core.DNSRequest{
Name: cleanName(sd),
Domain: domain,
Tag: s.SourceType,
Source: s.String(),
})
}
}
func (s *SiteDossier) getURL(domain string) string {
format := "http://www.sitedossier.com/parentdomain/%s"
return fmt.Sprintf(format, domain)
}