-
Notifications
You must be signed in to change notification settings - Fork 10
/
url_technology_fingerprinter.go
62 lines (50 loc) · 1.63 KB
/
url_technology_fingerprinter.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
package agents
import (
"fmt"
"github.com/shelld3v/aquatone/core"
wappalyzer "github.com/projectdiscovery/wappalyzergo"
)
type URLTechnologyFingerprinter struct {
session *core.Session
}
func NewURLTechnologyFingerprinter() *URLTechnologyFingerprinter {
return &URLTechnologyFingerprinter{}
}
func (a *URLTechnologyFingerprinter) ID() string {
return "agent:url_technology_fingerprinter"
}
func (a *URLTechnologyFingerprinter) Register(s *core.Session) error {
s.EventBus.SubscribeAsync(core.URLResponsive, a.OnURLResponsive, false)
a.session = s
return nil
}
func (a *URLTechnologyFingerprinter) OnURLResponsive(url string) {
a.session.Out.Debug("[%s] Received new responsive URL %s\n", a.ID(), url)
page := a.session.GetPage(url)
if page == nil {
a.session.Out.Error("Unable to find page for URL: %s\n", url)
return
}
a.session.WaitGroup.Add()
go func(page *core.Page) {
defer a.session.WaitGroup.Done()
body, err := a.session.ReadFile(fmt.Sprintf("html/%s.html", page.BaseFilename()))
if err != nil {
a.session.Out.Debug("[%s] Error reading HTML body file for %s: %s\n", a.ID(), page.URL, err)
return
}
headers := map[string][]string{}
for _, header := range page.Headers {
headers[header.Name] = []string{header.Value}
}
wappalyzerClient, err := wappalyzer.New()
if err != nil {
a.session.Out.Debug("[%s] Unable to create wappalyzer client (wappalyzergo)\n", a.ID())
return
}
fingerprints := wappalyzerClient.Fingerprint(headers, body)
for service := range fingerprints {
page.AddTag(service, "primary", "https://cve.mitre.org/cgi-bin/cvekey.cgi?keyword=" + service)
}
}(page)
}