Home page logo

basics logo Security Basics mailing list archives

RE: Local Administrators
From: Joey Peloquin <jpelo1 () jcpenney com>
Date: Tue, 30 Dec 2003 20:31:51 -0600


Here's something to output a txt file in the format:


It reads and writes input and output from its current directory.  There is
pretty much no error checking, but it does confirm the machine is up first.
Specify the group to enumerate in the function, EnumServer(); currently is

In case you don't know, copy and paste the text into notepad, save the file
with a '.vbs' extension, and run it from the command line with 'cscript':
cscript EnumGroupUsers.vbs

Works for the ~250 machines I'm responsible for ...

Joey Peloquin

=-- Begin Script -----------------------

dim strQuery, strServer, strGroup
dim oGroup, oWSH, oFSO, oLogfile, oInputFile
dim blnServerUp, aServers, i, Group, Member

Set oWSH = CreateObject("Wscript.Shell")
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oLogFile = oFSO.OpenTextFile("output.log", 8, True)
Set oInputFile = oFSO.OpenTextFile("servers.txt", 1)
strInput = oInputFile.ReadAll()
aServers = Split(strInput, vbCrLf)
Set oInputFile = Nothing

' Main Loop
Trace "----------------------------------------------------------------"
Trace "EnumGroupUsers.vbs started: " & Date & " -- " & Time
Trace "----------------------------------------------------------------"

For i = 0 to UBound(aServers)
        If aServers(i) <> "" Then
                strServer = aServers(i) ' Retrieve Server Name
                Call ServerUp(strServer) ' Check to see if server is up
                If blnServerUp = True Then
                        Trace strServer
                        Call EnumServer(strServer)
                        Trace strServer & vbTab & "Offline"
                End If
        End If

Trace "----------------------------------------------------------------"
Trace "Script Completed at: " & Time
Trace "----------------------------------------------------------------"

oWSH.Run "notepad.exe output.log"
Set oGroup = Nothing
Set oLogFile = Nothing
Set oFSO = Nothing
Set oWSH = Nothing

'------------------= Functions and SubRoutines =-------------------

Function EnumServer(Server)
strGroup = "Administrators"
Set oGroup = GetObject("WinNT://" & strServer & "/" & strGroup & ",group")
        For each Member in oGroup.Members
                'Trace strServer & vbTab & vbCrLf & _
                Trace "---" & Member.Name
End Function

Sub ServerUp(Server)
  blnServerUp = True ' Make an assumption
  If oFSO.DriveExists("\\" & Server & "\" & "ADMIN$") = False Then
    blnServerUp = False
    If Err.Number <> 0 Then
      blnServerUp = False
    End If
  End If
End Sub

' Logging Sub Routine
Sub Trace(LogInfo)
        oLogFile.WriteLine LogInfo
End Sub

=-- End Script -----------------------


The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material.  If the reader of this message is not the intended recipient,
you are hereby notified that your access is unauthorized, and any review,
dissemination, distribution or copying of this message including any
attachments is strictly prohibited.   If you are not the intended
recipient, please contact the sender and delete the material from any


  By Date           By Thread  

Current thread:
[ Nmap | Sec Tools | Mailing Lists | Site News | About/Contact | Advertising | Privacy ]