From 6e087b14cc39776a00d294c7a0f929fef6dd03b9 Mon Sep 17 00:00:00 2001 From: Ice3man543 Date: Tue, 3 Dec 2019 21:16:36 +0530 Subject: [PATCH] Removed facebook + misc --- .../sources/certspotterold/certspotterold.go | 0 pkg/subscraping/sources/digicert/digicert.go | 0 .../sources/digicert/digicert_test.go | 0 pkg/subscraping/sources/facebook/facebook.go | 100 ------------------ 4 files changed, 100 deletions(-) mode change 100644 => 100755 pkg/subscraping/sources/certspotterold/certspotterold.go mode change 100644 => 100755 pkg/subscraping/sources/digicert/digicert.go mode change 100644 => 100755 pkg/subscraping/sources/digicert/digicert_test.go delete mode 100755 pkg/subscraping/sources/facebook/facebook.go diff --git a/pkg/subscraping/sources/certspotterold/certspotterold.go b/pkg/subscraping/sources/certspotterold/certspotterold.go old mode 100644 new mode 100755 diff --git a/pkg/subscraping/sources/digicert/digicert.go b/pkg/subscraping/sources/digicert/digicert.go old mode 100644 new mode 100755 diff --git a/pkg/subscraping/sources/digicert/digicert_test.go b/pkg/subscraping/sources/digicert/digicert_test.go old mode 100644 new mode 100755 diff --git a/pkg/subscraping/sources/facebook/facebook.go b/pkg/subscraping/sources/facebook/facebook.go deleted file mode 100755 index 8c88d4c..0000000 --- a/pkg/subscraping/sources/facebook/facebook.go +++ /dev/null @@ -1,100 +0,0 @@ -package facebook - -import ( - "errors" - "fmt" - "strings" - - jsoniter "github.com/json-iterator/go" - "github.com/subfinder/subfinder/pkg/subscraping" -) - -type authResponse struct { - AccessToken string `json:"access_token"` -} - -type response struct { - Data []struct { - Domains []string `json:"domains"` - } `json:"data"` - - Paging struct { - Next string `json:"next"` - } `json:"paging"` -} - -// Source is the passive scraping agent -type Source struct{} - -// Run function returns all subdomains found with the service -func (s *Source) Run(domain string, session *subscraping.Session) <-chan subscraping.Result { - results := make(chan subscraping.Result) - - go func() { - if session.Keys.FacebookAppID == "" || session.Keys.FacebookAppSecret == "" { - close(results) - return - } - - resp, err := session.NormalGet(fmt.Sprintf("https://graph.facebook.com/oauth/access_token?client_id=%s&client_secret=%s&grant_type=client_credentials", session.Keys.FacebookAppID, session.Keys.FacebookAppSecret)) - if err != nil { - results <- subscraping.Result{Source: s.Name(), Type: subscraping.Error, Error: err} - close(results) - return - } - - auth := authResponse{} - err = jsoniter.NewDecoder(resp.Body).Decode(&auth) - if err != nil { - results <- subscraping.Result{Source: s.Name(), Type: subscraping.Error, Error: err} - close(results) - return - } - - if auth.AccessToken == "" { - results <- subscraping.Result{Source: s.Name(), Type: subscraping.Error, Error: errors.New("no access token in Facebook API response")} - close(results) - return - } - - fetchURL := fmt.Sprintf("https://graph.facebook.com/certificates?fields=domains&access_token=%s&query=*.%s", auth.AccessToken, domain) - - wrapper := new(response) - for { - resp, err := session.NormalGet(fetchURL) - if err != nil { - results <- subscraping.Result{Source: s.Name(), Type: subscraping.Error, Error: err} - close(results) - return - } - - err = jsoniter.NewDecoder(resp.Body).Decode(&wrapper) - if err != nil { - results <- subscraping.Result{Source: s.Name(), Type: subscraping.Error, Error: err} - close(results) - return - } - - for _, data := range wrapper.Data { - for _, d := range data.Domains { - d := strings.TrimPrefix(strings.ToLower(d), "*.") - - results <- subscraping.Result{Source: s.Name(), Type: subscraping.Subdomain, Value: d} - } - } - - fetchURL = wrapper.Paging.Next - if fetchURL == "" { - break - } - } - close(results) - }() - - return results -} - -// Name returns the name of the source -func (s *Source) Name() string { - return "facebook" -}