MCPcopy
hub / github.com/jaeles-project/gospider / getVirusTotalURLs

Function getVirusTotalURLs

core/othersource.go:137–173  ·  view source on GitHub ↗
(domain string, noSubs bool)

Source from the content-addressed store, hash-verified

135}
136
137func getVirusTotalURLs(domain string, noSubs bool) ([]wurl, error) {
138 out := make([]wurl, 0)
139
140 apiKey := os.Getenv("VT_API_KEY")
141 if apiKey == "" {
142 Logger.Warnf("You are not set VirusTotal API Key yet.")
143 return out, nil
144 }
145
146 fetchURL := fmt.Sprintf(
147 "https://www.virustotal.com/vtapi/v2/domain/report?apikey=%s&domain=%s",
148 apiKey,
149 domain,
150 )
151
152 resp, err := http.Get(fetchURL)
153 if err != nil {
154 return out, err
155 }
156 defer resp.Body.Close()
157
158 wrapper := struct {
159 URLs []struct {
160 URL string `json:"url"`
161 } `json:"detected_urls"`
162 }{}
163
164 dec := json.NewDecoder(resp.Body)
165
166 err = dec.Decode(&wrapper)
167
168 for _, u := range wrapper.URLs {
169 out = append(out, wurl{url: u.URL})
170 }
171
172 return out, nil
173}
174
175func getOtxUrls(domain string, noSubs bool) ([]wurl, error) {
176 var urls []wurl

Callers 1

TestGetVirusTotalURLsFunction · 0.85

Calls 1

CloseMethod · 0.80

Tested by 1

TestGetVirusTotalURLsFunction · 0.68