diff --git a/.gitignore b/.gitignore index 72de34f..d7b4360 100644 --- a/.gitignore +++ b/.gitignore @@ -385,4 +385,9 @@ FodyWeavers.xsd # JetBrains Rider .idea/ -*.sln.iml \ No newline at end of file +*.sln.iml + +# QT +build-* +qrelease +qdebug \ No newline at end of file diff --git a/README.md b/README.md index 5282fa4..8b5f5aa 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,30 @@ Provide a lightweight feature detection engine, support custom extended feature # 更新日志 Update log + +# v1.2.1 + +``` +1:单资源匹配返回单条匹配特征改为返回多条匹配特征,这样单个文件允许被检测出多个特征。 +2:【革命性更新】推出“特征库编辑器 FireDogEditor”,可以使用界面对特征库进行修改,并且进行测试,该编辑器支持国际化。 + +1: Single resource matching returns a single matching feature instead of returning multiple matching features, so that a single file allows multiple features to be detected. +2: [Revolutionary update] Launched the "feature library editor FireDogEditor", you can use the interface to modify and test the feature library, the editor supports internationalization. +``` + +## v1.2.1 界面GUI +### 特征库配置界面 Feature library configuration gui +![](images/v1.0-feature-library.png) + +### 测试界面 Test gui +![](images/v1.0-matching.png) + +### 设置语言界面 Language setting gui +![](images/v1.0-language.png) + + # v1.1.0 + ``` 1:重构特征库格式,特征库更加合理。 2:升级hex检测,支持通配符,例如:6D ?? ?5 6? [73-75] [41-5A,61-7A] 6C 6F 75 64 @@ -59,279 +82,5 @@ include FireDog ## Step 3: Example ``` -#include -#include -#include - -#include "firedog.h" -#include "featurelibrary.h" -#include "matcher.h" - -#include "stringutil.h" - -#include "rule/rule.h" - -using namespace std; -using namespace firedog; - -void testMatcher() { - - //test featureLibrary 定义特征库 - const char* featureLibraryJson = R"( - { - "version":"1.1.0", - "items":[ - { - "name":"test simple", - "describe":"match hello world,hello hex:68 65 6C 6C 6F,world hex:77 6F 72 6C 64", - "author":"MountCloud", - "features":[ - { - "key":"str1", - "text":"hello" - }, - { - "key":"str2", - "text":"world" - } - ], - "rule":{ - "$and":[ - "str1", - "str2" - ] - } - }, - { - "name":"test complex hex match", - "describe":"match mountcloud firedog,mountcloud hex:6D 6F 75 6E 74 63 6C 6F 75 64,firedog hex:66 69 72 65 64 6F 67", - "author":"MountCloud", - "features":[ - { - "key":"hex1", - "hex":"6D ?? ?5 6? [73-75] [41-5A,61-7A] 6C 6F 75 64" - }, - { - "key":"hex2", - "hex":"66 6? 72 ?? 64 [60-70] 67" - } - ], - "rule":{ - "$and":[ - "hex1", - "hex2" - ] - } - }, - { - "name":"test complex rule match", - "describe":"match we can do it.", - "author":"MountCloud", - "features":[ - { - "key":"str1", - "text":"we" - }, - { - "key":"str2", - "text":"can" - }, - { - "key":"str3", - "text":"do" - }, - { - "key":"str4", - "text":"it" - } - ], - "rule":{ - "$and":[ - { - "$or":[ - { - "$and":[ - "str1","str2" - ] - }, - { - "$and":[ - "str3","str4" - ] - } - ] - }, - { - "$and":[ - "str1", - "str4" - ] - } - ] - } - } - ] - } - - )"; - - //bytes 校验的bytes - //const string bytes = "fire dog hello world."; - const string bytes = "123213123213 mountcloud 12312312313 firedog"; - - int ecode = NO_ERROR; - - //step1: init feature library 初始化特征库 - FeatureLibrary* featureLibrary = FeatureLibrary::createByJson(featureLibraryJson, &ecode); - - if (ecode != NO_ERROR) { - cout << "feature library load faild"; - return; - } - - //step2: push to firedog datasource,support multiple feature libraries - //将特征库添加到引擎中,支持多个特征库 - FireDog* fireDog = new FireDog(); - ecode = fireDog->pushFeatureLibrary(featureLibrary); - if (ecode != NO_ERROR) { - cout << "push feature library faild"; - return; - } - - //step3: create match,One matcher per file! - //创建检测器,一个检测器对应一个文件! - Matcher* matcher = fireDog->createNewMatcher(); - if (matcher == NULL) { - cout << "create matcher faild"; - return; - } - - //step4: matcher bytes - int length = bytes.length(); - MatcherResult* mr = NULL; - - //test check multiple bytes 一次放入多个byte - //检测 - //mr = matcher->matchBytes(bytes.c_str(), length); - //or Check byte one by one 或者一个byte一个的检测 - for (int i = 0; i < bytes.size(); i++) { - char byte = bytes[i]; - mr = matcher->matchByte(byte); - if (mr != NULL) { - break; - } - } - //检测结果 - if (mr != NULL) { - cout << "found it:" << mr->name << endl; - } - else { - cout << "not found." << endl; - } -} - -int main() -{ - testMatcher(); - return 0; -} -``` - -# 特征库示例 Example of feature library -请参考 Please refer to:doc/test-feature-library.json,doc/firedog-featurelibrary-json-schema.json -``` -{ - "version":"1.1.0", - "items":[ - { - "name":"test simple", - "describe":"match hello world,hello hex:68 65 6C 6C 6F,world hex:77 6F 72 6C 64", - "author":"MountCloud", - "features":[ - { - "key":"str1", - "text":"hello" - }, - { - "key":"str2", - "text":"world" - } - ], - "rule":{ - "$and":[ - "str1", - "str2" - ] - } - }, - { - "name":"test complex hex match", - "describe":"match mountcloud firedog,mountcloud hex:6D 6F 75 6E 74 63 6C 6F 75 64,firedog hex:66 69 72 65 64 6F 67", - "author":"MountCloud", - "features":[ - { - "key":"hex1", - "hex":"6D ?? ?5 6? [73-75] [41-5A,61-7A] 6C 6F 75 64" - }, - { - "key":"hex2", - "hex":"66 6? 72 ?? 64 [60-70] 67" - } - ], - "rule":{ - "$and":[ - "hex1", - "hex2" - ] - } - }, - { - "name":"test complex rule match", - "describe":"match we can do it., if ((str1&&str2)|(str3&&str4))&&(str1&&str4)", - "author":"MountCloud", - "features":[ - { - "key":"str1", - "text":"we" - }, - { - "key":"str2", - "text":"can" - }, - { - "key":"str3", - "text":"do" - }, - { - "key":"str4", - "text":"it" - } - ], - "rule":{ - "$and":[ - { - "$or":[ - { - "$and":[ - "str1","str2" - ] - }, - { - "$and":[ - "str3","str4" - ] - } - ] - }, - { - "$and":[ - "str1", - "str4" - ] - } - ] - } - } - ] -} +look FireDogEditor/matchthread.h and FireDogEditor/matchthread.cpp ``` \ No newline at end of file diff --git a/images/v1.0-feature-library.png b/images/v1.0-feature-library.png new file mode 100644 index 0000000..b403c79 Binary files /dev/null and b/images/v1.0-feature-library.png differ diff --git a/images/v1.0-language.png b/images/v1.0-language.png new file mode 100644 index 0000000..db626cd Binary files /dev/null and b/images/v1.0-language.png differ diff --git a/images/v1.0-matching.png b/images/v1.0-matching.png new file mode 100644 index 0000000..11b9a80 Binary files /dev/null and b/images/v1.0-matching.png differ