7 Commits

Author SHA1 Message Date
bol-van
9776d5d8a9 nfqws: old gcc 4.x compat 2025-06-13 11:44:11 +03:00
bol-van
f88c9a662d nfqws: allow linux build without ssid 2025-06-13 11:31:50 +03:00
bol-van
97bcb9740d update docs 2025-06-13 11:12:37 +03:00
bol-van
b6e9fa3434 nfqws: check wext ssid len not zero 2025-06-12 13:22:54 +03:00
bol-van
32cfee705a nfqws: optimize wext 2025-06-12 11:58:20 +03:00
bol-van
1303bf0fef update changes.txt 2025-06-12 11:46:34 +03:00
bol-van
2417d4ee76 nfqws: use wireless ext in case nl80211 does not return ssid 2025-06-12 11:45:14 +03:00
5 changed files with 50 additions and 10 deletions

View File

@@ -513,3 +513,7 @@ nfqws: --filter-ssid (linux-only)
install_easy: stop if running embedded release on traditional linux system (some files missing)
install_bin: add "read elf" arch detection method
binaries: renamed arch dirs in binaries
v71.2
nfqws: use wireless ext in case nl80211 does not return SSID

View File

@@ -1,4 +1,4 @@
# zapret v71.1
# zapret v71.1.1
# SCAMMER WARNING
@@ -679,9 +679,11 @@ Instead, `nfqws` has per-profile `--filter-ssid` parameter. Like `--ssid-filter`
`nfqws` maintains ifname->SSID list which is updated not faster than once a second.
When a packet comes incoming or outgoing interface name is matched to the SSID and then used in profile selection algorithm.
SSID info is taken the same way as `iw dev <ifname> info` does.
In practice this command not always returns SSID name for reasons not known yet. If it does not display SSID then `--filter-ssid` will also not work.
Before using it check iw command output.
SSID info is taken the same way as `iw dev <ifname> info` does (nl80211).
Unfortunately it's broken since kernel 5.19 and still unfixed in 6.14.
In the latter case `iwgetid` way is used (wireless extensions).
Wireless extensions are deprecated. Some kernels can be built without wext support.
Before using `--filter-ssid` check that any of the mentioned commands can return SSID.
### Virtual machines

View File

@@ -1,4 +1,4 @@
# zapret v71.1
# zapret v71.1.1
# ВНИМАНИЕ, остерегайтесь мошенников
@@ -794,9 +794,12 @@ L7 протокол становится известен обычно посл
При выборе профиля имеет значение куда идет конкретный обрабатываемый пакет. На какой интерфейс. Или с какого интерфейса пакет пришел, если он считается входящим.
Поэтому даже если у вас часть трафика идет на одну сеть, часть на другую, а часть вообще не идет по wifi, то все это можно настроить.
Информация о подключенных сетях берется способом, используемым командой `iw dev <ifname> info`.
Как показывает опыт, не всегда возвращается SSID. Пока не выяснено с чем это связано.
Перед использованием `--filter-ssid` удостоверьтесь, что iw возвращает имя сети. Иначе работать не будет.
Информация о подключенных сетях берется способом, используемым командой `iw dev <ifname> info` (nl80211).
К сожалению, на ядрах с 5.19 до самых последних (6.14 не работает) этот способ сломан.
В этом случае используется способ iwgetid (wireless extensions).
wireless extensions считаются deprecated и на новых ядрах реализованы как прослойка совместимости.
Некоторые ядра могут быть собраны без wireless extensions.
Перед использованием `--filter-ssid` удостоверьтесь, что любая из этих команд возвращает SSID.
Сканируются все wifi интерфейсы, составляется список interface->SSID. Он обновляется по мере поступления
пакетов, но не чаще 1 раза в секунду.

View File

@@ -34,6 +34,9 @@
#include <linux/genetlink.h>
#include <libmnl/libmnl.h>
#include <net/if.h>
#define _LINUX_IF_H // prevent conflict between linux/if.h and net/if.h in old gcc 4.x
#include <linux/wireless.h>
#include <sys/ioctl.h>
#endif
uint32_t net32_add(uint32_t netorder_value, uint32_t cpuorder_increment)
@@ -1959,8 +1962,28 @@ static int wlan_info_cb(const struct nlmsghdr *nlh, void *data)
if (wc->count>=WLAN_INTERFACE_MAX) return MNL_CB_OK;
memset(wc->wlan+wc->count,0,sizeof(wc->wlan[0]));
ret = mnl_attr_parse(nlh, sizeof(struct genlmsghdr), wlan_info_attr_cb, wc->wlan+wc->count);
if (ret>=0 && *wc->wlan[wc->count].ssid && *wc->wlan[wc->count].ifname && wc->wlan[wc->count].ifindex)
wc->count++;
if (ret>=0 && *wc->wlan[wc->count].ifname && wc->wlan[wc->count].ifindex)
{
if (*wc->wlan[wc->count].ssid)
wc->count++;
else
{
// sometimes nl80211 does not return SSID but wireless ext does
int wext_fd = socket(AF_INET, SOCK_DGRAM, 0);
if (wext_fd!=-1)
{
struct iwreq req;
snprintf(req.ifr_ifrn.ifrn_name,sizeof(req.ifr_ifrn.ifrn_name),"%s",wc->wlan[wc->count].ifname);
req.u.essid.pointer = wc->wlan[wc->count].ssid;
req.u.essid.length = sizeof(wc->wlan[wc->count].ssid);
req.u.essid.flags = 0;
if (ioctl(wext_fd, SIOCGIWESSID, &req)!=-1)
if (*wc->wlan[wc->count].ssid)
wc->count++;
close(wext_fd);
}
}
}
return ret;
}
static bool wlan_info(struct mnl_socket* nl, uint16_t wlan_family_id, struct wlan_interface_collection* w)

View File

@@ -306,6 +306,7 @@ static int nfq_main(void)
if (!nfq_init(&h,&qh))
goto err;
#ifdef HAS_FILTER_SSID
if (params.filter_ssid_present)
{
if (!wlan_info_init())
@@ -315,6 +316,7 @@ static int nfq_main(void)
}
DLOG("wlan info capture initialized\n");
}
#endif
if (params.daemon) daemonize();
@@ -340,9 +342,11 @@ static int nfq_main(void)
while ((rd = recv(fd, buf, sizeof(buf), 0)) >= 0)
{
ReloadCheck();
#ifdef HAS_FILTER_SSID
if (params.filter_ssid_present)
if (!wlan_info_get_rate_limited())
DLOG_ERR("cannot get wlan info\n");
#endif
if (rd)
{
int r = nfq_handle_packet(h, (char *)buf, (int)rd);
@@ -359,12 +363,16 @@ static int nfq_main(void)
} while(e==ENOBUFS);
nfq_deinit(&h,&qh);
#ifdef HAS_FILTER_SSID
wlan_info_deinit();
#endif
return 0;
err:
if (Fpid) fclose(Fpid);
nfq_deinit(&h,&qh);
#ifdef HAS_FILTER_SSID
wlan_info_deinit();
#endif
return 1;
}