Compare commits

...

3 Commits

Author SHA1 Message Date
Dani Santos fe5c5264ef Version 4.2 1 year ago
Dani Santos 5524afb2a0 removed pdb files 2 years ago
Dani Santos f644f4b1d7 Version 4.1 2 years ago
  1. 79
      README.md
  2. BIN
      bin/Ijwhost.dll
  3. BIN
      bin/Linux/XvirusSDK.so
  4. 0
      bin/Linux/errorlog.txt
  5. BIN
      bin/Linux/libFastTreeNative.so
  6. BIN
      bin/Linux/libLdaNative.so
  7. 1
      bin/Linux/settings.json
  8. BIN
      bin/Microsoft.ML.Core.dll
  9. BIN
      bin/Microsoft.ML.CpuMath.dll
  10. BIN
      bin/Microsoft.ML.Data.dll
  11. BIN
      bin/Microsoft.ML.DataView.dll
  12. BIN
      bin/Microsoft.ML.FastTree.dll
  13. BIN
      bin/Microsoft.ML.KMeansClustering.dll
  14. BIN
      bin/Microsoft.ML.PCA.dll
  15. BIN
      bin/Microsoft.ML.StandardTrainers.dll
  16. BIN
      bin/Microsoft.ML.Transforms.dll
  17. BIN
      bin/Microsoft.ML.dll
  18. BIN
      bin/Newtonsoft.Json.dll
  19. BIN
      bin/PeNet.Asn1.dll
  20. BIN
      bin/PeNet.dll
  21. BIN
      bin/System.CodeDom.dll
  22. BIN
      bin/System.Security.Cryptography.Pkcs.dll
  23. BIN
      bin/Validation.dll
  24. 0
      bin/Windows/FastTreeNative.dll
  25. 0
      bin/Windows/LdaNative.dll
  26. BIN
      bin/Windows/XvirusSDK.dll
  27. 0
      bin/Windows/errorlog.txt
  28. 16
      bin/Windows/settings.json
  29. 2097
      bin/XescSDK.deps.json
  30. BIN
      bin/XescSDK.dll
  31. 12
      bin/XescSDK.runtimeconfig.json
  32. BIN
      bin/Xunit.SkippableFact.dll
  33. BIN
      bin/xunit.abstractions.dll
  34. BIN
      bin/xunit.core.dll
  35. BIN
      bin/xunit.execution.dotnet.dll
  36. 169
      bin/xvneng.deps.json
  37. BIN
      bin/xvneng.dll
  38. BIN
      bin/xvneng.exp
  39. BIN
      bin/xvneng.lib
  40. 12
      bin/xvneng.runtimeconfig.json
  41. 33
      example/xvbdc.cpp
  42. 8
      example/xvbdc.vcxproj
  43. 42
      example/xvneng.h
  44. BIN
      example/xvneng.lib
  45. BIN
      functions.JPG
  46. 42
      headers/xvneng.h

79
README.md

@ -1,6 +1,6 @@
# Xvirus SDK C++
Xvirus SDK 4.0.5 C++ bindings.
Xvirus SDK 4.2 C++ bindings.
## Table of Contents
@ -17,38 +17,65 @@ Xvirus SDK 4.0.5 C++ bindings.
## Minimum Requirements
To run Xvirus SDK you need:
- .NET 5 Runtime - [download](https://dotnet.microsoft.com/download/dotnet/thank-you/runtime-5.0.11-windows-x64-installer)
- Visual C++ Redistributable 2019 - [download](https://aka.ms/vs/16/release/vc_redist.x64.exe)
The following Operating Systems are supported:
- Windows:
- Windows 10 1607
- Windows 11 22000
- Windows Server 2012
- Windows Server Core 2012
- Linux (glibc 2.17):
- Alpine Linux 3.15
- CentOS 7
- Debian 10
- Fedora 36
- openSUSE 15
- Oracle Linux 7
- Red Hat Enterprise Linux 7
- SUSE Enterprise Linux (SLES) 12 SP2
- Ubuntu 18.04
## Changelog
- 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"
- Version **4.2**:
- Reduced glibc minimum version to 2.17 on Linux
- Added "Logging()" function to enable/disable logging
- Added "BaseFolder()" function to set a custom base folder
- Added new setting "DatabaseFolder" to set the Database folder path
- Fixed C++ binding will return "Success=false" correctly when failing to scan a file
- Version **4.1**:
- Upgraded from .NET 5 to .NET 7
- C++ bindings now also support Linux
- 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"
## Known Issues
- XvirusAI engine is still in BETA. It is not recomended to use in production yet.
- XvirusAI engine does not work in C++ bindings.
- The checkUpdate function can now check for SDK updates but can't update it
## Get Started
The "`example`" folder contains an example project on how to import and use Xvirus SDK in C++.
This project shows you how to statically load Xvirus SDK using `xvneng.lib`, you can also dinamically load `xvneng.dll` like any other dll, [see](https://stackoverflow.com/questions/8696653/dynamically-load-a-function-from-a-dll).
This project shows you how to dynamically load Xvirus SDK (`XvirusSDK.dll`) for both Windows and Linux and call a function. You can also read more [here](https://stackoverflow.com/questions/8696653/dynamically-load-a-function-from-a-dll).
You can run it by building it, copying the files from the `bin` folder to the output folder of the build and then running `xvbdc.exe`.
## Avaiable Functions
You can find the declaration of all functions and structs in the file `xvneng.h` located in the "headers" folder.
You can find the definition of all functions and structs in the file `xvneng.h` located in the "headers" folder.
- **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.
@ -66,6 +93,8 @@ You can find the declaration of all functions and structs in the file `xvneng.h`
- "**Database was updated!**"
- "**Database is up-to-date!**"
- **getSettings** - returns a string representation of the `settings.json` file.
- **logging** - Sets and return if `Logging` is enabled. If `enableLogging` Null value is provided it will only return.
- **baseFolder** - Sets and return the `BaseFolder` path. If `baseFolder` Null value is provided it will only return.
- **version** - returns the version of the SDK/CLI.
![functions](./functions.JPG)
@ -76,19 +105,32 @@ The `scan` function returns a struct `ScanResult` with the following properties:
```c++
struct ScanResult {
bool sucess; // true if scan was sucessful
bool isMalware; // true if malware
double score; // between 0 and 1, higher score means more likely to be malware, -1 if there was an error
char* name; // detection name
wchar_t* name; // detection name
wchar_t* error; // error message, only has value if success=false
};
```
All other functions return a struct `ActionResult` with the following properties:
```c++
struct ActionResult {
bool sucess; // true if action was sucessful
wchar_t* result; // result message, only has value if success=true
wchar_t* error; // error message, only has value if success=false
};
```
## Settings
Settings are located in the "`settings.json`" file in the root folder of the SDK. There are 4 avaiable options:
Settings are located in the "`settings.json`" file in the root folder of the SDK. There are 5 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_
- **DatabaseFolder** - Path to the database folder, it accepts both relative and absolute paths. Default: _"Database"_
- **DatabaseVersion** - KeyValue list of database files version. This is updated automatically when using the "checkUpdate()" function.
Example of a `settings.json` file:
@ -98,6 +140,7 @@ Example of a `settings.json` file:
"EnableHeuristics": true,
"EnableAIScan": false,
"MaxScanLength": null,
"DatabaseFolder": "Database",
"DatabaseVersion": {
"AIModel": 0,
"MainDB": 0,
@ -113,6 +156,6 @@ Example of a `settings.json` file:
## Exceptions
If any of the functions fail it may return an [exception](https://www.cplusplus.com/doc/tutorial/exceptions/).
If any of the functions fails the `success` property returns `false` and the `error` property contains the error message.
All exceptions are logged in the `errorlog.txt` file.

BIN
bin/Ijwhost.dll

Binary file not shown.

BIN
bin/Linux/XvirusSDK.so

Binary file not shown.

0
bin/errorlog.txt → bin/Linux/errorlog.txt

BIN
bin/Linux/libFastTreeNative.so

Binary file not shown.

BIN
bin/Linux/libLdaNative.so

Binary file not shown.

1
bin/settings.json → bin/Linux/settings.json

@ -2,6 +2,7 @@
"EnableHeuristics": true,
"EnableAIScan": false,
"MaxScanLength": null,
"DatabaseFolder": "Database",
"DatabaseVersion": {
"AIModel": 0,
"MainDB": 0,

BIN
bin/Microsoft.ML.Core.dll

Binary file not shown.

BIN
bin/Microsoft.ML.CpuMath.dll

Binary file not shown.

BIN
bin/Microsoft.ML.Data.dll

Binary file not shown.

BIN
bin/Microsoft.ML.DataView.dll

Binary file not shown.

BIN
bin/Microsoft.ML.FastTree.dll

Binary file not shown.

BIN
bin/Microsoft.ML.KMeansClustering.dll

Binary file not shown.

BIN
bin/Microsoft.ML.PCA.dll

Binary file not shown.

BIN
bin/Microsoft.ML.StandardTrainers.dll

Binary file not shown.

BIN
bin/Microsoft.ML.Transforms.dll

Binary file not shown.

BIN
bin/Microsoft.ML.dll

Binary file not shown.

BIN
bin/Newtonsoft.Json.dll

Binary file not shown.

BIN
bin/PeNet.Asn1.dll

Binary file not shown.

BIN
bin/PeNet.dll

Binary file not shown.

BIN
bin/System.CodeDom.dll

Binary file not shown.

BIN
bin/System.Security.Cryptography.Pkcs.dll

Binary file not shown.

BIN
bin/Validation.dll

Binary file not shown.

0
bin/FastTreeNative.dll → bin/Windows/FastTreeNative.dll

0
bin/LdaNative.dll → bin/Windows/LdaNative.dll

BIN
bin/Windows/XvirusSDK.dll

Binary file not shown.

0
bin/Windows/errorlog.txt

16
bin/Windows/settings.json

@ -0,0 +1,16 @@
{
"EnableHeuristics": true,
"EnableAIScan": false,
"MaxScanLength": null,
"DatabaseFolder": "Database",
"DatabaseVersion": {
"AIModel": 0,
"MainDB": 0,
"DailyDB": 0,
"WhiteDB": 0,
"DailywlDB": 0,
"HeurDB": 0,
"HeurDB2": 0,
"MalvendorDB": 0
}
}

2097
bin/XescSDK.deps.json

File diff suppressed because it is too large

BIN
bin/XescSDK.dll

Binary file not shown.

12
bin/XescSDK.runtimeconfig.json

@ -1,12 +0,0 @@
{
"runtimeOptions": {
"tfm": "net5.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "5.0.0"
},
"configProperties": {
"System.Reflection.Metadata.MetadataUpdater.IsSupported": false
}
}
}

BIN
bin/Xunit.SkippableFact.dll

Binary file not shown.

BIN
bin/xunit.abstractions.dll

Binary file not shown.

BIN
bin/xunit.core.dll

Binary file not shown.

BIN
bin/xunit.execution.dotnet.dll

Binary file not shown.

169
bin/xvneng.deps.json

@ -1,169 +0,0 @@
{
"runtimeTarget": {
"name": "net5.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
"net5.0": {
"xvneng/1.0.0": {
"dependencies": {
"XescSDK": "4.0.5.0"
},
"runtime": {
"xvneng.dll": {}
}
},
"XescSDK/4.0.5.0": {
"runtime": {
"XescSDK.dll": {
"assemblyVersion": "4.0.5.0",
"fileVersion": "4.0.5.0"
}
}
},
"Microsoft.ML.Data/1.0.0.0": {
"runtime": {
"Microsoft.ML.Data.dll": {
"assemblyVersion": "1.0.0.0",
"fileVersion": "1.700.122.15804"
}
}
},
"Microsoft.ML.Core/1.0.0.0": {
"runtime": {
"Microsoft.ML.Core.dll": {
"assemblyVersion": "1.0.0.0",
"fileVersion": "1.700.122.15804"
}
}
},
"Microsoft.ML.DataView/1.0.0.0": {
"runtime": {
"Microsoft.ML.DataView.dll": {
"assemblyVersion": "1.0.0.0",
"fileVersion": "1.700.122.15804"
}
}
},
"PeNet/1.6.1.0": {
"runtime": {
"PeNet.dll": {
"assemblyVersion": "1.6.1.0",
"fileVersion": "1.6.1.0"
}
}
},
"Microsoft.ML.Transforms/1.0.0.0": {
"runtime": {
"Microsoft.ML.Transforms.dll": {
"assemblyVersion": "1.0.0.0",
"fileVersion": "1.700.122.15804"
}
}
},
"Microsoft.ML.FastTree/1.0.0.0": {
"runtime": {
"Microsoft.ML.FastTree.dll": {
"assemblyVersion": "1.0.0.0",
"fileVersion": "1.700.122.15804"
}
}
},
"Microsoft.ML.StandardTrainers/1.0.0.0": {
"runtime": {
"Microsoft.ML.StandardTrainers.dll": {
"assemblyVersion": "1.0.0.0",
"fileVersion": "1.700.122.15804"
}
}
},
"Newtonsoft.Json/10.0.0.0": {
"runtime": {
"Newtonsoft.Json.dll": {
"assemblyVersion": "10.0.0.0",
"fileVersion": "10.0.3.21018"
}
}
},
"Microsoft.ML.CpuMath/1.0.0.0": {
"runtime": {
"Microsoft.ML.CpuMath.dll": {
"assemblyVersion": "1.0.0.0",
"fileVersion": "1.700.122.15804"
}
}
},
"PeNet.Asn1/1.3.3.0": {
"runtime": {
"PeNet.Asn1.dll": {
"assemblyVersion": "1.3.3.0",
"fileVersion": "1.3.3.0"
}
}
}
}
},
"libraries": {
"xvneng/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
},
"XescSDK/4.0.5.0": {
"type": "reference",
"serviceable": false,
"sha512": ""
},
"Microsoft.ML.Data/1.0.0.0": {
"type": "reference",
"serviceable": false,
"sha512": ""
},
"Microsoft.ML.Core/1.0.0.0": {
"type": "reference",
"serviceable": false,
"sha512": ""
},
"Microsoft.ML.DataView/1.0.0.0": {
"type": "reference",
"serviceable": false,
"sha512": ""
},
"PeNet/1.6.1.0": {
"type": "reference",
"serviceable": false,
"sha512": ""
},
"Microsoft.ML.Transforms/1.0.0.0": {
"type": "reference",
"serviceable": false,
"sha512": ""
},
"Microsoft.ML.FastTree/1.0.0.0": {
"type": "reference",
"serviceable": false,
"sha512": ""
},
"Microsoft.ML.StandardTrainers/1.0.0.0": {
"type": "reference",
"serviceable": false,
"sha512": ""
},
"Newtonsoft.Json/10.0.0.0": {
"type": "reference",
"serviceable": false,
"sha512": ""
},
"Microsoft.ML.CpuMath/1.0.0.0": {
"type": "reference",
"serviceable": false,
"sha512": ""
},
"PeNet.Asn1/1.3.3.0": {
"type": "reference",
"serviceable": false,
"sha512": ""
}
}
}

BIN
bin/xvneng.dll

Binary file not shown.

BIN
bin/xvneng.exp

Binary file not shown.

BIN
bin/xvneng.lib

Binary file not shown.

12
bin/xvneng.runtimeconfig.json

@ -1,12 +0,0 @@
{
"runtimeOptions": {
"tfm": "net5.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "5.0.0"
},
"configProperties": {
"System.Reflection.Metadata.MetadataUpdater.IsSupported": false
}
}
}

33
example/xvbdc.cpp

@ -1,7 +1,14 @@
#include <iostream>
#include "xvneng.h"
#ifdef _WIN32
#include "windows.h"
#define symLoad GetProcAddress
#else
#include "dlfcn.h"
#define symLoad dlsym
#endif
using namespace std;
int main (
@ -9,27 +16,25 @@ int main (
char* argv[]
)
{
string info = string ( version () );
#ifdef _WIN32
HINSTANCE handle = LoadLibrary(L"C:\\XvirusSDK\\bin\\Windows\\XvirusSDK.dll"); // changed this to the path of the dll
#else
void* handle = dlopen("C:\\XvirusSDK\\bin\\Linux\\XvirusSDK.so", RTLD_LAZY); // changed this to the path of the so
#endif
try
{
load(false);
}
catch (const std::exception& e )
{
cout << e.what() << endl;
}
VersionFn version = (VersionFn) symLoad(handle, VersionFnKey);
wstring info = wstring(version());
if ( info.length () )
if ( info.length() )
{
cout << info.c_str () << endl;
wcout << info.c_str() << endl;
}
else
{
cout << "N/A" << endl;
wcout << L"N/A" << endl;
}
(void) getchar ();
(void) getchar();
return EXIT_SUCCESS;
}

8
example/xvbdc.vcxproj

@ -29,26 +29,26 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>

42
example/xvneng.h

@ -2,20 +2,40 @@
#ifndef _XVNENG_H
#define _XVNENG_H
#pragma comment ( lib, "xvneng.lib" )
#define LoadFnKey "load"
#define UnloadFnKey "unload"
#define ScanFnKey "scan"
#define ScanAsStringFnKey "scanAsString"
#define CheckUpdatesFnKey "checkUpdates"
#define GetSettingsFnKey "getSettings"
#define LoggingFnKey "logging"
#define BaseFolderFnKey "baseFolder"
#define VersionFnKey "version"
struct ScanResult {
struct ActionResult
{
bool sucess;
wchar_t *result;
wchar_t *error;
};
struct ScanResult
{
bool sucess;
bool isMalware;
double score;
char* name;
wchar_t *name;
wchar_t *error;
};
__declspec(dllimport) void load(bool force);
__declspec(dllimport) void unload();
__declspec(dllimport) ScanResult scan(const wchar_t* filepath);
__declspec(dllimport) char* scanAsString(const wchar_t* filepath);
__declspec(dllimport) char* checkUpdates(bool checkSDKUpdates, bool loadDBAfterUpdate);
__declspec(dllimport) char* getSettings();
__declspec(dllimport) char* version();
typedef ActionResult (*LoadFn)(bool force);
typedef ActionResult (*UnloadFn)();
typedef ScanResult (*ScanFn)(const wchar_t *filepath);
typedef ActionResult (*ScanAsStringFn)(const wchar_t *filepath);
typedef ActionResult (*CheckUpdatesFn)(bool checkSDKUpdates, bool loadDBAfterUpdate);
typedef ActionResult (*GetSettingsFn)();
typedef bool (*LoggingFn)(bool enableLogging);
typedef wchar_t *(*BaseFolderFn)(const wchar_t *baseFolder);
typedef wchar_t *(*VersionFn)();
#endif // _XVNENG_H
#endif // _XVNENG_H

BIN
example/xvneng.lib

Binary file not shown.

BIN
functions.JPG

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 74 KiB

42
headers/xvneng.h

@ -2,20 +2,40 @@
#ifndef _XVNENG_H
#define _XVNENG_H
#pragma comment ( lib, "xvneng.lib" )
#define LoadFnKey "load"
#define UnloadFnKey "unload"
#define ScanFnKey "scan"
#define ScanAsStringFnKey "scanAsString"
#define CheckUpdatesFnKey "checkUpdates"
#define GetSettingsFnKey "getSettings"
#define LoggingFnKey "logging"
#define BaseFolderFnKey "baseFolder"
#define VersionFnKey "version"
struct ScanResult {
struct ActionResult
{
bool sucess;
wchar_t *result;
wchar_t *error;
};
struct ScanResult
{
bool sucess;
bool isMalware;
double score;
char* name;
wchar_t *name;
wchar_t *error;
};
__declspec(dllimport) void load(bool force);
__declspec(dllimport) void unload();
__declspec(dllimport) ScanResult scan(const wchar_t* filepath);
__declspec(dllimport) char* scanAsString(const wchar_t* filepath);
__declspec(dllimport) char* checkUpdates(bool checkSDKUpdates, bool loadDBAfterUpdate);
__declspec(dllimport) char* getSettings();
__declspec(dllimport) char* version();
typedef ActionResult (*LoadFn)(bool force);
typedef ActionResult (*UnloadFn)();
typedef ScanResult (*ScanFn)(const wchar_t *filepath);
typedef ActionResult (*ScanAsStringFn)(const wchar_t *filepath);
typedef ActionResult (*CheckUpdatesFn)(bool checkSDKUpdates, bool loadDBAfterUpdate);
typedef ActionResult (*GetSettingsFn)();
typedef bool (*LoggingFn)(bool enableLogging);
typedef wchar_t *(*BaseFolderFn)(const wchar_t *baseFolder);
typedef wchar_t *(*VersionFn)();
#endif // _XVNENG_H
#endif // _XVNENG_H

Loading…
Cancel
Save