YaraSharp
1.0.0
C# 야라 패턴 매칭 라이브러리 주변의 래퍼.
Loki 또는 Yara를 형성하는 서명을 사용하십시오.
Nuget 패키지를 사용할 수 있습니다
// All API calls happens here
YSInstance YSInstance = new YSInstance ( ) ;
// Declare external variables (could be null)
Dictionary < string , object > externals = new Dictionary < string , object > ( )
{
{ "filename" , string . Empty } ,
{ "filepath" , string . Empty } ,
{ "extension" , string . Empty }
} ;
// Get list of YARA rules
List < string > ruleFilenames = Directory . GetFiles ( @"D:Testyara" , "*.yar" , SearchOption . AllDirectories ) . ToList ( ) ;
// Context is where yara is initialized
// From yr_initialize() to yr_finalize()
using ( YSContext context = new YSContext ( ) )
{
// Compiling rules
using ( YSCompiler compiler = instance . CompileFromFiles ( ruleFilenames , externals ) )
{
// Get compiled rules
YSRules rules = compiler . GetRules ( ) ;
// Get errors
YSReport errors = compiler . GetErrors ( ) ;
// Get warnings
YSReport warnings = compiler . GetWarnings ( ) ;
// Some file to test yara rules
string Filename = @"" ;
// Get matches
List < YSMatches > Matches = instance . ScanFile ( Filename , rules ,
new Dictionary < string , object > ( )
{
{ "filename" , Alphaleonis . Win32 . Filesystem . Path . GetFileName ( Filename ) } ,
{ "filepath" , Alphaleonis . Win32 . Filesystem . Path . GetFullPath ( Filename ) } ,
{ "extension" , Alphaleonis . Win32 . Filesystem . Path . GetExtension ( Filename ) }
} ,
0 ) ;
// Iterate over matches
foreach ( YSMatches Match in Matches )
{
//...
}
}
// Log errors
}비동기 스캔 사용의 경우 파괴 방법을 호출 해야합니다 .
YaraSharp . CYaraSharp YSInstance = new CYaraSharp ( ) ;
YaraSharp . CContext YSContext = new YaraSharp . CContext ( ) ;
YaraSharp . CRules YSRules = YSInstance . CompileFromFiles ( RuleFilenames , null , out Errors ) ;
// Async here
YSRules . Destroy ( ) ;
YSContext . Destroy ( ) ; 리비아라 사용 방법에 대한 일반적인 개요를위한 리비아라 C API 문서.
Soultion에는 2 개의 프로젝트가 포함됩니다.
VS 2017에서 구축
Yara 3.8.1로 편집
야라는 유니 코드 경로를 지원하기 위해 패치했다
원하는 소스를 사용하거나 수정할 수 있습니다.
Kallanreed에게 특별한 감사를드립니다