snort 規則選項自定義詳細分析(原始碼)

2021-09-12 08:01:23 字數 1196 閱讀 7679

前面分析過content的規則選項主要流程包括註冊、解析

接下來我乙個例項進行分析如何增加乙個自定義的規則選項

首先進入registerruleoptions函式中,編寫自己的註冊介面函式setuptest, 規則選項關鍵字test, ,初始換函式testinit, testruleparse解析該字段的函式,在什麼時候生效opt_type_detection, 更新規則選項中的陣列ds_list,增加元素鍊錶列舉型別rule_option_type_test,設定處理匹配函式testdetect,設計這個關鍵字的資料結構testruleoption, 在detection-plugins目錄下增加sp_test.h|c兩個原始檔,並修改當前目錄下的makefile.am, 增加

libspd_a_sources=...

sp_test.c sp_test.h

重新編譯安裝,這個增加test欄位會被編譯程序式中

void registerruleoptions(void)

void setuptest(void)

/* encapsulate the rule option */

typedef struct _testruleoption

testruleoption;

static void testruleparse(char *rule_args, testruleoption *test_rule_option)

static void testinit(struct _snortconfig *sc, char *data, opttreenode *otn, int protocol)

/* attach detection function to rule's detect function ptr */

ofl = addoptfunctolist(testdetect, otn);

ofl->type = rule_option_type_test;

ofl->context = (void *)test_rule_option;

}

這樣就基本把怎麼增加自定義規則選項講完了。

也可以參考 sp_template.h|c這個模板進行增加自己的規則選項。

LINQ Intersect 自定義規則

如果你還不了解intersect,可參考這往篇文章 實際專案中,往往需求會複雜的多 比如有這樣乙個product類 public class product public string productname public double unitprice 需求是只要兩個product的 id和pr...

自定義UITableViewCell詳細步驟

例 自定義單元格中有乙個button和乙個textview 1.在xcode中選擇新建 cocoa touch objective c class 名字 mycell 繼承 uitableviewcell 2.mycell.h檔案 inte ce mycell uitableviewcell iba...

zabbix自定義監控規則

這裡先需要再zabbix端安裝乙個測試工具,用於測試自定義的規則是否可用 檢視可以安裝的工具 yum list all grep zabbix 進行安裝 yum install zabbix get.x86 64 先編寫指令碼,這個指令碼可以是python也可以是shell,下面以shell為例子 ...