By Mike Danseglio, Robbie Allen
Book Price: $49.95 USD
£35.50 GBP
PDF Price: $39.99
Cover | Table of Contents
http://support.microsoft.com/), Microsoft Developer Network (MSDN
) documentation
(http://msdn.microsoft.com), or the Windows Server 2003 product documentation.http://www.microsoft.com/windows/reskits/. The Microsoft Installer (MSI) for the Windows Support Tools
can be found on a Windows 2000 Server or Windows Server 2003 CD in the \support\tools directory.runas utility when you invoke a script from the command line, or even use runas to open an administrative command prompt and launch other applications from there. Another option is to use the Scheduled Tasks service to run the script under credentials you specify when creating the scheduled task. And yet another option is to hardcode the credentials in the script. Obviously, the latter approach is not very appealing in many scenarios because you do not want the username and password contained in the script to be easily viewable by others. In addition to being insecure, it's also a maintenance nightmare when those user credentials change. Nevertheless, at times it is a necessary evil, especially when working against multiple servers, and we'll describe how it can be done with WMI, ADSI, and ADO.
strComputer = "." ' localhost
set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
set objDisks = objWMI.InstancesOf("Win32_LogicalDisk")
for each objDisk in objDisks
Wscript.Echo "DeviceID: " & objDisk.DeviceID
Wscript.Echo "FileSystem: " & objDisk.FileSystem
Wscript.Echo "FreeSpace: " & objDisk.FreeSpace
Wscript.Echo "Size: " & objDisk.Size
WScript.Echo ""
nextdc=amer,dc=rallencorp,dc=com)amer.rallencorp.com)Administrator)cn=administrator,cn=users,dc=rallencorp,dc=com)rallen-xp)http://www.microsoft.com/security/msrc that describes how it works and what you can expect when you contact it./? as a parameter. For example:
> dsquery /?http://support.microsoft.com/. You can also append the KB article number to the end of the following URL to go directly to the article: http://support.microsoft.com/?kbid=.http://technet.microsoft.com/.baseline
), it's almost impossible to guarantee a known secure state in the future.clean start
. The clean start gives an administrator the opportunity to protect the system proactively. Most purist security administrators consider any system that becomes compromised as untrustworthy and must be completely rebuilt. So if the build process itself is compromised, all computers based on that process are also compromised. The result could be an entire organization of computers that are not only untrustworthy but cannot be made trustworthy without taking drastic measures. The clean start must also include appropriate initial configuration to help ensure that the computer is not compromised the moment it connects to the network.baseline
), it's almost impossible to guarantee a known secure state in the future.clean start
. The clean start gives an administrator the opportunity to protect the system proactively. Most purist security administrators consider any system that becomes compromised as untrustworthy and must be completely rebuilt. So if the build process itself is compromised, all computers based on that process are also compromised. The result could be an entire organization of computers that are not only untrustworthy but cannot be made trustworthy without taking drastic measures. The clean start must also include appropriate initial configuration to help ensure that the computer is not compromised the moment it connects to the network.Administrator to Mike in the domain Contoso:
> renuser Administrator Mike Contoso
http://www.loa.espci.fr/winnt/renuser/renuser.htm.You can also use the built-in dsmove tool to rename an account, as shown in this example:
> dsmove CN=Administrator,CN=Users,DC=Contoso,DC=com -newname Mike
-newname option specifies the new name for the user object.
' This code renames the domain administrator account.
' ------ SCRIPT CONFIGURATION ------
strParentDN = "<ParentDN>" ' e.g. cn=Users,dc=rallenc orp,dc=com
strUserOldName = "<OldUserName>" ' e.g. administrator
strUserNewName = "<NewUserName>" ' e.g. mike
' ------ END CONFIGURATION ---------
set objCont = GetObject("LDAP://" & strParentDN)
objCont.MoveHere "LDAP://cn=" & strUserOldName & "," & strParentDN, _
"cn=" & strUserNewName
set objUser = GetObject("LDAP://cn=" & strUserNewName & "," & strParentDN)
objUser.Put "sAMAccountName", strUserNewName
objUser.SetInfo
WScript.Echo "Rename successful"
Administrator to Mike:
> renuser Administrator Mike
http://www.loa.espci.fr/winnt/renuser/renuser.htm.Path | Computer Configuration\Windows Settings\Security Settings\Local Policies\Security Options\ |
Policy name | Accounts: Rename administrator account |
Value | Define this policy setting; <NewAdministratorName> |
' This code renames the local administrator account.
' ------ SCRIPT CONFIGURATION ------
strComputer = "."
strNewName = "<NewUserName>" ' e.g. mike
' ------ END CONFIGURATION ---------
set objComputer = GetObject("WinNT://" & strComputer)
set objUser = GetObject("WinNT://" & strComputer & _
"/Administrator,user")
set objNewUser = objComputer.MoveHere(objUser.ADsPath,strNewName)
WScript.Echo "Successfully renamed account to: " & strNewNamePath | Computer Configuration\Windows Settings\Security Settings\Local Policies\Security Options\ |
Policy name | Accounts: Administrator account status |
Value | Define this policy setting; Enabled |
' This code disables the local administrator account.
' ------ SCRIPT CONFIGURATION ------
strComputer = "."
strAdminName = "<NewAdminName>" ' e.g. mike
' ------ END CONFIGURATION ---------
set objComputer = GetObject("WinNT://" & strComputer)
set objUser = GetObject("WinNT://" & strComputer & _
"/" & strAdminName & ",user")
objUser.AccountDisabled = TRUE
objUser.SetInfo
WScript.Echo "Successfully disabled account: " & strAdminNameGuest to the name Fred in the domain Contoso:
> renuser Guest Fred Contoso
www.ntfaq.com. You can also use the built-in dsutil tool to rename an account, as shown in this example:
> dsmove CN=Guest,CN=Users,DC=Contoso,DC=com -newname Fred
CN= options to define the object name and location, and DC= options to define the domain name. The -newname option specifies the new name for the user object.
' This code renames the domain guest account.
' ------ SCRIPT CONFIGURATION ------
strParentDN = "<ParentDN>" ' e.g. cn=Users,dc=rallenc orp,dc=com
strUserOldName = "<OldUserName>" ' e.g. guest
strUserNewName = "<NewUserName>" ' e.g. fred
' ------ END CONFIGURATION ---------
set objCont = GetObject("LDAP://" & strParentDN)
objCont.MoveHere "LDAP://cn=" & strUserOldName & "," & strParentDN, _
"cn=" & strUserNewName
set objUser = GetObject("LDAP://cn=" & strUserNewName & "," & strParentDN)
objUser.Put "sAMAccountName", strUserNewName
objUser.SetInfo
WScript.Echo "Rename successful"
> runas /user:Contoso\DomainAdmin mmc.exe
/user switch indicates the identity of the user in domain\username format.
> runas /smartcard cmd.exe
Path | Computer Configuration\Windows Settings\Security Settings\Local Policies\User Rights Assignment\ |
Policy name | Load and unload device drivers |
Value | <GroupList> |
<GroupList> is a list of all users and groups that can load and unload device drivers. You can add or remove any user or group.Path | Computer Configuration\Windows Settings\Security Settings\Local Policies\Security Options\ |
Policy name | Devices: Unsigned driver installation |
Value | Do not allow installation |
syskey
encrypts the SAM. The encryption key can be stored in the Registry, on floppy disk, or derived from a supplied password
. This helps thwart attackers because the SAM is no longer in cleartext. A successful attack now becomes a matter of breaking the Syskey encryption before any other attacks can be attempted. This is a very effective countermeasure to such an offline SAM attack.Path | Computer Configuration\Administrative Templates \Display |
Policy name | Password protect the screen saver |
Value | Enabled |
Policy name | Screen Saver timeout |
Value | 300 seconds |
Policy name | Screen Saver executable name |
Value | Scrnsave.scr |