Skip to content

Commit

Permalink
更新Readme
Browse files Browse the repository at this point in the history
  • Loading branch information
MountCloud committed Nov 17, 2021
1 parent 49476a0 commit dd58bfa
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 276 deletions.
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -385,4 +385,9 @@ FodyWeavers.xsd

# JetBrains Rider
.idea/
*.sln.iml
*.sln.iml

# QT
build-*
qrelease
qdebug
299 changes: 24 additions & 275 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -59,279 +82,5 @@ include FireDog
## Step 3: Example

```
#include <iostream>
#include <string>
#include <iomanip>
#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
```
Binary file added images/v1.0-feature-library.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/v1.0-language.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/v1.0-matching.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit dd58bfa

Please sign in to comment.