cdncheck

package module
v0.0.0-...-6e113c1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 14, 2024 License: MIT Imports: 10 Imported by: 0

README

cdncheck

cdncheck 做了一些修改,方便构建信息收集自动化时的子域名 cdn 识别模块。

go get -u github.com/fuyoumingyan/cdncheck@v1.0.9.1
package main

import (
	"encoding/json"
	"fmt"
	"github.com/fuyoumingyan/cdncheck"
)

func main() {
	client := cdncheck.New()
	domain := "www.aliyun.com"
	domainInfo, err := client.CheckDomain(domain)
	if err != nil {
		return
	}
	jsonData, err := json.MarshalIndent(domainInfo, "", "    ")
	if err != nil {
		return
	}
	fmt.Println(string(jsonData))
}
image-20240114143134654

感谢 projectdiscovery 开源及 mabangde 师傅对于国内厂商的 IP 段及 CNAME 整理 .

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultCDNProviders   string
	DefaultWafProviders   string
	DefaultCloudProviders string
)
View Source
var DefaultResolvers = []string{
	"180.76.76.76:53",
	"112.124.47.27:53",
	"1.1.1.1:53",
	"223.5.5.5:53",
	"223.6.6.6:53",
	"1.0.0.1:53",
	"8.8.8.8:53",
	"8.8.4.4:53",
}

DefaultResolvers trusted (taken from fastdialer)

Functions

This section is empty.

Types

type Client

type Client struct {
	sync.Once
	// contains filtered or unexported fields
}

Client checks for CDN based IPs which should be excluded during scans since they belong to third party firewalls.

func New

func New() *Client

New creates cdncheck client with default options NewWithOpts should be preferred over this function

func NewWithOpts

func NewWithOpts(MaxRetries int, resolvers []string) (*Client, error)

NewWithOpts creates cdncheck client with custom options

func (*Client) Check

func (c *Client) Check(ip net.IP) (matched bool, value string, itemType string, err error)

Check checks if Address belongs to one of CDN, WAF and Cloud . It is generic method for Checkxxx methods

func (*Client) CheckCDN

func (c *Client) CheckCDN(ip net.IP) (matched bool, value string, err error)

CheckCDN checks if an Address is contained in the Cdn denylist

func (*Client) CheckCloud

func (c *Client) CheckCloud(ip net.IP) (matched bool, value string, err error)

CheckCloud checks if an Address is contained in the Cloud denylist

func (*Client) CheckDNSResponse

func (c *Client) CheckDNSResponse(dnsResponse *retryabledns.DNSData) (matched bool, value string, itemType string, err error)

CheckDNSResponse is same as CheckDomainWithFallback but takes DNS response as input

func (*Client) CheckDomain

func (c *Client) CheckDomain(domain string) (*DomainInfo, error)

func (*Client) CheckDomainWithFallback

func (c *Client) CheckDomainWithFallback(domain string) (matched bool, value string, itemType string, err error)

Check Domain with fallback checks if Domain belongs to one of CDN, WAF and Cloud . It is generic method for Checkxxx methods Since input is Domain, as a fallback it queries CNAME records and checks if Domain is WAF

func (*Client) CheckIP

func (c *Client) CheckIP(ipStr string) *IpInfo

func (*Client) CheckSuffix

func (c *Client) CheckSuffix(fqdns ...string) (isCDN bool, provider string, itemType string, err error)

CheckFQDN checks if fqdns are known Cloud ones

func (*Client) CheckWAF

func (c *Client) CheckWAF(ip net.IP) (matched bool, value string, err error)

CheckWAF checks if an Address is contained in the Waf denylist

func (*Client) CheckWappalyzer

func (c *Client) CheckWappalyzer(data map[string]struct{}) (isCDN bool, provider string, err error)

CheckWappalyzer checks if the wappalyzer detection are a part of CDN

func (*Client) Checks

func (c *Client) Checks(ip net.IP) map[string]string

type DomainInfo

type DomainInfo struct {
	Domain  string   `json:"domain"`
	Cdn     string   `json:"cdn"`
	Waf     string   `json:"waf"`
	Cloud   string   `json:"cloud"`
	Address []string `json:"address"`
	CNAME   []string `json:"cname"`
}

type InputCompiled

type InputCompiled struct {
	// CDN contains a list of ranges for CDN cidrs
	CDN map[string][]string `yaml:"Cdn,omitempty" json:"Cdn,omitempty"`
	// WAF contains a list of ranges for WAF cidrs
	WAF map[string][]string `yaml:"Waf,omitempty" json:"Waf,omitempty"`
	// Cloud contains a list of ranges for Cloud cidrs
	Cloud map[string][]string `yaml:"Cloud,omitempty" json:"Cloud,omitempty"`
	// Common contains a list of suffixes for major sources
	Common map[string][]string `yaml:"common,omitempty" json:"common,omitempty"`
}

InputCompiled contains a compiled list of input structure

type IpInfo

type IpInfo struct {
	Ip    string `json:"ip"`
	Cdn   string `json:"cdn"`
	Waf   string `json:"waf"`
	Cloud string `json:"cloud"`
}

Directories

Path Synopsis
cmd
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL