跟踪本地用户帐户的安全审计

我想编译networking上所有服务器的本地用户帐户列表。 这将包括域和非域W2K3机器。 一个脚本来运行networking用户和pipe道结果到一个文件? 任何帮助表示赞赏。 谢谢

快速和肮脏的方式

您需要使用Microsoft的PsExec才能使用此脚本。 我假设您可以使用相同的用户名和密码连接到非域成员和域成员计算机。 如果这是不可能的,让我知道,我会稍微改变剧本。

将机器名称列表放入machines.txt中并运行:

@echo off for /F "delims=" %%i in (machines.txt) do ( psexec \\%%i NET USER > %%i.txt ) 

你将得到一堆格式为computer-name.txt的文本文件,并在每台计算机上输出“NET USER”。

花式(tm)的方式

这是相当快速和肮脏的,输出将是相当痛苦的parsing。 这是VBScript中的一个fancier脚本:

 Option Explicit Dim dictGroupsToIgnore, dictUsersToIgnore, objNetwork, strComputer Dim colUsers, colGroups, objGroup, objUser ' Debugging Const DEBUGGING = True ' Constants for comparison of accounts to ignore list Const MATCH_EXACT = 1 Const MATCH_LEFT = 2 Set dictGroupsToIgnore = CreateObject("Scripting.Dictionary") ' dictGroupsToIgnore.Add "Name of group you want to ignore (matching left only)", MATCH_LEFT ' dictGroupsToIgnore.Add "Name of group you want to ignore", MATCH_EXACT ' Accounts to ignore during copying Set dictUsersToIgnore = CreateObject("Scripting.Dictionary") ' dictUsersToIgnore.Add "Name of user you want to ignore (matching left only)", MATCH_LEFT ' dictUsersToIgnore.Add "Name of user you want to ignore", MATCH_EXACT ' Should this account be ignored Function IgnoreObject(Name, dictNames) Dim strToIgnore IgnoreObject = False For Each strToIgnore in dictNames ' Match Exact If (dictNames.Item(strToIgnore) = MATCH_EXACT) and (UCase(Name) = UCase(strToIgnore)) Then IgnoreObject = True Exit Function End If ' Match left If (dictNames.Item(strToIgnore) = MATCH_LEFT) and (Left(UCase(Name), Len(strToIgnore)) = UCase(strToIgnore)) Then IgnoreObject = True Exit Function End If Next' strToIgnore End Function ' Main Set objNetwork = CreateObject("Wscript.Network") While NOT WScript.StdIn.AtEndOfStream strComputer = WScript.StdIn.ReadLine ' Get accounts on source computer and loop through them, copying as necessary Set colUsers = GetObject("WinNT://" & strComputer) colUsers.Filter = Array("user") For Each objUser In colUsers If IgnoreObject(objUser.Name, dictUsersToIgnore) = False Then WScript.Echo strComputer & Chr(9) & "user" & Chr(9) & objUser.Name End If Next ' objUser ' Get groups on source computer and loop through them, copying as necessary Set colGroups = GetObject("WinNT://" & strComputer) colGroups.Filter = Array("group") ' Put user into destination groups For Each objGroup In colGroups If IgnoreObject(objGroup.Name, dictGroupsToIgnore) = False then For Each objUser In objGroup.Members WScript.Echo strComputer & Chr(9) & "group" & Chr(9) & objGroup.Name & Chr(9) & "member" & Chr(9) & objUser.Name Next ' objUser End If Next 'objGroup Wend ' WScript.StdIn.AtEndOfStream 

我已经包含了一些function来“忽略”组或用户。

  • 将不应报告给dictGroupsToIgnore列表的任何组名称(如脚本中所示)。 MATCH_EXACT表示组的名称完全匹配。 MATCH_LEFT意味着只有组名的最左边部分将被匹配(即,想象名称匹配后面有一个“*”)。

  • 添加不应报告给dictUsersToIgnore列表的任何用户名(如脚本中所示)。 MATCH_EXACT和MATCH_LEFT具有与dictGroupsToIgnores列表相同的含义(即“IUSR_”和MATCH_LEFT意味着任何以“IUSR_”开头的用户帐户都不会被报告)。

调用这个脚本redirect来自文本文件的input并输出到一个文本文件(即“cscript script-name.vbs <machines.txt> report.txt”),你将得到一个TAB分隔格式的输出:

 computer_name user username computer_name group groupname member member_1_name computer_name group groupname member member_2_name computer_name group groupname member member_3_name ... 

您可能不需要群组信息,但稍后可以轻松过滤掉。

如果您需要使用不同凭据连接到每台机器,请告诉我,我将稍微更改一下脚本。

我记得几年前在类似的事情上工作。 可能有5种方法可以通过脚本轻松完成此任务。不过,最近我将其引入到SYDI中,我build议您检查一下,它可能会带来更多好处,然后只是本地审计跟踪用户。

http://sydiproject.com/tools/sydi-audit-localgroups/

从站点Snippit:使用scheme您可能想要跟踪您的组织中有多less本地pipe理员,也许有些用户已经暂时放置在本地pipe理员组中,但现在已经解决了它提供的所有权限。 即使您的组织尚未禁止本地pipe理访问,您仍然可能希望能够以黑白的forms查看哪些用户已被授予此访问权限。 Power Users组可以是您要监视的另一个组。

如果你有一个标准化的环境,你的客户的组织结构应该都是一样的。 您可以使用该工具查找不应该在其中的任何其他组。

使用脚本像许多其他的SYDI工具一样,这个脚本是用vbscript编写的,目的是从cscript.exe运行。 要使用它,您需要提供SYDI服务器输出文件path的参数:

Cscript.exe sydi-audit-localgroups.vbs -xN:\ SYDI \ Output

让我知道它是如何工作的

尼克