feat(logins): login accounts and console and Remote Desktop sessions (NetOrk/netork#2895)

get_login_accounts reads the host's own accounts (Get-LocalUser), their
last login and failed attempts from the account database, expiry and
lock, and whether each is an administrator (S-1-5-32-544, by SID) or may
log in over Remote Desktop (the logon right and its denial from
secedit, the host's fDenyTSConnections). groups lists the groups that
grant either, with every member, a domain's included. uid is the RID,
sid the SID. A domain controller's accounts are not read.

get_login_sessions reads logon events 4624 of type 2, 10 and 11 of the
last seven days from the Security log, ended by 4634/4647, an
administrator's two linked logons as one session. own_address is the
reading's own WinRM logon's address; records_since the log's oldest
event. A log without any logon raises LoginSessionsUnavailable.

Both scripts are in tools/harvest.py.
This commit is contained in:
Christian Manivong committed 2026-12-01 12:55:49 +01:00
1 parent 977ddbd904
commit de6ab3c801
14 files changed
+1789 -4

No files matched your search

+5 -2
View File
@@ -5,7 +5,8 @@
Asks for the password, runs every getter script over one WinRM connection and
writes the raw JSON to tools/harvest-out/<label>/<fixture>.json — the same file
names as tests/fixtures/synthetic/. harvest-out/ is gitignored: scrub serials,
MAC and IP addresses and host names before copying anything into tests/.
MAC and IP addresses, host names, account names and SIDs before copying anything into
tests/.
"""
from __future__ import annotations
@@ -14,7 +15,7 @@ import argparse
import getpass
import pathlib
from napalm_windows import WindowsDriver, scheduled_tasks, time_sync
from napalm_windows import WindowsDriver, login_accounts, login_sessions, scheduled_tasks, time_sync
from napalm_windows import windows as mod
SCRIPTS = {
@@ -27,6 +28,8 @@ SCRIPTS = {
"listening": mod._PS_LISTENING,
"scheduled_tasks": scheduled_tasks._PS_SCHEDULED_TASKS,
"time_sync": time_sync._PS_TIME_SYNC,
"login_accounts": login_accounts._PS_LOGIN_ACCOUNTS,
"login_sessions": login_sessions._PS_LOGIN_SESSIONS,
}
OUT = pathlib.Path(__file__).parent / "harvest-out"