Check HTML Text for SSRF Threats in C/C++
Server-side request forgery, or SSRF for short, is a type of cyber threat that is generally used to target internal systems protected by firewalls that can’t be accessed from the external network. These threats can be deployed via URLs or HTML injection, and in this brief tutorial, we will demonstrate how an API can be used in C/C++ to automatically detect the threats that have been injected into HTML text.
Let’s start things off by installing libcurl into our C/C++ project:
libcurl/7.75.0
After the installation, we can input our HTML text and call the function:
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(curl, CURLOPT_URL, "https://api.cloudmersive.com/validate/text-input/html/check/ssrf");
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Content-Type: application/json");
headers = curl_slist_append(headers, "Apikey: YOUR-API-KEY-HERE");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
const char *data = "\"<string>\"";
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
res = curl_easy_perform(curl);
}
curl_easy_cleanup(curl);
This simple process will allow you to detect this inconspicuous threat that may otherwise be missed. To retrieve your API key, visit the Cloudmersive website to register for a free account; this will provide access to 800 monthly calls across anyof our APIs.