我正在尝试读取一个带有 IP 地址列表的文件和另一个带有域的文件,作为https://docs.zeek.org/en/stable/frameworks/input.html中定义的输入框架的概念证明
我准备了以下兄弟脚本:
阅读。兄弟:
type Idx: record {
ip: addr;
};
type Idx: record {
domain: string;
};
global ips: table[addr] of Idx = table();
global domains: table[string] of Idx = table();
event bro_init() {
Input::add_table([$source="read_ip_bro", $name="ips",
$idx=Idx, $destination=ips, $mode=Input::REREAD]);
Input::add_table([$source="read_domain_bro", $name="domains",
$idx=Idx, $destination=domains, $mode=Input::REREAD]);
Input::remove("ips");
Input::remove("domains");
}
还有 bad_ip.bro 脚本,它检查一个 IP 是否在黑名单中,它会加载前一个:
bad_ip.bro
@load reading.bro
module HTTP;
event http_reply(c: connection, version: string, code: count, reason: string)
{
if ( c$id$orig_h in ips )
print fmt("A malicious IP is connecting: %s", c$id$orig_h);
}
但是,当我运行兄弟时,我收到错误消息:
error: Input stream ips: Table type does not match index type. Need type 'string':string, got 'addr':addr
Segmentation fault (core dumped)