How to Check a URL for Server-side Request Forgery (SSRF) in Go
Avoid sneaky Server-Side Request Forgery attacks with ease — check a suspicious URL using the SSRF iteration of the Cloudmersive Security API. Take advantage of ready-to-run code below in Go to add this API to your project, or easily choose code in one of 12 other programming languages on the Cloudmersive API Console.
If you’re working in Go, copy in the below code to make your connection. If you’re lacking a Cloudmersive API key, be sure to visit our website (www.cloudmersive.com) and make a free account with zero commitments. You’ll get an API key with 800 uses per month including any API from our catalogue of options.
package mainimport (
"fmt"
"strings"
"net/http"
"io/ioutil"
)func main() {url := "https://api.cloudmersive.com/security/threat-detection/network/url/ssrf/detect"
method := "POST"payload := strings.NewReader(`{
"URL": "<string>",
"BlockedDomains": [
"<string>",
"<string>"
]
}`)client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Apikey", "YOUR-API-KEY-HERE")res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}