You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

125 lines
4.6 KiB

2 years ago
# Xvirus SDK C#
2 years ago
2 years ago
Xvirus SDK 4.1 C# bindings.
2 years ago
## Table of Contents
2 years ago
- [Xvirus SDK C#](#xvirus-sdk-c)
2 years ago
- [Table of Contents](#table-of-contents)
- [Minimum Requirements](#minimum-requirements)
- [Changelog](#changelog)
- [Known Issues](#known-issues)
- [Get Started](#get-started)
- [Avaiable Functions](#avaiable-functions)
2 years ago
- [Model](#model)
2 years ago
- [Settings](#settings)
2 years ago
- [Exceptions](#exceptions)
2 years ago
## Minimum Requirements
2 years ago
To use Xvirus SDK you need:
2 years ago
2 years ago
- .NET 7 SDK - [download](https://dotnet.microsoft.com/en-us/download/dotnet/7.0)
2 years ago
## Changelog
2 years ago
- Version **4.1**:
- Upgraded from .NET 5 to .NET 7
- C++ bindings now also support Linux
- Removed Minimum Requirements on C++ bindings and CLI
- Changed how exceptions are handled in C++ bindings
- Version **4.0**:
- Completely redone in .NET 5
- Now supports Linux (CLI and C# bindings only)
- Added XvirusAI scan engine (BETA)
- Scan speed is up to 2x faster
- Fixed memory usage spike when scanning large files
- Removed file size limit for scanned files by default
- The checkUpdate function can now check for SDK updates
- Added 3 new settings "EnableAIScan", "MaxScanLength" and "DatabaseVersion"
2 years ago
## Known Issues
- XvirusAI engine is still in BETA. It is not recomended to use in production yet.
2 years ago
- XvirusAI engine does not work in C++ bindings.
2 years ago
- The checkUpdate function can now check for SDK updates but can't update it
## Get Started
2 years ago
The "`example`" folder contains an example project on how to import and use Xvirus SDK in C# (.NET 7).
2 years ago
2 years ago
You can run it by building it and then running executable file in the output folder.
2 years ago
## Avaiable Functions
2 years ago
You have the following functions available:
2 years ago
2 years ago
- **Load** - Loads Xvirus Scan Engine into memory, if set `force`=true it will reload the scan engine, even if it is already loaded.
- **Unload** - Unloads Xvirus Scan Engine from memory.
- **Scan** - Scans the file located at `filepath`. It will return a [`ScanResult`](#Model).
- **ScanAsString** - Scans the file located at `filepath`. It will return one of the following strings:
2 years ago
- "**Safe**" - If no malware is detected.
- "**Malware**" - If malware is detected but the name isn't known.
- **_Malware Name_** - If it is malware from a known family (example: "Trojan.Downloader").
- "**AI.{aiScore}**" - Score of the file using XvirusAI from 0 to 100, the higher the score the more probable it is malicious (example: "AI.99").
- "**File not found!**" - If no file is found in the submited path.
- "**File too big!**" - If the file size is bigger than the set limit.
- "**Could not get file hash!**" - There was an error calculating the hash of the file.
2 years ago
- **CheckUpdates** - Checks and updates the databases and AI engine to the most recent versions. If `checkSDKUpdates`=true then it will also check for SDK updates. If `loadDBAfterUpdate`=true then it will reload the Xvirus Scan Engine after the update is done. It can return the following strings:
2 years ago
- "**There is a new SDK version available!**"
- "**Database was updated!**"
- "**Database is up-to-date!**"
2 years ago
- **GetSettings** - returns object representation of the `settings.json` file.
- **GetSettingsAsString** - returns a string representation of the `settings.json` file.
- **Version** - returns the version of the SDK/CLI.
2 years ago
## Model
2 years ago
The `scan` function returns a class `ScanResult` with the following properties:
2 years ago
2 years ago
```c#
public class ScanResult
{
public bool IsMalware { get; set; } // true if malware
2 years ago
public string Name { get; set; } // detection name
2 years ago
public double MalwareScore { get; set; } // between 0 and 1, higher score means more likely to be malware, -1 if there was an error
}
2 years ago
```
## Settings
Settings are located in the "`settings.json`" file in the root folder of the SDK. There are 4 avaiable options:
- **EnableHeuristics** - Enables heuristics scanning of files. Default: _true_
- **EnableAIScan** - Enables XvirusAI scan engine. This feature is still in BETA. Default: _false_
- **MaxScanLength** - Maximum file size to be scanned in bytes. If set "null" then there is no limit. Default: _null_
- **DatabaseVersion** - KeyValue list of database files version. This is updated automatically when using the "checkUpdate()" function.
Example of a `settings.json` file:
```JSON
{
"EnableHeuristics": true,
"EnableAIScan": false,
"MaxScanLength": null,
"DatabaseVersion": {
"AIModel": 0,
"MainDB": 0,
"DailyDB": 0,
"WhiteDB": 0,
"DailywlDB": 0,
"HeurDB": 0,
"HeurDB2": 0,
"MalvendorDB": 0
}
}
```
## Exceptions
2 years ago
If any of the functions fail it may return an [exception](https://docs.microsoft.com/en-us/dotnet/csharp/fundamentals/exceptions/).
2 years ago
All exceptions are logged in the `errorlog.txt` file.