/
ptrarchive.go
50 lines (38 loc) · 1.01 KB
/
ptrarchive.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
// 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/internal/utils"
)
type PTRArchive struct {
BaseDataSource
}
func NewPTRArchive() DataSource {
p := new(PTRArchive)
p.BaseDataSource = *NewBaseDataSource(SCRAPE, "PTRarchive")
return p
}
func (p *PTRArchive) Query(domain, sub string) []string {
var unique []string
if domain != sub {
return unique
}
url := p.getURL(domain)
page, err := utils.GetWebPage(url, nil)
if err != nil {
p.log(fmt.Sprintf("%s: %v", url, err))
return unique
}
re := utils.SubdomainRegex(domain)
for _, sd := range re.FindAllString(page, -1) {
if u := utils.NewUniqueElements(unique, sd); len(u) > 0 {
unique = append(unique, u...)
}
}
return unique
}
func (p *PTRArchive) getURL(domain string) string {
format := "http://ptrarchive.com/tools/search3.htm?label=%s&date=ALL"
return fmt.Sprintf(format, domain)
}