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))
}

--

--

--

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Sniping honeypots on Ethereum

Axie Infinity Loses Over $600 Million in Crypto Following Ronin Network Hack

{UPDATE} V-Ball Hack Free Resources Generator

Interesting Article on a Found Password Database

$RAZE Liquidity Migration to Uniswap V3

FAQ of Assure Golden Tester Program

Self-Reflective Blog Post Journal — Week 4Module 4: Cybersecurity Culture

mStable Process Quality Score rated as 93% from DeFiSafety

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Cloudmersive

Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

More from Medium

Detect XXE Attacks from XML Text Input in Go

How to create a CLI in Golang

Data Types In Go — II