这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Changes from all 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
16 changes: 13 additions & 3 deletions v2/pkg/subscraping/sources/commoncrawl/commoncrawl.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,21 @@ import (
"context"
"fmt"
"net/url"
"strconv"
"strings"
"time"

jsoniter "github.com/json-iterator/go"

"github.com/projectdiscovery/subfinder/v2/pkg/subscraping"
)

const indexURL = "https://index.commoncrawl.org/collinfo.json"
const (
indexURL = "https://index.commoncrawl.org/collinfo.json"
maxYearsBack = 5
)

var year = time.Now().Year()

type indexResponse struct {
ID string `json:"id"`
Expand All @@ -23,8 +30,6 @@ type indexResponse struct {
// Source is the passive scraping agent
type Source struct{}

var years = [...]string{"2020", "2019", "2018", "2017"}

// Run function returns all subdomains found with the service
func (s *Source) Run(ctx context.Context, domain string, session *subscraping.Session) <-chan subscraping.Result {
results := make(chan subscraping.Result)
Expand All @@ -48,6 +53,11 @@ func (s *Source) Run(ctx context.Context, domain string, session *subscraping.Se
}
resp.Body.Close()

years := make([]string, 0)
for i := 0; i < maxYearsBack; i++ {
years = append(years, strconv.Itoa(year-i))
}

searchIndexes := make(map[string]string)
for _, year := range years {
for _, index := range indexes {
Expand Down