Jimesh
Jimesh

Reputation: 529

Scan Uploaded File using Sophos Labs Intelix in c#

I am new to SophosLabs Intelix. I am trying to build a sample in my ASP .Net Application(webforms/MVC) in which I want to run an Antivirus Scan on the uploaded file by the User. If the Uploaded file is clean I want to upload it to the server else I want to cancel the operation. I want to specifically use SophosLabs Intelix for the functionality. It would be great if someone can guide me regarding this functionality. A code sample in C# would be appreciated a lot. Thanks in advance for your help.

Sample:

if(file.HasFile)
{
     //run an antivirus scan
     //result
     if(result == NoThreat){
         //Uploaded Successfully
     }
     else{
         //File contains a virus. Upload failed!
     }
}
else{
     //Please select a file to upload!
}

Upvotes: 3

Views: 793

Answers (1)

I suggest to start with the implementation of OAUTH 2 authentication request. You can find some ideas here: How do I get an OAuth 2.0 authentication token in C#

As soon as you have the access_token you can use if for /reports/?sha256=... query. It may return the report immediately. If it does not return any data (404) this request was free and you can POST the file to the root endpoint "/" for analysis. It can take a few seconds/minutes, during that you should poll the report from /reports/{job_id} endpoint as long as you get it.

If you cannot wait minutes for decision data, you may use the File Hash Lookup API as well that returns immediately. It may give a reputationScore between 30..69 so cannot decide how dangerous the file is, but in this case you can still perform a static or dynamic analysis on it.

Upvotes: 1

Related Questions