From bdcf2bdc5f2d3c6fe71a28b70af08f3f91f5039e Mon Sep 17 00:00:00 2001 From: PTah Date: Mon, 4 May 2026 09:02:14 +1000 Subject: [PATCH] docs: expand ignore.lst section in README and README_eng --- README.md | 38 ++++++++++++++++++++++++++++++++++---- README_eng.md | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ed334c7..b8f3a8b 100644 --- a/README.md +++ b/README.md @@ -86,11 +86,41 @@ powershell.exe -NoProfile -ExecutionPolicy Bypass -File "C:\ProgramData\RDP-logi ## 7) Подавление уведомлений Security: `ignore.lst` -В каталоге установки можно положить файл **`C:\ProgramData\RDP-login-monitor\ignore.lst`** (рядом с **`Login_Monitor.ps1`**). Он влияет **только** на уведомления по событиям **`4624`/`4625`** (успех/неудача входа в журнале Security). События **RD Gateway (`302`/`303`)**, **RCM `1149`**, ежедневный отчёт и heartbeat **не фильтруются** этим файлом. +В каталоге установки можно положить файл **`C:\ProgramData\RDP-login-monitor\ignore.lst`** (рядом с **`Login_Monitor.ps1`**). Правила из списка проверяются **только** для Telegram-уведомлений по событиям **`4624`/`4625`** журнала Security (успех/неудача входа). Жёстко заданные в скрипте исключения (`ExcludedUsers`, локальный IP, сервисные учётные записи и т.д.) по-прежнему действуют для всех типов событий; **`ignore.lst`** добавляет к ним **дополнительные** совпадения именно для **4624/4625**. -- Кодировка файла: **UTF-8** (как и для остальных текстовых конфигов). -- Комментарии: строки, начинающиеся с **`#`** или **`;`**, игнорируются. -- Форматы строк и примеры — в **`ignore.lst.example`** в корне репозитория (скопируйте на сервер как `ignore.lst` и отредактируйте). +События **RD Gateway (`302`/`303`)**, **RCM `1149`**, ежедневный отчёт и heartbeat **этим файлом не настраиваются** (для `1149` список не используется, даже если формально вызывается общая функция фильтрации). + +### Как читается файл + +- Чтение выполняется по мере обработки событий; содержимое **кэшируется в памяти**. Если **`LastWriteTimeUtc`** файла изменился (редактирование и сохранение), список **перечитывается автоматически** — перезапуск монитора не обязателен. +- Кодировка: **UTF-8** (`Get-Content -Encoding UTF8`). Строка может начинаться с BOM — он отбрасывается при разборе. +- Пустые строки пропускаются. Строки, начинающиеся с **`#`** или **`;`**, считаются комментариями. +- Строка с **`:`**: берётся **первая** двоеточие — всё слева (после обрезки пробелов) определяет тип правила, всё справа — значение. Если справа пусто, строка игнорируется. +- Строка **без** **`:`**: целиком трактуется как правило типа «любое совпадение» (см. ниже). + +### Типы правил (левая часть до первого `:`) + +| Левая часть (фрагменты совпадают как regex, без учёта регистра) | Поле события | +| --- | --- | +| `рабоч`, `workstation`, `wks` | имя рабочей станции (**WorkstationName** и аналоги в XML события) | +| `польз`, `username`, `subject`, `account`, `target user`, целое слово `user` | имя пользователя (**TargetUserName** и др.) | +| `ip`, `ip адрес`, `ipaddress`, `адрес ip` | IP источника (**IpAddress** и др.), только если в событии есть непустой IP | + +Если левая часть **не** подошла ни к одному типу, но двоеточие есть — используется режим как в разборе строк Telegram: тип **«любое»**, значение — **только правая часть** (метка слева отбрасывается). + +### Совпадение для типа «любое» (строка без `:` или «неизвестная» метка слева от `:`) + +Проверка по очереди: + +1. Если значение похоже на **IPv4** — сравнивается с IP источника в событии (точное совпадение, без учёта регистра для текста не применимо). +2. Если значение содержит **`\`** — сравнивается с **учётной записью**: полное совпадение с `DOMAIN\user` **или** совпадение с **SAM** после последнего `\` (как `DOMAIN\IVANOV` при правиле `IVANOV`). +3. Иначе сначала полное совпадение с **именем рабочей станции**, затем с **учётной записью** по тем же правилам, что в п.2. + +Для явных типов **User** / **Workstation** / **Ip** используется только соответствующее поле (для пользователя — те же правила полного имени и SAM, что в п.2). + +### Примеры и поставка + +- Расширенные примеры строк — в **`ignore.lst.example`** в корне репозитория (скопируйте на сервер как **`ignore.lst`** и отредактируйте). - **`Deploy-LoginMonitor.ps1`** этот файл **не копирует**: правила обычно разные на каждой машине; при необходимости создайте `ignore.lst` вручную или через вашу систему конфигурации. ## Ключевые слова (для поиска репозитория) diff --git a/README_eng.md b/README_eng.md index 55802a0..29e05aa 100644 --- a/README_eng.md +++ b/README_eng.md @@ -33,6 +33,7 @@ PowerShell toolkit for monitoring Windows logons with Telegram notifications. 4. Run elevated (Security log access and task registration). 5. Logs and auxiliary files: - `C:\ProgramData\RDP-login-monitor\Logs\` +6. (Optional) Suppress some Security alerts via **`ignore.lst`** — see **section 7** below. ## 2) Manual run @@ -81,6 +82,46 @@ For domain deployment from a share you do not configure the scheduler on clients - **`-SkipScheduledTaskMaintenance`**: during normal monitor startup, skip verification/recreation of scheduled tasks (if you manage tasks only via **`-InstallTasks`** or manually). - **`Install-DeployScheduledTask.ps1`** — helper to run **`Deploy-LoginMonitor.ps1`** from a share on a schedule (see **[DEPLOY.md](DEPLOY.md)**). - **`Watchdog_RDP_Monitor.ps1`** and **`Install-ScheduledTasks.ps1`** — **alternate** layout with a separate watchdog script and default paths under **`D:\Soft`**. For new installs, prefer the built-in **`-Watchdog`** in **`Login_Monitor.ps1`** and tasks **`RDP-Login-Monitor`** / **`RDP-Login-Monitor-Watchdog`**. +- **`ignore.lst.example`** in the repo is a template for **`ignore.lst`** to suppress selected Security notifications (see section 7). + +## 7) Suppressing Security alerts: `ignore.lst` + +Place a file **`C:\ProgramData\RDP-login-monitor\ignore.lst`** next to **`Login_Monitor.ps1`**. Rules in this list are evaluated **only** for Telegram notifications from Security events **`4624`/`4625`** (successful/failed logons). Built-in exclusions in the script (`ExcludedUsers`, loopback IPs, service-style accounts, etc.) still apply to all event paths; **`ignore.lst`** adds **extra** matches **for 4624/4625 only**. + +**RD Gateway (`302`/`303`)**, **RCM `1149`**, the daily report, and heartbeat **are not controlled** by this file (for `1149` the list is not applied, even though a shared filter function runs). + +### How the file is loaded + +- The file is read during event processing; entries are **cached in memory**. If **`LastWriteTimeUtc`** changes (save after edit), the list is **reloaded automatically** — no monitor restart required. +- Encoding: **UTF-8** (`Get-Content -Encoding UTF8`). A UTF-8 BOM at the start of a line is stripped when parsing. +- Blank lines are skipped. Lines starting with **`#`** or **`;`** are comments. +- If the line contains **`:`**, the **first** colon splits the line: the left part (trimmed) selects the rule kind, the right part is the value. If the right part is empty, the line is ignored. +- If there is **no** colon, the whole trimmed line is one “match-any” value (see below). + +### Rule kinds (left part before the first `:`) + +| Left part (case-insensitive regex fragments) | Event field | +| --- | --- | +| `рабоч`, `workstation`, `wks` | workstation name (**WorkstationName** and similar XML fields) | +| `польз`, `username`, `subject`, `account`, `target user`, whole word `user` | user name (**TargetUserName**, etc.) | +| `ip`, `ip адрес`, `ipaddress`, `адрес ip` | source IP (**IpAddress**, etc.) when present | + +If the left part matches none of the above but a colon exists, the parser behaves like the Telegram line splitter: kind is **Any**, value is **only the right part** (the label on the left is discarded). + +### “Any” matching (no colon, or unknown label before `:`) + +Evaluated in order: + +1. If the value looks like **IPv4**, it is compared to the event source IP (exact match). +2. If the value contains **`\`**, it is matched against the **account**: full `DOMAIN\user` equality **or** SAM after the last `\` (e.g. rule `IVANOV` matches `DOMAIN\IVANOV`). +3. Otherwise: exact match against **workstation name** first, then the same account rules as in step 2. + +Explicit **User** / **Workstation** / **Ip** kinds only compare their respective field (user rules use the same full-name and SAM behavior as step 2). + +### Examples and deployment + +- See **`ignore.lst.example`** in the repo; copy it to the server as **`ignore.lst`** and edit. +- **`Deploy-LoginMonitor.ps1`** does **not** copy this file — rules are usually host-specific; create **`ignore.lst`** manually or via your configuration tooling. ## Keywords (for discovery)