From 9f2fa126bd8e8c4cbd80bedfae56f6a8bbe94de5 Mon Sep 17 00:00:00 2001 From: mux1ng <49070782+mux1ng@users.noreply.github.com> Date: Mon, 21 Aug 2023 02:46:29 +0800 Subject: [PATCH] Update virustotal.go --- .../subscraping/sources/virustotal/virustotal.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/v2/pkg/subscraping/sources/virustotal/virustotal.go b/v2/pkg/subscraping/sources/virustotal/virustotal.go index 0abe5c5bb..49e728de1 100644 --- a/v2/pkg/subscraping/sources/virustotal/virustotal.go +++ b/v2/pkg/subscraping/sources/virustotal/virustotal.go @@ -12,7 +12,11 @@ import ( ) type response struct { - Subdomains []string `json:"subdomains"` + Data []Object `json:"data"` +} + +type Object struct { + Id string `json:"id"` } // Source is the passive scraping agent @@ -41,7 +45,9 @@ func (s *Source) Run(ctx context.Context, domain string, session *subscraping.Se return } - resp, err := session.SimpleGet(ctx, fmt.Sprintf("https://www.virustotal.com/vtapi/v2/domain/report?apikey=%s&domain=%s", randomApiKey, domain)) + headers := map[string]string{"x-apikey": randomApiKey} + + resp, err := session.Get(ctx, fmt.Sprintf("https://www.virustotal.com/api/v3/domains/%s/subdomains?limit=1000", domain), "", headers) if err != nil { results <- subscraping.Result{Source: s.Name(), Type: subscraping.Error, Error: err} s.errors++ @@ -60,8 +66,8 @@ func (s *Source) Run(ctx context.Context, domain string, session *subscraping.Se resp.Body.Close() - for _, subdomain := range data.Subdomains { - results <- subscraping.Result{Source: s.Name(), Type: subscraping.Subdomain, Value: subdomain} + for _, subdomain := range data.Data { + results <- subscraping.Result{Source: s.Name(), Type: subscraping.Subdomain, Value: subdomain.Id} s.results++ } }()