nfqws2,zapret-lib: fix wrong spelling : WRITEABLE -> WRITABLE

This commit is contained in:
bol-van
2026-06-07 08:34:40 +03:00
parent 441d2e3cfc
commit fe8b8df2ae
10 changed files with 42 additions and 41 deletions
+3 -2
View File
@@ -293,7 +293,8 @@ v0.9.4.3
* nfqws2: rewrite time counting algorithm, remove --timer-res * nfqws2: rewrite time counting algorithm, remove --timer-res
0.9.5.3 1.0
* zapret-lib,zapret-antidpi: delay parameter in "send" desync function * zapret-lib,zapret-antidpi: delay parameter in "send" desync function
* zapret-lib: fix oob urp=b case in rawsend_dissect_segmented * zapret-lib: fix oob urp=0 case in rawsend_dissect_segmented
* nfqws2, zapret-lib: (LUA_COMPAT_VER=6) fix wrong spelling : WRITEABLE -> WRITABLE
+6 -6
View File
@@ -656,7 +656,7 @@ General parameters for all versions - nfqws2, dvtws2, winws2.
--reasm-disable=[type[,type]] ; disable fragment reassembly for a list of payloads: tls_client_hello quic_initial. without arguments - disable reasm for everything. --reasm-disable=[type[,type]] ; disable fragment reassembly for a list of payloads: tls_client_hello quic_initial. without arguments - disable reasm for everything.
DESYNC ENGINE INIT: DESYNC ENGINE INIT:
--writeable[=<dir_name>] ; create a directory for Lua with write permissions and store its path in the "WRITEABLE" env variable (only one directory) --writable[=<dir_name>] ; create a directory for Lua with write permissions and store its path in the "WRITABLE" env variable (only one directory)
--blob=<item_name>:[+ofs]@<filename>|0xHEX ; load a binary file or hex string into the Lua variable <item_name>. +ofs specifies the offset from the start of the file --blob=<item_name>:[+ofs]@<filename>|0xHEX ; load a binary file or hex string into the Lua variable <item_name>. +ofs specifies the offset from the start of the file
--lua-init=@<filename>|<lua_text> ; execute Lua code from a string or file once at startup. supports gzipped files. automatically checks for "<filename>.gz" --lua-init=@<filename>|<lua_text> ; execute Lua code from a string or file once at startup. supports gzipped files. automatically checks for "<filename>.gz"
--lua-gc=<int> ; Lua garbage collector invocation interval in seconds. 0 disables periodic calls. --lua-gc=<int> ; Lua garbage collector invocation interval in seconds. 0 disables periodic calls.
@@ -1018,7 +1018,7 @@ Windows:
- All `Se*` privileges are irrevocably removed from the token, except for `SeChangeNotifyPrivilege`. - All `Se*` privileges are irrevocably removed from the token, except for `SeChangeNotifyPrivilege`.
- A Job object is used to prohibit the creation of child processes and restrict desktop interaction - clipboard access, changing desktop settings, changing display settings, etc. - A Job object is used to prohibit the creation of child processes and restrict desktop interaction - clipboard access, changing desktop settings, changing display settings, etc.
There is a simple way to pass a writable directory to the Lua code using the `--writeable[=<dirname>]` parameter. `nfqws2` creates the directory and assigns permissions so that the Lua code can write files there, then passes the directory name in the `WRITEABLE` environment variable. If `dirname` is not specified, a directory is created within `%USERPROFILE%/AppData/LocalLow` on Windows. There is a simple way to pass a writable directory to the Lua code using the `--writable[=<dirname>]` parameter. `nfqws2` creates the directory and assigns permissions so that the Lua code can write files there, then passes the directory name in the `WRITABLE` environment variable. If `dirname` is not specified, a directory is created within `%USERPROFILE%/AppData/LocalLow` on Windows.
On the Lua side, dangerous functions are removed: `os.execute`, `io.popen`, `package.loadlib`, and the `debug` module. On GitHub, `nfqws2` executables are built with a version of LuaJIT that excludes FFI. On the Lua side, dangerous functions are removed: `os.execute`, `io.popen`, `package.loadlib`, and the `debug` module. On GitHub, `nfqws2` executables are built with a version of LuaJIT that excludes FFI.
@@ -1697,8 +1697,8 @@ Before executing `--lua-init`, the C code sets up base constants, blobs, and C f
| env | Purpose | | env | Purpose |
| :-------- |:---------- | | :-------- |:---------- |
| WRITEABLE | A directory writable by Lua. Corresponds to the `--writeable` option. | | WRITABLE | A directory writable by Lua. Corresponds to the `--writable` option. |
| APPDATALOW | (Windows only) The AppData location for the low mandatory level. This is also writable, but using `--writeable` is preferred for cross-platform compatibility. | | APPDATALOW | (Windows only) The AppData location for the low mandatory level. This is also writable, but using `--writable` is preferred for cross-platform compatibility. |
## C functions ## C functions
@@ -3295,12 +3295,12 @@ function host_or_ip(desync)
``` ```
function is_absolute_path(path) function is_absolute_path(path)
function append_path(path, file) function append_path(path, file)
function writeable_file_name(filename) function writeble_file_name(filename)
``` ```
- `is_absolute_path` returns true if the path starts from the root. It accounts for CYGWIN path specifics. - `is_absolute_path` returns true if the path starts from the root. It accounts for CYGWIN path specifics.
- `append_path` appends a file or directory name `file` to `path`, using '/' as a separator. - `append_path` appends a file or directory name `file` to `path`, using '/' as a separator.
- `writeable_file_name` returns `filename` if it contains an absolute path or if the `WRITEABLE` environment variable is not set. Otherwise, it retrieves the path from the `WRITEABLE` environment variable and appends the `filename` using `append_path`. - `writeble_file_name` returns `filename` if it contains an absolute path or if the `WRITABLE` environment variable is not set. Otherwise, it retrieves the path from the `WRITABLE` environment variable and appends the `filename` using `append_path`.
## Reading and writing Files ## Reading and writing Files
+8 -8
View File
@@ -715,7 +715,7 @@ nfqws2 использует стандартный парсер getopt_long_only
--reasm-disable=[type[,type]] ; отключить сборку фрагментов для списка пейлоадов : tls_client_hello quic_initial . без аргумента - отключить reasm для всего. --reasm-disable=[type[,type]] ; отключить сборку фрагментов для списка пейлоадов : tls_client_hello quic_initial . без аргумента - отключить reasm для всего.
DESYNC ENGINE INIT: DESYNC ENGINE INIT:
--writeable[=<dir_name>] ; создать директорию для Lua с разрешением записи и поместить путь к ней в переменную env "WRITEABLE" (только одна директория) --writable[=<dir_name>] ; создать директорию для Lua с разрешением записи и поместить путь к ней в переменную env "WRITABLE" (только одна директория)
--blob=<item_name>:[+ofs]@<filename>|0xHEX ; загрузить бинарный файл или hex строку в переменную Lua <item_name>. +ofs задает смещение от начала файла --blob=<item_name>:[+ofs]@<filename>|0xHEX ; загрузить бинарный файл или hex строку в переменную Lua <item_name>. +ofs задает смещение от начала файла
--lua-init=@<filename>|<lua_text> ; однократно при старте выполнить Lua код из строки или из файла. поддерживаются сжатые gzip файлы. автоматически проверяется "<filename>.gz" --lua-init=@<filename>|<lua_text> ; однократно при старте выполнить Lua код из строки или из файла. поддерживаются сжатые gzip файлы. автоматически проверяется "<filename>.gz"
--lua-gc=<int> ; интервал вызова сборщика мусора Lua в секундах. 0 отключает периодический вызов. --lua-gc=<int> ; интервал вызова сборщика мусора Lua в секундах. 0 отключает периодический вызов.
@@ -1139,8 +1139,8 @@ Windows :
- Безвозвратно убираются все Se* привилегии из токена, кроме SeChangeNotifyPrivilege. - Безвозвратно убираются все Se* привилегии из токена, кроме SeChangeNotifyPrivilege.
- С помощью Job запрещается создание дочерних процессов и ограничивается взаимодействие с десктопом - clipboard, change desktop, change display settings и тд - С помощью Job запрещается создание дочерних процессов и ограничивается взаимодействие с десктопом - clipboard, change desktop, change display settings и тд
Есть простой способ передать Lua коду каталог, доступный на запись - параметр `--writeable[=<dirname>]`. Есть простой способ передать Lua коду каталог, доступный на запись - параметр `--writable[=<dirname>]`.
nfqws2 создает каталог, назначает на него такие права, чтобы Lua код смог писать туда файлы, передает имя директории в переменной env `WRITEABLE`. nfqws2 создает каталог, назначает на него такие права, чтобы Lua код смог писать туда файлы, передает имя директории в переменной env `WRITABLE`.
Если dirname не задан, на Windows создается каталог внутри `%USERPROFILE%/AppData/LocalLow` Если dirname не задан, на Windows создается каталог внутри `%USERPROFILE%/AppData/LocalLow`
Со стороны Lua убираются опасные функции - os.execute, io.popen, package.loadlib и модуль debug. Со стороны Lua убираются опасные функции - os.execute, io.popen, package.loadlib и модуль debug.
@@ -1844,8 +1844,8 @@ data задается при запуске таймера через [timer_set
| env | Назначение | | env | Назначение |
| :-------- |:---------- | | :-------- |:---------- |
| WRITEABLE | Директория, доступная на запись Lua. Результат опции `--writeable` | | WRITABLE | Директория, доступная на запись Lua. Результат опции `--writable` |
| APPDATALOW | (только Windows) Расположение AppData для low mandatory level. Сюда тоже можно записывать, но предпочтительно использовать `--writeable` для кросс-платформенности. | | APPDATALOW | (только Windows) Расположение AppData для low mandatory level. Сюда тоже можно записывать, но предпочтительно использовать `--writable` для кросс-платформенности. |
## C функции ## C функции
@@ -3468,13 +3468,13 @@ function host_or_ip(desync)
``` ```
function is_absolute_path(path) function is_absolute_path(path)
function append_path(path,file) function append_path(path,file)
function writeable_file_name(filename) function writable_file_name(filename)
``` ```
- is_absolute_path возвращает true, если путь path начинается с корня. Учитываются особенности путей CYGWIN. - is_absolute_path возвращает true, если путь path начинается с корня. Учитываются особенности путей CYGWIN.
- append_path дописывает имя файла или каталога file к пути path, разделяя их знаком '/' - append_path дописывает имя файла или каталога file к пути path, разделяя их знаком '/'
- writeable_file_name возвращает filename, если filename содержит абсолютный путь или env `WRITEABLE` отсутствует. - writable_file_name возвращает filename, если filename содержит абсолютный путь или env `WRITABLE` отсутствует.
Иначе берется путь из env `WRITEABLE` и к нему дописывается имя файла filename через append_path. Иначе берется путь из env `WRITABLE` и к нему дописывается имя файла filename через append_path.
## Чтение и запись файлов ## Чтение и запись файлов
+3 -3
View File
@@ -1,4 +1,4 @@
NFQWS2_COMPAT_VER_REQUIRED=5 NFQWS2_COMPAT_VER_REQUIRED=6
if NFQWS2_COMPAT_VER~=NFQWS2_COMPAT_VER_REQUIRED then if NFQWS2_COMPAT_VER~=NFQWS2_COMPAT_VER_REQUIRED then
error("Incompatible NFQWS2_COMPAT_VER. Use pktws and lua scripts from the same release !") error("Incompatible NFQWS2_COMPAT_VER. Use pktws and lua scripts from the same release !")
@@ -1435,9 +1435,9 @@ end
function append_path(path,file) function append_path(path,file)
return string.sub(path,#path,#path)=='/' and path..file or path.."/"..file return string.sub(path,#path,#path)=='/' and path..file or path.."/"..file
end end
function writeable_file_name(filename) function writable_file_name(filename)
if is_absolute_path(filename) then return filename end if is_absolute_path(filename) then return filename end
local writedir = os.getenv("WRITEABLE") local writedir = os.getenv("WRITABLE")
if not writedir then return filename end if not writedir then return filename end
return append_path(writedir, filename) return append_path(writedir, filename)
end end
+3 -3
View File
@@ -15,8 +15,8 @@ function pcap_write(file, raw)
pcap_write_packet(file, raw) pcap_write_packet(file, raw)
end end
-- test case : --writeable=zdir --in-range=a --lua-desync=pcap:file=test.pcap -- test case : --writable=zdir --in-range=a --lua-desync=pcap:file=test.pcap
-- arg : file=<filename> - file for storing pcap data. if --writeable is specified and filename is relative - append filename to writeable path -- arg : file=<filename> - file for storing pcap data. if --writable is specified and filename is relative - append filename to writable path
-- arg : keep - do not overwrite file, append packets to existing -- arg : keep - do not overwrite file, append packets to existing
function pcap(ctx, desync) function pcap(ctx, desync)
if not desync.arg.file or #desync.arg.file==0 then if not desync.arg.file or #desync.arg.file==0 then
@@ -24,7 +24,7 @@ function pcap(ctx, desync)
end end
local fn_cache_name = desync.func_instance.."_fn" local fn_cache_name = desync.func_instance.."_fn"
if not _G[fn_cache_name] then if not _G[fn_cache_name] then
_G[fn_cache_name] = writeable_file_name(desync.arg.file) _G[fn_cache_name] = writable_file_name(desync.arg.file)
if not desync.arg.keep then if not desync.arg.keep then
-- overwrite file -- overwrite file
os.remove(_G[fn_cache_name]) os.remove(_G[fn_cache_name])
+4 -4
View File
@@ -2478,11 +2478,11 @@ bool set_socket_buffers(int fd, int rcvbuf, int sndbuf)
return true; return true;
} }
bool make_writeable_dir() bool make_writable_dir()
{ {
char wdir[PATH_MAX], *wrdir; char wdir[PATH_MAX], *wrdir;
if (*params.writeable_dir) if (*params.writable_dir)
wrdir = params.writeable_dir; wrdir = params.writable_dir;
else else
{ {
#ifdef __CYGWIN__ #ifdef __CYGWIN__
@@ -2516,6 +2516,6 @@ bool make_writeable_dir()
} }
} }
#endif #endif
if (b) setenv("WRITEABLE",wrdir,1); if (b) setenv("WRITABLE",wrdir,1);
return b; return b;
} }
+1 -1
View File
@@ -121,7 +121,7 @@ bool tcp_synack_segment(const struct tcphdr *tcphdr);
bool tcp_syn_segment(const struct tcphdr *tcphdr); bool tcp_syn_segment(const struct tcphdr *tcphdr);
bool make_writeable_dir(); bool make_writable_dir();
bool ensure_file_access(const char *filename); bool ensure_file_access(const char *filename);
#ifdef __CYGWIN__ #ifdef __CYGWIN__
extern uint32_t w_win32_error; extern uint32_t w_win32_error;
+11 -11
View File
@@ -1866,7 +1866,7 @@ static void exithelp(void)
" --nlm-list[=all]\t\t\t\t\t; list Network List Manager (NLM) networks. connected only or all.\n" " --nlm-list[=all]\t\t\t\t\t; list Network List Manager (NLM) networks. connected only or all.\n"
#endif #endif
"\nDESYNC ENGINE INIT:\n" "\nDESYNC ENGINE INIT:\n"
" --writeable[=<dir_name>]\t\t\t\t; create writeable dir for LUA scripts and pass it in WRITEABLE env variable (only one dir possible)\n" " --writable[=<dir_name>]\t\t\t\t; create writable dir for LUA scripts and pass it in WRITABLE env variable (only one dir possible)\n"
" --blob=<item_name>:[+ofs]@<filename>|0xHEX\t\t; load blob to LUA var <item_name>\n" " --blob=<item_name>:[+ofs]@<filename>|0xHEX\t\t; load blob to LUA var <item_name>\n"
" --lua-init=@<filename>|<lua_text>\t\t\t; load LUA program from a file or string. if multiple parameters present order of execution is preserved. gzipped files are supported.\n" " --lua-init=@<filename>|<lua_text>\t\t\t; load LUA program from a file or string. if multiple parameters present order of execution is preserved. gzipped files are supported.\n"
" --lua-gc=<int>\t\t\t\t\t\t; forced garbage collection every N sec. default %u sec. triggers only when a packet arrives. 0 = disable.\n" " --lua-gc=<int>\t\t\t\t\t\t; forced garbage collection every N sec. default %u sec. triggers only when a packet arrives. 0 = disable.\n"
@@ -2003,7 +2003,7 @@ enum opt_indices {
IDX_SOCKARG, IDX_SOCKARG,
#endif #endif
IDX_WRITEABLE, IDX_WRITABLE,
IDX_BLOB, IDX_BLOB,
IDX_LUA_INIT, IDX_LUA_INIT,
@@ -2107,7 +2107,7 @@ static const struct option long_options[] = {
#elif defined(SO_USER_COOKIE) #elif defined(SO_USER_COOKIE)
[IDX_SOCKARG] = {"sockarg", required_argument, 0, 0}, [IDX_SOCKARG] = {"sockarg", required_argument, 0, 0},
#endif #endif
[IDX_WRITEABLE] = {"writeable", optional_argument, 0, 0}, [IDX_WRITABLE] = {"writable", optional_argument, 0, 0},
[IDX_BLOB] = {"blob", required_argument, 0, 0}, [IDX_BLOB] = {"blob", required_argument, 0, 0},
[IDX_LUA_INIT] = {"lua-init", required_argument, 0, 0}, [IDX_LUA_INIT] = {"lua-init", required_argument, 0, 0},
[IDX_LUA_GC] = {"lua-gc", required_argument, 0, 0}, [IDX_LUA_GC] = {"lua-gc", required_argument, 0, 0},
@@ -2519,18 +2519,18 @@ int main(int argc, char **argv)
} }
break; break;
#endif #endif
case IDX_WRITEABLE: case IDX_WRITABLE:
params.writeable_dir_enable = true; params.writable_dir_enable = true;
if (optarg) if (optarg)
{ {
if (!realpath_any(optarg, params.writeable_dir)) if (!realpath_any(optarg, params.writable_dir))
{ {
DLOG_ERR("bad file '%s'\n",optarg); DLOG_ERR("bad file '%s'\n",optarg);
exit_clean(1); exit_clean(1);
} }
} }
else else
*params.writeable_dir = 0; *params.writable_dir = 0;
break; break;
case IDX_BLOB: case IDX_BLOB:
@@ -3148,14 +3148,14 @@ int main(int argc, char **argv)
DLOG_CONDUP("we have %u user defined desync profile(s) and default low priority profile 0\n", desync_profile_count); DLOG_CONDUP("we have %u user defined desync profile(s) and default low priority profile 0\n", desync_profile_count);
DLOG_CONDUP("we have %u user defined desync template(s)\n", desync_template_count); DLOG_CONDUP("we have %u user defined desync template(s)\n", desync_template_count);
if (params.writeable_dir_enable) if (params.writable_dir_enable)
{ {
if (!make_writeable_dir()) if (!make_writable_dir())
{ {
DLOG_ERR("could not make writeable dir for LUA\n"); DLOG_ERR("could not make writable dir for LUA\n");
exit_clean(1); exit_clean(1);
} }
DLOG("LUA writeable dir : %s\n", getenv("WRITEABLE")); DLOG("LUA writable dir : %s\n", getenv("WRITABLE"));
} }
#ifndef __CYGWIN__ #ifndef __CYGWIN__
if (params.droproot) if (params.droproot)
+1 -1
View File
@@ -10,4 +10,4 @@ extern volatile sig_atomic_t bQuit;
int main(int argc, char *argv[]); int main(int argc, char *argv[]);
// when something changes that can break LUA compatibility this version should be increased // when something changes that can break LUA compatibility this version should be increased
#define LUA_COMPAT_VER 5 #define LUA_COMPAT_VER 6
+2 -2
View File
@@ -190,8 +190,8 @@ struct params_s
uint64_t payload_disable; uint64_t payload_disable;
struct str_list_head lua_init_scripts; struct str_list_head lua_init_scripts;
bool writeable_dir_enable; bool writable_dir_enable;
char writeable_dir[PATH_MAX]; char writable_dir[PATH_MAX];
timer_pool *timers; timer_pool *timers;
bool timers_dirty; // changed something in timers bool timers_dirty; // changed something in timers