How to Quarantine an Infected File in a Zip Archive using C/C++

Cloudmersive
2 min readAug 22, 2023

--

When we detect virus or malware signatures in a file, we need to act on that file immediately. We can delete the file outright, or we can quarantine the file so it can’t infect other files in our system.

Using the below code, we can automatically quarantine infected files in an encrypted zip archive, and we can choose between AES-256 (default/recommended), AES-128 or PK-Zip (not recommended) encryption algorithms. This will keep our infected file separate from the rest of our system while we plan out next steps for handling the threat.

We can structure our API call in C/C++ by first installing libcurl in our project:

libcurl/7.75.0

And then adding the ready-to-run examples below into our file:

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/convert/archive/zip/create/quarantine");
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, "password: <string>");
headers = curl_slist_append(headers, "encryptionAlgorithm: <string>");
headers = curl_slist_append(headers, "Content-Type: application/x-www-form-urlencoded");
headers = curl_slist_append(headers, "Apikey: YOUR-API-KEY-HERE");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
const char *data = "inputFile1=%3Cbinary%3E";
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
res = curl_easy_perform(curl);
}
curl_easy_cleanup(curl);

We can now authorize our requests with a free-tier API key and perform up to 800 quarantine operations per month (with no commitments upon reaching that limit).

It’s just that easy to quarantine threats in your system!

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

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

No responses yet