Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose CDN Name in output and json #499

Merged
merged 3 commits into from
Feb 7, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions common/httpx/cdn.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
)

// CdnCheck verifies if the given ip is part of Cdn ranges
func (h *HTTPX) CdnCheck(ip string) (bool, error) {
func (h *HTTPX) CdnCheck(ip string) (bool, string, error) {
if h.cdn == nil {
return false, fmt.Errorf("cdn client not configured")
return false, "", fmt.Errorf("cdn client not configured")
}

return h.cdn.Check(net.ParseIP((ip)))
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ require (
github.com/microcosm-cc/bluemonday v1.0.17
github.com/miekg/dns v1.1.43 // indirect
github.com/pkg/errors v0.9.1
github.com/projectdiscovery/cdncheck v0.0.2
github.com/projectdiscovery/cdncheck v0.0.3-0.20220207103122-d90a1140381a
github.com/projectdiscovery/clistats v0.0.8
github.com/projectdiscovery/cryptoutil v0.0.0-20210805184155-b5d2512f9345
github.com/projectdiscovery/fastdialer v0.0.14-0.20211117222717-6599e7bc586e
Expand Down Expand Up @@ -52,10 +52,10 @@ require (
github.com/cnf/structhash v0.0.0-20201127153200-e1b16c1ebc08 // indirect
github.com/dimchansky/utfbom v1.1.1 // indirect
github.com/gorilla/css v1.0.0 // indirect
github.com/json-iterator/go v1.1.11 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/karrick/godirwalk v1.16.1 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/projectdiscovery/blackrock v0.0.0-20210415162320-b38689ae3a2e // indirect
github.com/projectdiscovery/networkpolicy v0.0.1 // indirect
github.com/projectdiscovery/reflectutil v0.0.0-20210804085554-4d90952bf92f // indirect
Expand Down
8 changes: 8 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpO
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.11 h1:uVUAXhF2To8cbw/3xN3pxj6kk7TYKs98NIrTqPlMWAQ=
github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U=
Expand Down Expand Up @@ -82,6 +84,8 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJ
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/ngdinhtoan/glide-cleanup v0.2.0/go.mod h1:UQzsmiDOb8YV3nOsCxK/c9zPpCZVNoHScRE3EO9pVMM=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
Expand All @@ -105,6 +109,10 @@ github.com/projectdiscovery/blackrock v0.0.0-20210415162320-b38689ae3a2e h1:7bwa
github.com/projectdiscovery/blackrock v0.0.0-20210415162320-b38689ae3a2e/go.mod h1:/IsapnEYiWG+yEDPXp0e8NWj3npzB9Ccy9lXEUJwMZs=
github.com/projectdiscovery/cdncheck v0.0.2 h1:ZAaezMvVioC/8fC8iilylGT4FBBryzQdXHow+lHnPOE=
github.com/projectdiscovery/cdncheck v0.0.2/go.mod h1:+vB8400d1Kxq5aDoi/XkVcdvpiqQjSrYJ8bRfUDdymQ=
github.com/projectdiscovery/cdncheck v0.0.3-0.20220115001641-2550ce07bde6 h1:pUr8UiK2fPhMmk8qk0ijXH5IaJAtHY47+BODmx62SlU=
github.com/projectdiscovery/cdncheck v0.0.3-0.20220115001641-2550ce07bde6/go.mod h1:+vB8400d1Kxq5aDoi/XkVcdvpiqQjSrYJ8bRfUDdymQ=
github.com/projectdiscovery/cdncheck v0.0.3-0.20220207103122-d90a1140381a h1:U96yKkM0FosBpclr4HHgkeloMKnFexCKPpTt9KEZ1UY=
github.com/projectdiscovery/cdncheck v0.0.3-0.20220207103122-d90a1140381a/go.mod h1:EevMeCG1ogBoUJYaa0Mv9R1VUboDm/DiynId7DboKy0=
github.com/projectdiscovery/clistats v0.0.8 h1:tjmWb15mqsPf/yrQXVHLe2ThZX/5+mgKSfZBKWWLh20=
github.com/projectdiscovery/clistats v0.0.8/go.mod h1:lV6jUHAv2bYWqrQstqW8iVIydKJhWlVaLl3Xo9ioVGg=
github.com/projectdiscovery/cryptoutil v0.0.0-20210805184155-b5d2512f9345 h1:jT6f/cdOpLkp9GAfRrxk57BUjYfIrR8E+AjMv5H5U4U=
Expand Down
8 changes: 5 additions & 3 deletions runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -1154,9 +1154,9 @@ retry:
builder.WriteString(fmt.Sprintf(" [%s]", cnames[0]))
}

isCDN, err := hp.CdnCheck(ip)
isCDN, cdnName, err := hp.CdnCheck(ip)
if scanopts.OutputCDN && isCDN && err == nil {
builder.WriteString(" [cdn]")
builder.WriteString(fmt.Sprintf(" [%s]", cdnName))
}

if scanopts.OutputResponseTime {
Expand Down Expand Up @@ -1339,6 +1339,7 @@ retry:
A: ips,
CNAMEs: cnames,
CDN: isCDN,
CDNName: cdnName,
ResponseTime: resp.Duration.String(),
Technologies: technologies,
FinalURL: finalURL,
Expand Down Expand Up @@ -1391,6 +1392,7 @@ type Result struct {
Pipeline bool `json:"pipeline,omitempty" csv:"pipeline"`
HTTP2 bool `json:"http2,omitempty" csv:"http2"`
CDN bool `json:"cdn,omitempty" csv:"cdn"`
CDNName string `json:"cdn-name,omitempty" csv:"cdn-name"`
ResponseTime string `json:"response-time,omitempty" csv:"response-time"`
Technologies []string `json:"technologies,omitempty" csv:"technologies"`
Chain []httpx.ChainItem `json:"chain,omitempty" csv:"chain"`
Expand Down Expand Up @@ -1489,7 +1491,7 @@ func (r *Runner) skipCDNPort(host string, port string) bool {
// pick the first ip as target
hostIP := dnsData.A[0]

isCdnIP, err := r.hp.CdnCheck(hostIP)
isCdnIP, _, err := r.hp.CdnCheck(hostIP)
if err != nil {
return false
}
Expand Down