我正在使用 WFP 做一些工作,并且在 FWPM_LAYER_ALE_CONNECT_REDIRECT_V4 层上遇到阻塞过滤器的问题。它必须阻止来自本地 IP 的流量,但事实并非如此。如果我将图层更改为 FWPM_LAYER_ALE_AUTH_CONNECT_V4 过滤器可以正常工作。
所以我有几个问题:
1)我可以阻止来自 FWPM_LAYER_ALE_CONNECT_REDIRECT_V4 层上指定本地 IP 的流量(下面的代码不起作用)吗?
2)我们可以在ale_connect_redirect(或ale_bind_redirect)层上使用local_ip(remote_ip)创建条件吗?
UINT32 test_wfp_filter(HANDLE engine_handle,
FWP_V4_ADDR_AND_MASK* source_ip,
UINT8 weight)
{
UINT32 status;
FWPM_FILTER filter = { 0 };
FWPM_FILTER_CONDITION filter_conditions[1] = { 0 };
filter_conditions[0].fieldKey = FWPM_CONDITION_IP_LOCAL_ADDRESS;
filter_conditions[0].matchType = FWP_MATCH_EQUAL;
filter_conditions[0].conditionValue.type = FWP_V4_ADDR_MASK;
filter_conditions[0].conditionValue.v4AddrMask = source_ip;
status = UuidCreate(&(filter.filterKey));
if (status != NO_ERROR)
{
return status;
}
filter.layerKey = FWPM_LAYER_ALE_CONNECT_REDIRECT_V4;
//With this layerKey filter doesn't work,
//but with FWPM_LAYER_ALE_AUTH_CONNECT_V4 filter works properly
filter.displayData.name = L"Blocking filter";
filter.displayData.description = L"Blocks all trafic from current comp";
filter.action.type = FWP_ACTION_BLOCK;
filter.subLayerKey = WFP_TEST_SUBLAYER;
filter.weight.type = FWP_UINT8;
filter.weight.uint8 = weight;
filter.filterCondition = filter_conditions;
filter.numFilterConditions = 1;
status = FwpmFilterAdd(engine_handle, &filter, 0, 0);
return 0;
}
谢谢!