Check Text Inputs for SQL Injection Attacks in C/C++

Cloudmersive
1 min readJul 6, 2021

--

The amount of SQL injection attacks that have been reported by organizations has been multiplying over the past several years. Retail companies have proven to be particularly susceptible due to the combination of the nature of the attacks to target web forms, and the companies’ reliance on check-out forms for their websites. The following API can be run in C/C++ assist in providing protection to websites and applications by detecting SQL injection attacks from a single text input and allowing you to define the threat detection level you want to utilize.

We will begin by installing libcurl into our C/C++ project:

libcurl/7.75.0

Next, we can call the function with the below example code:

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/check/sql-injection");
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, "detectionLevel: <string>");
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 will provide a prompt result, with an indicator of whether your text is SQL injection-free!

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

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

No responses yet