18
“Content-Type:text/html; charset=utf-8rnrn”
register_http_filter_fake_response_rule_by_group(0, “www.xxx.com” , 0,
response);
//回复 www.xxx.com HTTP/1.1 403
register_http_filter_fake_response_rule_by_group(0, “www.xxx.com” , 403,NULL);
♦ 对指定的 url链接数据包做文本替换
int register_http_filter_replace_rule_by_group(uint16_t group_id, const char *url, const struct u_text_replace *original,int o_num, const struct u_text_replace *reply, int r_num)
struct u_text_replace 定义如下:
struct u_text_replace {
uint32_t size_of_struct;
uint16_t type;
uint16_t flags;
unsigned char match_len;
unsigned char replace_len;
void *match_data;
void *replace_data;
};
type: 文本替换类型,目前支持如下类型
enum {
HTTP_FILTER_TYPE_UNSPEC,
HTTP_FILTER_TYPE_REPLACE,
HTTP_FILTER_TYPE_DELETE,
HTTP_FILTER_TYPE_INSERT,
};
HTTP_FILTER_TYPE_REPLACE:替换模式,替换指定的子串
HTTP_FILTER_TYPE_DELETE:删除模式,删除指定的子串
HTTP_FILTER_TYPE_INSERT:插入模式,在命中的子串附近插入指定的文本串,默认插入
在特征串的后面,可以在 flags 中指定 HTTP_FILTER_MATCH_INSERT_BEFORE 来插入到特征串的
前面。
flags:标志,目前支持如下标志
#define HTTP_FILTER_MATCH_REPEAT (1<<0)
#define HTTP_FILTER_MATCH_INSERT_BEFORE (1<<1)
HTTP_FILTER_MATCH_REPEAT: 对当前报文段匹配所有的子串
HTTP_FILTER_MATCH_INSERT_BEFORE:插入模式类型下有效,表示匹配到子串后,文本数
据插入子串前(默认是插入子串后)