Skip to content

Commit e2f5823

Browse files
committed
rename tldplus1 to apex (correct name) and update some deps
1 parent 3bc53e0 commit e2f5823

9 files changed

Lines changed: 33 additions & 30 deletions

File tree

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ BUILD_FLAGS := -ldflags "-X main.gitDate=$(GIT_DATE) -X main.gitHash=$(GIT_HASH)
55

66
PLATFORMS := linux/amd64 linux/386 linux/arm darwin/amd64 windows/amd64 windows/386 openbsd/amd64
77
SOURCES := $(shell find . -maxdepth 1 -type f -name "*.go")
8-
ALL_SOURCES = $(shell find . -type f -name '*.go')
8+
ALL_SOURCES = $(shell find . -type f -name '*.go') go.mod
99

1010
temp = $(subst /, ,$@)
1111
os = $(word 1, $(temp))
@@ -40,3 +40,6 @@ clean:
4040

4141
serv:
4242
(cd docs; python -m SimpleHTTPServer)
43+
44+
updateMod:
45+
go get -u

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ OPTIONS:
3333
-parallel uint
3434
number of certificates to retrieve in parallel (default 10)
3535
-sanscap int
36-
maximum number of uniq TLD+1 domains in certificate to include, 0 has no limit (default 80)
36+
maximum number of uniq apex domains in certificate to include, 0 has no limit (default 80)
3737
-save string
3838
save certs to folder in PEM format
3939
-timeout uint
4040
tcp timeout in seconds (default 10)
41-
-tldplus1
42-
for every domain found, add tldPlus1 of the domain's parent
41+
-apex
42+
for every domain found, add the apex domain of the domain's parent
4343
-verbose
4444
verbose logging
4545
-version
@@ -138,15 +138,15 @@ CertGraph can be used to detect [BygoneSSL](https://insecure.design) DoS with th
138138
Provide all known input domains you own. If any domains you do not own are printed, then you are vulnerable.
139139

140140
```
141-
certgraph -depth 1 -driver CT-DRIVER -ct-subdomains -cdn -tldplus1 [DOMAIN]...
141+
certgraph -depth 1 -driver CT-DRIVER -ct-subdomains -cdn -apex [DOMAIN]...
142142
```
143143

144144
### Bug Bounty
145145

146146
If you want to find a vulnerable site that has a bug bounty, certgraph can be used with the following options and any driver. But you will have better luck with a non Certificate Transparency driver to ensure that the certificates in question are actually in use
147147

148148
```
149-
certgraph -cdn -dns -tldplus1 [DOMAIN]...
149+
certgraph -cdn -dns -apex [DOMAIN]...
150150
```
151151

152152
And domains that print `* Missing DNS for` have vulnerable certificates that should be rotated.

certgraph.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ var config struct {
4242
includeCTExpired bool
4343
cdn bool
4444
maxSANsSize int
45-
tldPlus1 bool
45+
apex bool
4646
updatePSL bool
4747
checkDNS bool
4848
printVersion bool
@@ -56,10 +56,10 @@ func init() {
5656
flag.StringVar(&config.driver, "driver", "http", fmt.Sprintf("driver to use [%s]", strings.Join(driver.Drivers, ", ")))
5757
flag.BoolVar(&config.includeCTSubdomains, "ct-subdomains", false, "include sub-domains in certificate transparency search")
5858
flag.BoolVar(&config.includeCTExpired, "ct-expired", false, "include expired certificates in certificate transparency search")
59-
flag.IntVar(&config.maxSANsSize, "sanscap", 80, "maximum number of uniq TLD+1 domains in certificate to include, 0 has no limit")
59+
flag.IntVar(&config.maxSANsSize, "sanscap", 80, "maximum number of uniq apex domains in certificate to include, 0 has no limit")
6060
flag.BoolVar(&config.cdn, "cdn", false, "include certificates from CDNs")
6161
flag.BoolVar(&config.checkDNS, "dns", false, "check for DNS records to determine if domain is registered")
62-
flag.BoolVar(&config.tldPlus1, "tldplus1", false, "for every domain found, add tldPlus1 of the domain's parent")
62+
flag.BoolVar(&config.apex, "apex", false, "for every domain found, add the apex domain of the domain's parent")
6363
flag.BoolVar(&config.updatePSL, "updatepsl", false, "Update the default Public Suffix List")
6464
flag.UintVar(&config.maxDepth, "depth", 5, "maximum BFS depth to go")
6565
flag.UintVar(&config.parallel, "parallel", 10, "number of certificates to retrieve in parallel")
@@ -109,12 +109,12 @@ func main() {
109109
d := strings.ToLower(domain)
110110
if len(d) > 0 {
111111
startDomains = append(startDomains, cleanInput(d))
112-
if config.tldPlus1 {
113-
tldPlus1, err := dns.TLDPlus1(domain)
112+
if config.apex {
113+
apexDomain, err := dns.ApexDomain(domain)
114114
if err != nil {
115115
continue
116116
}
117-
startDomains = append(startDomains, tldPlus1)
117+
startDomains = append(startDomains, apexDomain)
118118
}
119119
}
120120
}
@@ -246,13 +246,13 @@ func breathFirstSearch(roots []string) {
246246
for _, neighbor := range certGraph.GetDomainNeighbors(domainNode.Domain, config.cdn, config.maxSANsSize) {
247247
wg.Add(1)
248248
domainNodeInputChan <- graph.NewDomainNode(neighbor, domainNode.Depth+1)
249-
if config.tldPlus1 {
250-
tldPlus1, err := dns.TLDPlus1(neighbor)
249+
if config.apex {
250+
apexDomain, err := dns.ApexDomain(neighbor)
251251
if err != nil {
252252
continue
253253
}
254254
wg.Add(1)
255-
domainNodeInputChan <- graph.NewDomainNode(tldPlus1, domainNode.Depth+1)
255+
domainNodeInputChan <- graph.NewDomainNode(apexDomain, domainNode.Depth+1)
256256
}
257257
}
258258
}(domainNode)
@@ -356,7 +356,7 @@ func printNode(domainNode *graph.DomainNode) {
356356
if config.checkDNS && !domainNode.HasDNS {
357357
// TODO print this in a better way
358358
// TODO for debugging
359-
realDomain, _ := dns.TLDPlus1(domainNode.Domain)
359+
realDomain, _ := dns.ApexDomain(domainNode.Domain)
360360
fmt.Fprintf(os.Stdout, "* Missing DNS for: %s\n", realDomain)
361361

362362
}

dns/ns.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func noSuchHostDNSError(err error) bool {
2626
}
2727

2828
// HasRecords does NS, CNAME, A, and AAAA lookups with a timeout
29-
// returns error when no NS found, does not use TLDPlus1
29+
// returns error when no NS found, does not use alexDomain
3030
func HasRecords(domain string, timeout time.Duration) (bool, error) {
3131
ctx, cancel := context.WithTimeout(context.Background(), timeout)
3232
defer cancel()
@@ -68,10 +68,10 @@ func HasRecords(domain string, timeout time.Duration) (bool, error) {
6868
return false, nil
6969
}
7070

71-
// HasRecordsCache returns true if the domain has no DNS records (at the tldplus1 level)
71+
// HasRecordsCache returns true if the domain has no DNS records (at the apex domain level)
7272
// uses a cache to store results to prevent lots of DNS lookups
7373
func HasRecordsCache(domain string, timeout time.Duration) (bool, error) {
74-
domain, err := TLDPlus1(domain)
74+
domain, err := ApexDomain(domain)
7575
if err != nil {
7676
return false, err
7777
}

dns/publicsuffix.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func UpdatePublicSuffixList(timeout time.Duration) error {
3636
return err
3737
}
3838

39-
// TLDPlus1 returns TLD+1 of domain
40-
func TLDPlus1(domain string) (string, error) {
39+
// ApexDomain returns TLD+1 of domain
40+
func ApexDomain(domain string) (string, error) {
4141
return publicsuffix.DomainFromListWithOptions(suffixList, domain, suffixListFindOptions)
4242
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ module github.com/lanrat/certgraph
33
require (
44
github.com/lib/pq v1.0.0
55
github.com/weppos/publicsuffix-go v0.4.0
6-
golang.org/x/net v0.0.0-20180911220305-26e67e76b6c3 // indirect
6+
golang.org/x/net v0.0.0-20181102091132-c10e9556a7bc // indirect
77
golang.org/x/text v0.3.0 // indirect
88
)

graph/cert_node.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,17 @@ func (c *CertNode) CDNCert() bool {
5757
return false
5858
}
5959

60-
// TLDPlus1Count the number of tld+1 domains in the certificate
61-
func (c *CertNode) TLDPlus1Count() int {
62-
tldPlus1Domains := make(map[string]bool)
60+
// ApexCount the number of tld+1 domains in the certificate
61+
func (c *CertNode) ApexCount() int {
62+
apexDomains := make(map[string]bool)
6363
for _, domain := range c.Domains {
64-
tldPlus1, err := dns.TLDPlus1(domain)
64+
apexDomain, err := dns.ApexDomain(domain)
6565
if err != nil {
6666
continue
6767
}
68-
tldPlus1Domains[tldPlus1] = true
68+
apexDomains[apexDomain] = true
6969
}
70-
return len(tldPlus1Domains)
70+
return len(apexDomains)
7171
}
7272

7373
// ToMap returns a map of the CertNode's fields (weak serialization)

graph/domain_node.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func (d *DomainNode) AddRelatedDomains(domains []string) {
4444
}
4545
}
4646

47-
// CheckForDNS checks for the existence of DNS records for the domain's tld+1
47+
// CheckForDNS checks for the existence of DNS records for the domain's apex
4848
// sets the value to the node and returns the result as well
4949
func (d *DomainNode) CheckForDNS(timeout time.Duration) (bool, error) {
5050
hasDNS, err := dns.HasRecordsCache(d.Domain, timeout)

graph/graph.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func (graph *CertGraph) GetDomainNeighbors(domain string, cdn bool, maxSANsSize
9797
certNode := node.(*CertNode)
9898
if !cdn && certNode.CDNCert() {
9999
//v(domain, "-> CDN CERT")
100-
} else if maxSANsSize > 0 && certNode.TLDPlus1Count() > maxSANsSize {
100+
} else if maxSANsSize > 0 && certNode.ApexCount() > maxSANsSize {
101101
//v(domain, "-> Large CERT")
102102
} else {
103103
for _, neighbor := range certNode.Domains {

0 commit comments

Comments
 (0)