我们都知道DOS命令Copy的主要作用是复制文件,可是你是否知道,它还有一个作用是合并文件呢?
一般情况下,它主要用于合并相同类型的文件,比如将两个文本文件合并为一个文本文件、将两个独立的MPEG视频文件合并为一个连续的视频文件等。那么,如果用它合并两个不同类型的文件,结果会怎样呢?
笔者发现,巧妙地将一个文本文件合并到一个非文本文件中,可以实现隐藏秘密的作用。一起来看看吧。
比如你有一段私人信息要隐藏起来,请先录入并保存为文本文件,假设保存为001.txt。另找一个非文本文件,最好为图片文件或可执行文件。以图片文件为例,假设它的文件名为002.jpg。如果把它们都放到D盘根目录下,那么在Windows的MS-DOS方式下执行以下命令:
- d:\Copy 002.jpg/b + 001.txt/a 003.jpg
其中参数/b指定以二进制格式复制、合并文件;参数/a指定以ASCII格式复制、合并文件。这里要注意文件的顺序,二进制格式的文件应放在加号前,文本格式的文件放在加号后。
执行该命令后,生成了一个新文件003.jpg。回到Windows中用图片浏览软件打开这个它,你会发现它与002.jpg的显示结果一模一样——别着急,秘密马上揭晓!用记事本打开003.jpg(在记事本的“打开”对话框中选择“文件类型”为“所有文件”才能打开非TXT文件;或者直接用鼠标把图片拖进记事本窗口),你看到什么了?一堆乱码吗?没错!但如果你按下Ctrl+End键将光标移至文件的尾部,哈,你再看看!是不是001.txt文件中的内容?呵呵,“秘密”原来在这儿。
按照这种方法,你可以轻松地把一些重要信息隐藏起来,比如用户ID、密码、重要私人信息等。
这个方法的确很巧妙,推荐尝试!哪怕你并不想隐藏什么,它也能带给你一种新奇的感觉。但经过我的验证,有一点要提醒大家:就是这个文本文件的前面最好空上3行以上,这样它头部的内容就不会丢失。
Windows NT家族的操作系统——Windows XP、Windows 2000、NT 4.0和NT 3.x一直以缺乏安全性饱受争议。但实际上,这些操作系统(包括Novell Netware和各种UNIX变种)都具有相当好的安全性,它们都装备了数以千计的“锁”——这是一些操作系统用来确保安全性的部件,能够让我们作出只允许用户A可以在对象B上实施动作C之类的规定。
Windows服务管理脚本:列出所有服务,停止、启动、删除和安装服务
本日志由 flyinweb 于 2009-06-18 13:00:27 发表到 Windows 中,目前已经被浏览 240 次,评论 0 次;
作者添加了以下标签: Windows服务管理;
首页只显示了部分日志内容,要查看日志的全部内容请阅读全文;
- '********************************************************************
- '*
- '* file: Restart.vbs
- '* Created: March 1999
- '* Version: 1.0
- '*
- '* Main Function: Shutsdown, PowerOff, LogOff, Restarts a machine.
- '*
- '* Restart.vbs /S <server> [/U <username>] [/W <password>]
- '* [/O <outputfile>] [/L} [/P] [/R] [/Q] [/F] [/T <time in seconds>]
- '*
- '* Copyright (C) 1999 Microsoft Corporation
- '*
- '********************************************************************
- OPTION EXPLICIT
- 'Define constants
- CONST CONST_ERROR = 0
- CONST CONST_WSCRIPT = 1
- CONST CONST_CSCRIPT = 2
- CONST CONST_SHOW_USAGE = 3
- CONST CONST_PROCEED = 4
- 'Shutdown Method Constants
- CONST CONST_SHUTDOWN = 1
- CONST CONST_LOGOFF = 0
- CONST CONST_POWEROFF = 8
- CONST CONST_REBOOT = 2
- CONST CONST_FORCE_REBOOT = 6
- CONST CONST_FORCE_POWEROFF = 12
- CONST CONST_FORCE_LOGOFF = 4
- CONST CONST_FORCE_SHUTDOWN = 5
- 'Declare variables
- Dim intOpMode, i
- Dim strServer, strUserName, strPassword, strOutputFile
- Dim blnLogoff, blnPowerOff, blnReBoot, blnShutDown
- Dim blnForce
- Dim intTimer
- Dim UserArray(3)
- Dim MyCount
- 'Make sure the host is csript, if not then abort
- VerifyHostIsCscript()
- 'Parse the command line
- intOpMode = intParseCmdLine(strServer , _
- strUserName , _
- strPassword , _
- strOutputFile , _
- blnLogoff , _
- blnPowerOff , _
- blnReBoot , _
- blnShutdown , _
- blnForce , _
- intTimer )
- Select Case intOpMode
- Case CONST_SHOW_USAGE
- Call ShowUsage()
- Case CONST_PROCEED
- Call Reboot(strServer , _
- strOutputFile , _
- strUserName , _
- strPassword , _
- blnReboot , _
- blnForce , _
- intTimer )
- Call LogOff(strServer , _
- strOutputFile , _
- strUserName , _
- strPassword , _
- blnLogoff , _
- blnForce , _
- intTimer )
- Call PowerOff(strServer , _
- strOutputFile , _
- strUserName , _
- strPassword , _
- blnPowerOff , _
- blnForce , _
- intTimer )
- Call ShutDown(strServer , _
- strOutputFile , _
- strUserName , _
- strPassword , _
- blnShutDown , _
- blnForce , _
- intTimer )
- Case CONST_ERROR
- 'Do Nothing
- Case Else 'Default -- should never happen
- Call Wscript.Echo("Error occurred in passing parameters.")
- End Select
- '********************************************************************
- '*
- '* Sub Reboot()
- '*
- '* Purpose: Reboots a machine.
- '*
- '* Input: strServer a machine name
- '* strOutputFile an output file name
- '* strUserName the current user's name
- '* strPassword the current user's password
- '* blnForce specifies whether to force the logoff
- '* intTimer specifies the amount of time to perform the function
- '*
- '* Output: Results are either printed on screen or saved in strOutputFile.
- '*
- '********************************************************************
- Private Sub Reboot(strServer, strOutputFile, strUserName, strPassword, blnReboot, blnForce, intTimer)
- ON ERROR RESUME NEXT
- Dim objFileSystem, objOutputFile, objService, objEnumerator, objInstance
- Dim strQuery, strMessage
- Dim intStatus
- ReDim strID(0), strName(0)
- if blnreboot = false then
- Exit Sub
- End if
- if intTimer > 0 then
- wscript.echo "Rebooting machine " & strServer & " in " & intTimer & " seconds..."
- wscript.sleep (intTimer * 1000)
- End if
- 'Open a text file for output if the file is requested
- If Not IsEmpty(strOutputFile) Then
- If (NOT blnOpenFile(strOutputFile, objOutputFile)) Then
- Call Wscript.Echo ("Could not open an output file.")
- Exit Sub
- End If
- End If
- 'Establish a connection with the server.
- If blnConnect("root\cimv2" , _
- strUserName , _
- strPassword , _
- strServer , _
- objService ) Then
- Call Wscript.Echo("")
- Call Wscript.Echo("Please check the server name, " _
- & "credentials and WBEM Core.")
- Exit Sub
- End If
- strID(0) = ""
- strName(0) = ""
- strMessage = ""
- strQuery = "Select * From Win32_OperatingSystem"
- Set objEnumerator = objService.ExecQuery(strQuery,,0)
- If Err.Number Then
- Print "Error 0x" & CStr(Hex(Err.Number)) & " occurred during the query."
- If Err.Description <> "" Then
- Print "Error description: " & Err.Description & "."
- End If
- Err.Clear
- Exit Sub
- End If
- i = 0
- For Each objInstance in objEnumerator
- If blnForce Then
- intStatus = objInstance.Win32ShutDown(CONST_FORCE_REBOOT)
- Else
- intStatus = objInstance.Win32ShutDown(CONST_REBOOT)
- End If
- IF intStatus = 0 Then
- strMessage = "Reboot a machine " & strServer & "."
- Else
- strMessage = "Failed to reboot a machine " & strServer & "."
- End If
- Call WriteLine(strMessage,objOutputFile)
- Next
- If IsObject(objOutputFile) Then
- objOutputFile.Close
- Call Wscript.Echo ("Results are saved in file " & strOutputFile & ".")
- End If
- End Sub
- '********************************************************************
- '*
- '* Sub LogOff()
- '*
- '* Purpose: Logs off the user currently logged onto a machine.
- '*
- '* Input: strServer a machine name
- '* strOutputFile an output file name
- '* strUserName the current user's name
- '* strPassword the current user's password
- '* blnForce specifies whether to force the logoff
- '* intTimer specifies the amount of time to preform the function
- '*
- '* Output: Results are either printed on screen or saved in strOutputFile.
- '*
- '********************************************************************
- Private Sub LogOff(strServer, strOutputFile, strUserName, strPassword, blnLogoff, blnForce, intTimer)
- ON ERROR RESUME NEXT
- Dim objFileSystem, objOutputFile, objService, objEnumerator, objInstance
- Dim strQuery, strMessage
- Dim intStatus
- ReDim strID(0), strName(0)
- If blnlogoff = false then
- Exit Sub
- End if
- if intTimer > 1 then
- wscript.echo "Logging off machine " & strServer & " in " & intTimer & " seconds..."
- wscript.sleep (intTimer * 1000)
- End if
- 'Open a text file for output if the file is requested
- If Not IsEmpty(strOutputFile) Then
- If (NOT blnOpenFile(strOutputFile, objOutputFile)) Then
- Call Wscript.Echo ("Could not open an output file.")
- Exit Sub
- End If
- End If
- 'Establish a connection with the server.
- If blnConnect("root\cimv2" , _
- strUserName , _
- strPassword , _
- strServer , _
- objService ) Then
- Call Wscript.Echo("")
- Call Wscript.Echo("Please check the server name, " _
- & "credentials and WBEM Core.")
- Exit Sub
- End If
- strID(0) = ""
- strName(0) = ""
- strMessage = ""
- strQuery = "Select * From Win32_OperatingSystem"
- Set objEnumerator = objService.ExecQuery(strQuery,,0)
- If Err.Number Then
- Print "Error 0x" & CStr(Hex(Err.Number)) & " occurred during the query."
- If Err.Description <> "" Then
- Print "Error description: " & Err.Description & "."
- End If
- Err.Clear
- Exit Sub
- End If
- i = 0
- For Each objInstance in objEnumerator
- If blnForce Then
- intStatus = objInstance.Win32ShutDown(CONST_FORCE_LOGOFF)
- Else
- intStatus = objInstance.Win32ShutDown(CONST_LOGOFF)
- End If
- IF intStatus = 0 Then
- strMessage = "Logging off the current user on machine " & _
- strServer & "..."
- Else
- strMessage = "Failed to log off the current user from machine " _
- & strServer & "."
- End If
- Call WriteLine(strMessage,objOutputFile)
- Next
- If IsObject(objOutputFile) Then
- objOutputFile.Close
- Call Wscript.Echo ("Results are saved in file " & strOutputFile & ".")
- End If
- End Sub
- '********************************************************************
- '*
- '* Sub PowerOff()
- '*
- '* Purpose: Powers off a machine.
- '*
- '* Input: strServer a machine name
- '* strOutputFile an output file name
- '* strUserName the current user's name
- '* strPassword the current user's password
- '* blnForce specifies whether to force the logoff
- '* intTimer specifies the amount of time to perform the function
- '*
- '* Output: Results are either printed on screen or saved in strOutputFile.
- '*
- '********************************************************************
- Private Sub PowerOff(strServer, strOutputFile, strUserName, strPassword, blnPowerOff, blnForce, intTimer)
- ON ERROR RESUME NEXT
- Dim objFileSystem, objOutputFile, objService, objEnumerator, objInstance
- Dim strQuery, strMessage
- Dim intStatus
- ReDim strID(0), strName(0)
- if blnPoweroff = false then
- Exit sub
- End if
- If intTimer > 0 then
- wscript.echo "Powering off machine " & strServer & " in " & intTimer & " seconds..."
- wscript.sleep (intTimer * 1000)
- End if
- 'Open a text file for output if the file is requested
- If Not IsEmpty(strOutputFile) Then
- If (NOT blnOpenFile(strOutputFile, objOutputFile)) Then
- Call Wscript.Echo ("Could not open an output file.")
- Exit Sub
- End If
- End If
- 'Establish a connection with the server.
- If blnConnect("root\cimv2" , _
- strUserName , _
- strPassword , _
- strServer , _
- objService ) Then
- Call Wscript.Echo("")
- Call Wscript.Echo("Please check the server name, " _
- & "credentials and WBEM Core.")
- Exit Sub
- End If
- strID(0) = ""
- strName(0) = ""
- strMessage = ""
- strQuery = "Select * From Win32_OperatingSystem"
- Set objEnumerator = objService.ExecQuery(strQuery,,0)
- If Err.Number Then
- Print "Error 0x" & CStr(Hex(Err.Number)) & " occurred during the query."
- If Err.Description <> "" Then
- Print "Error description: " & Err.Description & "."
- End If
- Err.Clear
- Exit Sub
- End If
- i = 0
- For Each objInstance in objEnumerator
- If blnForce Then
- intStatus = objInstance.Win32ShutDown(CONST_FORCE_POWEROFF)
- Else
- intStatus = objInstance.Win32ShutDown(CONST_POWEROFF)
- End If
- IF intStatus = 0 Then
- strMessage = "Power off machine " & strServer & "."
- Else
- strMessage = "Failed to power off machine " & strServer & "."
- End If
- Call WriteLine(strMessage,objOutputFile)
- Next
- If IsObject(objOutputFile) Then
- objOutputFile.Close
- Call Wscript.Echo ("Results are saved in file " & strOutputFile & ".")
- End If
- End Sub
- '********************************************************************
- '*
- '* Sub Shutdown()
- '*
- '* Purpose: Shutsdown a machine.
- '*
- '* Input: strServer a machine name
- '* strOutputFile an output file name
- '* strUserName the current user's name
- '* strPassword the current user's password
- '* blnForce specifies whether to force the logoff
- '* intTimer specifies the amount of time to perform the function
- '*
- '* Output: Results are either printed on screen or saved in strOutputFile.
- '*
- '********************************************************************
- Private Sub Shutdown(strServer, strOutputFile, strUserName, strPassword, blnShutDown, blnForce, intTimer)
- ON ERROR RESUME NEXT
- Dim objFileSystem, objOutputFile, objService, objEnumerator, objInstance
- Dim strQuery, strMessage
- Dim intStatus
- ReDim strID(0), strName(0)
- If blnShutdown = False then
- Exit Sub
- End if
- if intTimer > 0 then
- wscript.echo "Shutting down computer " & strServer & " in " & intTimer & " seconds..."
- wscript.sleep (intTimer * 1000)
- End if
- 'Open a text file for output if the file is requested
- If Not IsEmpty(strOutputFile) Then
- If (NOT blnOpenFile(strOutputFile, objOutputFile)) Then
- Call Wscript.Echo ("Could not open an output file.")
- Exit Sub
- End If
- End If
- 'Establish a connection with the server.
- If blnConnect("root\cimv2" , _
- strUserName , _
- strPassword , _
- strServer , _
- objService ) Then
- Call Wscript.Echo("")
- Call Wscript.Echo("Please check the server name, " _
- & "credentials and WBEM Core.")
- Exit Sub
- End If
- strID(0) = ""
- strName(0) = ""
- strMessage = ""
- strQuery = "Select * From Win32_OperatingSystem"
- Set objEnumerator = objService.ExecQuery(strQuery,,0)
- If Err.Number Then
- Print "Error 0x" & CStr(Hex(Err.Number)) & " occurred during the query."
- If Err.Description <> "" Then
- Print "Error description: " & Err.Description & "."
- End If
- Err.Clear
- Exit Sub
- End If
- i = 0
- For Each objInstance in objEnumerator
- If blnForce Then
- intStatus = objInstance.Win32ShutDown(CONST_FORCE_SHUTDOWN)
- Else
- intStatus = objInstance.Win32ShutDown(CONST_SHUTDOWN)
- End If
- IF intStatus = 0 Then
- strMessage = "Shuts down machine " & strServer & "."
- Else
- strMessage = "Failed to shutdown machine " & strServer & "."
- End If
- Call WriteLine(strMessage,objOutputFile)
- Next
- If IsObject(objOutputFile) Then
- objOutputFile.Close
- Call Wscript.Echo ("Results are saved in file " & strOutputFile & ".")
- End If
- End Sub
- '********************************************************************
- '*
- '* Function intParseCmdLine()
- '*
- '* Purpose: Parses the command line.
- '* Input:
- '*
- '* Output: strServer a remote server ("" = local server")
- '* strUserName the current user's name
- '* strPassword the current user's password
- '* strOutputFile an output file name
- '* intTimer amount of time in seconds
- '*
- '********************************************************************
- Private Function intParseCmdLine( ByRef strServer, _
- ByRef strUserName, _
- ByRef strPassword, _
- ByRef strOutputFile, _
- ByRef blnLogoff, _
- ByRef blnShutdown, _
- ByRef blnReboot, _
- ByRef blnPowerOff, _
- ByRef blnForce, _
- ByRef intTimer )
- ON ERROR RESUME NEXT
- Dim strFlag
- Dim intState, intArgIter
- Dim objFileSystem
- If Wscript.Arguments.Count > 0 Then
- strFlag = Wscript.arguments.Item(0)
- End If
- If IsEmpty(strFlag) Then 'No arguments have been received
- Wscript.Echo("Arguments are Required.")
- intParseCmdLine = CONST_ERROR
- Exit Function
- End If
- 'Check if the user is asking for help or is just confused
- If (strFlag="help") OR (strFlag="/h") OR (strFlag="\h") OR (strFlag="-h") _
- OR (strFlag = "\?") OR (strFlag = "/?") OR (strFlag = "?") _
- OR (strFlag="h") Then
- intParseCmdLine = CONST_SHOW_USAGE
- Exit Function
- End If
- 'Retrieve the command line and set appropriate variables
- intArgIter = 0
- Do While intArgIter <= Wscript.arguments.Count - 1
- Select Case Left(LCase(Wscript.arguments.Item(intArgIter)),2)
- Case "/s"
- intParseCmdLine = CONST_PROCEED
- If Not blnGetArg("Server", strServer, intArgIter) Then
- intParseCmdLine = CONST_ERROR
- Exit Function
- End If
- intArgIter = intArgIter + 1
- Case "/o"
- If Not blnGetArg("Output File", strOutputFile, intArgIter) Then
- intParseCmdLine = CONST_ERROR
- Exit Function
- End If
- intArgIter = intArgIter + 1
- Case "/u"
- If Not blnGetArg("User Name", strUserName, intArgIter) Then
- intParseCmdLine = CONST_ERROR
- Exit Function
- End If
- intArgIter = intArgIter + 1
- Case "/w"
- If Not blnGetArg("User Password", strPassword, intArgIter) Then
- intParseCmdLine = CONST_ERROR
- Exit Function
- End If
- intArgIter = intArgIter + 1
- Case "/f"
- blnForce = True
- intArgIter = intArgIter + 1
- Case "/r"
- blnReBoot = True
- userarray(0) = blnReBoot
- intArgIter = intArgIter + 1
- Case "/q"
- blnPowerOff = True
- userarray(1) = blnPowerOff
- intArgIter = intArgIter + 1
- Case "/l"
- blnLogOff = True
- userarray(2) = blnLogoff
- intArgIter = intArgIter + 1
- Case "/p"
- blnShutDown = True
- userarray(3) = blnShutDown
- intArgIter = intArgIter + 1
- Case "/t"
- If Not blnGetArg("Timer", intTimer, intArgIter) Then
- intParseCmdLine = CONST_ERROR
- Exit Function
- End If
- intArgIter = intArgIter + 1
- Case Else 'We shouldn't get here
- Call Wscript.Echo("Invalid or misplaced parameter: " _
- & Wscript.arguments.Item(intArgIter) & vbCRLF _
- & "Please check the input and try again," & vbCRLF _
- & "or invoke with '/?' for help with the syntax.")
- Wscript.Quit
- End Select
- Loop '** intArgIter <= Wscript.arguments.Count - 1
- MyCount = 0
- for i = 0 to 3
- if userarray(i) = True then
- MyCount = Mycount + 1
- End if
- Next
- if Mycount > 1 then
- intParseCmdLine = CONST_SHOW_USAGE
- End if
- If IsEmpty(intParseCmdLine) Then
- intParseCmdLine = CONST_ERROR
- Wscript.Echo("Arguments are Required.")
- End If
- End Function
- '********************************************************************
- '*
- '* Sub ShowUsage()
- '*
- '* Purpose: Shows the correct usage to the user.
- '*
- '* Input: None
- '*
- '* Output: Help messages are displayed on screen.
- '*
- '********************************************************************
- Private Sub ShowUsage()
- Wscript.Echo ""
- Wscript.Echo "Logoffs, Reboots, Powers Off, or Shuts Down a machine."
- Wscript.Echo ""
- Wscript.Echo "SYNTAX:"
- Wscript.Echo " Restart.vbs [/S <server>] [/U <username>] [/W <password>]"
- Wscript.Echo " [/O <outputfile>] </L> </R> </P> </Q> </F> [/T <time in seconds>]"
- Wscript.Echo ""
- Wscript.Echo "PARAMETER SPECIFIERS:"
- wscript.echo " /T Amount of time to perform the function."
- Wscript.Echo " /Q Perform Shutdown."
- Wscript.Echo " /P Perform Poweroff."
- Wscript.Echo " /R Perform Reboot."
- Wscript.Echo " /L Perform Logoff."
- Wscript.Echo " /F Force Function."
- Wscript.Echo " server A machine name."
- Wscript.Echo " username The current user's name."
- Wscript.Echo " password Password of the current user."
- Wscript.Echo " outputfile The output file name."
- Wscript.Echo ""
- Wscript.Echo "EXAMPLE:"
- Wscript.Echo "1. cscript Restart.vbs /S MyMachine2 /R"
- Wscript.Echo " Reboots the current machine MyMachine2."
- Wscript.Echo "2. cscript Restart.vbs /S MyMachine2 /R /F"
- Wscript.Echo " Forces MyMachine2 to reboot."
- Wscript.Echo "3. cscript Restart.vbs /S MyMachine2 /R /T 30"
- Wscript.Echo " Reboots the current machine MyMachine2 in 30 seconds."
- Wscript.Echo "NOTE:"
- Wscript.Echo " The force option will make the machine perform the function even " _
- & "if there are"
- Wscript.Echo " open and unsaved docuements on the screen."
- End Sub
- '********************************************************************
- '* General Routines
- '********************************************************************
- '********************************************************************
- '*
- '* Function strPackString()
- '*
- '* Purpose: Attaches spaces to a string to increase the length to intWidth.
- '*
- '* Input: strString a string
- '* intWidth the intended length of the string
- '* blnAfter Should spaces be added after the string?
- '* blnTruncate specifies whether to truncate the string or not if
- '* the string length is longer than intWidth
- '*
- '* Output: strPackString is returned as the packed string.
- '*
- '********************************************************************
- Private Function strPackString( ByVal strString, _
- ByVal intWidth, _
- ByVal blnAfter, _
- ByVal blnTruncate)
- ON ERROR RESUME NEXT
- intWidth = CInt(intWidth)
- blnAfter = CBool(blnAfter)
- blnTruncate = CBool(blnTruncate)
- If Err.Number Then
- Call Wscript.Echo ("Argument type is incorrect!")
- Err.Clear
- Wscript.Quit
- End If
- If IsNull(strString) Then
- strPackString = "null" & Space(intWidth-4)
- Exit Function
- End If
- strString = CStr(strString)
- If Err.Number Then
- Call Wscript.Echo ("Argument type is incorrect!")
- Err.Clear
- Wscript.Quit
- End If
- If intWidth > Len(strString) Then
- If blnAfter Then
- strPackString = strString & Space(intWidth-Len(strString))
- Else
- strPackString = Space(intWidth-Len(strString)) & strString & " "
- End If
- Else
- If blnTruncate Then
- strPackString = Left(strString, intWidth-1) & " "
- Else
- strPackString = strString & " "
- End If
- End If
- End Function
- '********************************************************************
- '*
- '* Function blnGetArg()
- '*
- '* Purpose: Helper to intParseCmdLine()
- '*
- '* Usage:
- '*
- '* Case "/s"
- '* blnGetArg ("server name", strServer, intArgIter)
- '*
- '********************************************************************
- Private Function blnGetArg ( ByVal StrVarName, _
- ByRef strVar, _
- ByRef intArgIter)
- blnGetArg = False 'failure, changed to True upon successful completion
- If Len(Wscript.Arguments(intArgIter)) > 2 then
- If Mid(Wscript.Arguments(intArgIter),3,1) = ":" then
- If Len(Wscript.Arguments(intArgIter)) > 3 then
- strVar = Right(Wscript.Arguments(intArgIter), _
- Len(Wscript.Arguments(intArgIter)) - 3)
- blnGetArg = True
- Exit Function
- Else
- intArgIter = intArgIter + 1
- If intArgIter > (Wscript.Arguments.Count - 1) Then
- Call Wscript.Echo( "Invalid " & StrVarName & ".")
- Call Wscript.Echo( "Please check the input and try again.")
- Exit Function
- End If
- strVar = Wscript.Arguments.Item(intArgIter)
- If Err.Number Then
- Call Wscript.Echo( "Invalid " & StrVarName & ".")
- Call Wscript.Echo( "Please check the input and try again.")
- Exit Function
- End If
- If InStr(strVar, "/") Then
- Call Wscript.Echo( "Invalid " & StrVarName)
- Call Wscript.Echo( "Please check the input and try again.")
- Exit Function
- End If
- blnGetArg = True 'success
- End If
- Else
- strVar = Right(Wscript.Arguments(intArgIter), _
- Len(Wscript.Arguments(intArgIter)) - 2)
- blnGetArg = True 'success
- Exit Function
- End If
- Else
- intArgIter = intArgIter + 1
- If intArgIter > (Wscript.Arguments.Count - 1) Then
- Call Wscript.Echo( "Invalid " & StrVarName & ".")
- Call Wscript.Echo( "Please check the input and try again.")
- Exit Function
- End If
- strVar = Wscript.Arguments.Item(intArgIter)
- If Err.Number Then
- Call Wscript.Echo( "Invalid " & StrVarName & ".")
- Call Wscript.Echo( "Please check the input and try again.")
- Exit Function
- End If
- If InStr(strVar, "/") Then
- Call Wscript.Echo( "Invalid " & StrVarName)
- Call Wscript.Echo( "Please check the input and try again.")
- Exit Function
- End If
- blnGetArg = True 'success
- End If
- End Function
- '********************************************************************
- '*
- '* Function blnConnect()
- '*
- '* Purpose: Connects to machine strServer.
- '*
- '* Input: strServer a machine name
- '* strNameSpace a namespace
- '* strUserName name of the current user
- '* strPassword password of the current user
- '*
- '* Output: objService is returned as a service object.
- '* strServer is set to local host if left unspecified
- '*
- '********************************************************************
- Private Function blnConnect(ByVal strNameSpace, _
- ByVal strUserName, _
- ByVal strPassword, _
- ByRef strServer, _
- ByRef objService)
- ON ERROR RESUME NEXT
- Dim objLocator, objWshNet
- blnConnect = False 'There is no error.
- 'Create Locator object to connect to remote CIM object manager
- Set objLocator = CreateObject("WbemScripting.SWbemLocator")
- If Err.Number then
- Call Wscript.Echo( "Error 0x" & CStr(Hex(Err.Number)) & _
- " occurred in creating a locator object." )
- If Err.Description <> "" Then
- Call Wscript.Echo( "Error description: " & Err.Description & "." )
- End If
- Err.Clear
- blnConnect = True 'An error occurred
- Exit Function
- End If
- 'following two lines added by Ravi
- objLocator.Security_.Privileges.Add 18, True 'wbemPrivilegeShutdown
- objLocator.Security_.Privileges.Add 23, True 'wbemPrivilegeRemoteShutdown
- 'Connect to the namespace which is either local or remote
- Set objService = objLocator.ConnectServer (strServer, strNameSpace, _
- strUserName, strPassword)
- ObjService.Security_.impersonationlevel = 3
- If Err.Number then
- Call Wscript.Echo( "Error 0x" & CStr(Hex(Err.Number)) & _
- " occurred in connecting to server " _
- & strServer & ".")
- If Err.Description <> "" Then
- Call Wscript.Echo( "Error description: " & Err.Description & "." )
- End If
- Err.Clear
- blnConnect = True 'An error occurred
- End If
- 'Get the current server's name if left unspecified
- If IsEmpty(strServer) Then
- Set objWshNet = CreateObject("Wscript.Network")
- strServer = objWshNet.ComputerName
- End If
- End Function
- '********************************************************************
- '*
- '* Sub VerifyHostIsCscript()
- '*
- '* Purpose: Determines which program is used to run this script.
- '*
- '* Input: None
- '*
- '* Output: If host is not cscript, then an error message is printed
- '* and the script is aborted.
- '*
- '********************************************************************
- Sub VerifyHostIsCscript()
- ON ERROR RESUME NEXT
- Dim strFullName, strCommand, i, j, intStatus
- strFullName = WScript.FullName
- If Err.Number then
- Call Wscript.Echo( "Error 0x" & CStr(Hex(Err.Number)) & " occurred." )
- If Err.Description <> "" Then
- Call Wscript.Echo( "Error description: " & Err.Description & "." )
- End If
- intStatus = CONST_ERROR
- End If
- i = InStr(1, strFullName, ".exe", 1)
- If i = 0 Then
- intStatus = CONST_ERROR
- Else
- j = InStrRev(strFullName, "\", i, 1)
- If j = 0 Then
- intStatus = CONST_ERROR
- Else
- strCommand = Mid(strFullName, j+1, i-j-1)
- Select Case LCase(strCommand)
- Case "cscript"
- intStatus = CONST_CSCRIPT
- Case "wscript"
- intStatus = CONST_WSCRIPT
- Case Else 'should never happen
- Call Wscript.Echo( "An unexpected program was used to " _
- & "run this script." )
- Call Wscript.Echo( "Only CScript.Exe or WScript.Exe can " _
- & "be used to run this script." )
- intStatus = CONST_ERROR
- End Select
- End If
- End If
- If intStatus <> CONST_CSCRIPT Then
- Call WScript.Echo( "Please run this script using CScript." & vbCRLF & _
- "This can be achieved by" & vbCRLF & _
- "1. Using ""CScript Restart.vbs arguments"" for Windows 95/98 or" _
- & vbCRLF & "2. Changing the default Windows Scripting Host " _
- & "setting to CScript" & vbCRLF & " using ""CScript " _
- & "//F:CScript //S"" and running the script using" & vbCRLF & _
- " ""Restart.vbs arguments"" for Windows NT/2000." )
- WScript.Quit
- End If
- End Sub
- '********************************************************************
- '*
- '* Sub WriteLine()
- '* Purpose: Writes a text line either to a file or on screen.
- '* Input: strMessage the string to print
- '* objFile an output file object
- '* Output: strMessage is either displayed on screen or written to a file.
- '*
- '********************************************************************
- Sub WriteLine(ByVal strMessage, ByVal objFile)
- On Error Resume Next
- If IsObject(objFile) then 'objFile should be a file object
- objFile.WriteLine strMessage
- Else
- Call Wscript.Echo( strMessage )
- End If
- End Sub
- '********************************************************************
- '*
- '* Function blnErrorOccurred()
- '*
- '* Purpose: Reports error with a string saying what the error occurred in.
- '*
- '* Input: strIn string saying what the error occurred in.
- '*
- '* Output: displayed on screen
- '*
- '********************************************************************
- Private Function blnErrorOccurred (ByVal strIn)
- If Err.Number Then
- Call Wscript.Echo( "Error 0x" & CStr(Hex(Err.Number)) & ": " & strIn)
- If Err.Description <> "" Then
- Call Wscript.Echo( "Error description: " & Err.Description)
- End If
- Err.Clear
- blnErrorOccurred = True
- Else
- blnErrorOccurred = False
- End If
- End Function
- '********************************************************************
- '*
- '* Function blnOpenFile
- '*
- '* Purpose: Opens a file.
- '*
- '* Input: strFileName A string with the name of the file.
- '*
- '* Output: Sets objOpenFile to a FileSystemObject and setis it to
- '* Nothing upon Failure.
- '*
- '********************************************************************
- Private Function blnOpenFile(ByVal strFileName, ByRef objOpenFile)
- ON ERROR RESUME NEXT
- Dim objFileSystem
- Set objFileSystem = Nothing
- If IsEmpty(strFileName) OR strFileName = "" Then
- blnOpenFile = False
- Set objOpenFile = Nothing
- Exit Function
- End If
- 'Create a file object
- Set objFileSystem = CreateObject("Scripting.FileSystemObject")
- If blnErrorOccurred("Could not create filesystem object.") Then
- blnOpenFile = False
- Set objOpenFile = Nothing
- Exit Function
- End If
- 'Open the file for output
- Set objOpenFile = objFileSystem.OpenTextFile(strFileName, 8, True)
- If blnErrorOccurred("Could not open") Then
- blnOpenFile = False
- Set objOpenFile = Nothing
- Exit Function
- End If
- blnOpenFile = True
- End Function
- '********************************************************************
- '* *
- '* End of File *
- '* *
- '********************************************************************
SID:S-1-0
名称:Null Authority
描述:标识符颁发机构。
SID:S-1-0-0
名称:Nobody
描述:无安全主体。
SID:S-1-1
名称:World Authority
描述:标识符颁发机构。
SID:S-1-1-0
名称:Everyone
描述:包括所有用户(甚至匿名用户和来宾)的组。成员身份由操作系统控制。
SID:S-1-2
名称:Local Authority
描述:标识符颁发机构。
SID:S-1-3
名称:Creator Authority
描述:标识符颁发机构。
SID:S-1-3-0
名称:Creator Owner
描述:可继承访问控制项 (ACE) 中的占位符。当 ACE 被继承时,系统用对象创建者的 SID 替换此 SID。
SID:S-1-3-1
名称:Creator Group
描述:可继承 ACE 中的占位符。当 ACE 被继承时,系统用对象创建者的主要组 SID 替换此 SID。主要组仅供 POSIX 子系统使用。
SID:S-1-3-2
名称:Creator Owner Server
描述:Windows 2000 中不使用此 SID。
SID:S-1-3-3
名称:Creator Group Server
描述:Windows 2000 中不使用此 SID。
SID:S-1-4
名称:Non-unique Authority
描述:标识符颁发机构。
SID:S-1-5
名称:NT Authority
描述:标识符颁发机构。
SID:S-1-5-1
名称:Dialup
描述:一个包括所有通过拨号连接登录的用户的组。成员身份由操作系统控制。
SID:S-1-5-2
名称:Network
描述:一个包括所有通过网络连接登录的用户的组。成员身份由操作系统控制。
SID:S-1-5-3
名称:Batch
描述:一个包括所有通过批队列工具登录的用户的组。成员身份由操作系统控制。
SID:S-1-5-4
名称:Interactive
描述:一个包括所有以交互方式登录的用户的组。成员身份由操作系统控制。
SID:S-1-5-5-X-Y
名称:Logon Session
描述:登录会话。这些 SID 的 X 和 Y 值因会话而异。
SID:S-1-5-6
名称:Service
描述:一个包括所有作为服务登录的安全主体的组。成员身份由操作系统控制。
SID:S-1-5-7
名称:Anonymous
描述:一个包括所有以匿名方式登录的用户的组。成员身份由操作系统控制。
SID:S-1-5-8
名称:Proxy
描述:Windows 2000 中不使用此 SID。
SID:S-1-5-9
名称:Enterprise Controllers
描述:一个由使用 Active Directory 目录服务的林中的所有域控制器组成的组。成员身份由操作系统控制。
SID:S-1-5-10
名称:Principal Self
描述:Active Directory 中的帐户对象或组对象上可继承 ACE 中的一个占位符。当 ACE 被继承时,系统用持有此帐户的安全主体的 SID 替换此 SID。
SID:S-1-5-11
名称:Authenticated Users
描述:一个包括登录时已经过身份验证的用户的组。成员身份由操作系统控制。
SID:S-1-5-12
名称:Restricted Code
描述:此 SID 保留供以后使用。
SID:S-1-5-13
名称:Terminal Server Users
描述:一个包括所有登录到终端服务服务器的用户的组。成员身份由操作系统控制。
SID:S-1-5-18
名称:Local System
描述:操作系统使用的服务帐户。
SID:S-1-5-19
名称:NT Authority
描述:本地服务
SID:S-1-5-20
名称:NT Authority
描述:网络服务
SID:S-1-5-域-500
名称:Administrator
描述:系统管理员的用户帐户。默认情况下,它是唯一能够完全控制系统的用户帐户。
SID:S-1-5-域-501
名称:Guest
描述:无个人帐户的人员的用户帐户。此用户帐户不需要密码。默认情况下,Guest 帐户被禁用。
SID:S-1-5-域-502
名称:KRBTGT
描述:密钥分发中心 (KDC) 服务使用的服务帐户。
SID:S-1-5-域-512
名称:Domain Admins
描述:一个全局组,其成员被授权管理该域。默认情况下,Domain Admins 组属于所有加入域的计算机(包括域控制器)上的 Administrators 组。Domain Admins 是该组的任何成员创建的任何对象的默认所有者。
SID:S-1-5-域-513
名称:Domain Users
描述:一个全局组,默认情况下它包括域中的所有用户帐户。在域中创建用户帐户时,默认情况下,帐户将添加到该组中。
SID:S-1-5-域-514
名称:Domain Guests
描述:一个全局组,默认情况下它只有一个成员,即域的内置 Guest 帐户。
SID:S-1-5-域-515
名称:Domain Computers
描述:一个包括加入域的所有客户端和服务器的全局组。
SID:S-1-5-域-516
名称:Domain Controllers
描述:一个包括域中所有域控制器的全局组。默认情况下,新的域控制器将添加到该组中。
SID:S-1-5-域-517
名称:Cert Publishers
描述:一个包括所有运行企业证书颁发机构的计算机的全局组。Cert Publishers 被授权为 Active Directory 中的 User 对象发布证书。
SID:S-1-5-根域-518
名称:Schema Admins
描述:纯模式域中的通用组;混合模式域中的全局组。该组被授权在 Active Directory 中更改架构。默认情况下,该组的唯一成员是目录林根域的 Administrator 帐户。
SID:S-1-5-根域-519
名称:Enterprise Admins
描述:纯模式域中的通用组;混合模式域中的全局组。该组被授权在 Active Directory 中进行目录林范围的更改,例如添加子域。默认情况下,该组的唯一成员是目录林根域的 Administrator 帐户。
SID:S-1-5-域-520
名称:Group Policy Creator Owners
描述:一个被授权在 Active Directory 中新建组策略对象的全局组。默认情况下,该组的唯一成员是 Administrator。
SID:S-1-5-域-533
名称:RAS and IAS Servers
描述:域本地组。默认情况下,该组没有成员。该组中的服务器对 Active Directory 域本地组中的 User 对象具有“读取帐户限制”和“读取登录信息”访问权限。默认情况下,该组没有成员。该组中的服务器对 Active Directory 中的 User 对象具有“读取帐户限制”和“读取登录信息”访问权限。
SID:S-1-5-32-544
名称:Administrators
描述:内置组。初次安装操作系统后,该组的唯一成员是 Administrator 帐户。当计算机加入域时,Domain Admins 组将被添加到 Administrators 组中。当服务器成为域控制器时,Enterprise Admins 组也被添加到 Administrators 组中。
SID:S-1-5-32-545
名称:Users
描述:内置组。初次安装操作系统后,该组的唯一成员是 Authenticated Users 组。当计算机加入域时,Domain Users 组将被添加到计算机上的 Users 组中。
SID:S-1-5-32-546
名称:Guests
描述:内置组。默认情况下,该组的唯一成员是 Guest 帐户。Guests 组允许临时或一次性用户使用有限权限登录到计算机的内置 Guest 帐户。
SID:S-1-5-32-547
名称:Power Users
描述:内置组。默认情况下,该组没有成员。Power Users 可以创建本地用户和组,修改和删除以前创建的帐户,删除 Power Users、Users 和 Guests 组中的用户。Power Users 还可以安装程序,创建、管理和删除本地打印机以及创建和删除文件共享目录。
SID:S-1-5-32-548
名称:Account Operators
描述:一种只存在于域控制器上的内置组。默认情况下,该组没有成员。默认情况下,Account Operators 有权为 Active Directory 的所有容器和组织单位中的用户、组和计算机创建、修改和删除帐户,Builtin 容器和 Domain Controllers OU 除外。Account Operators 无权修改 Administrators 和 Domain Admins 组,也无权为那些组的成员修改帐户。
SID:S-1-5-32-549
名称:Server Operators
描述:一种只存在于域控制器上的内置组。默认情况下,该组没有成员。Server Operators 可以以交互方式登录到服务器,创建和删除网络共享目录,启动和停止服务,备份和还原文件,格式化计算机的硬盘以及关闭计算机。computer.
SID:S-1-5-32-550
名称:Print Operators
描述:一种只存在于域控制器上的内置组。默认情况下,该组的唯一成员是 Domain Users 组。Print Operators 可以管理打印机和文档队列。
SID:S-1-5-32-551
名称:Backup Operators
描述:内置组。默认情况下,该组没有成员。Backup Operators 可以备份和还原计算机上的所有文件,无论那些文件受哪些权限保护均如此。Backup Operators 也可以登录和关闭计算机。
SID:S-1-5-32-552
名称:Replicators
描述:一个由域控制器上的文件复制服务使用的内置组。默认情况下,该组没有成员。不要向该组中添加用户。
下列各组在某台 Windows Server 2003 域控制器被指定担任主域控制器 (PDC) 操作主机角色之前,将一直显示为 SID。(“操作主机”也称作灵活的单主机操作或 FSMO。)在将 Windows Server 2003 域控制器添加到域中时,新建的其他内置组有:
SID:S-1-5-32-554
名称:BUILTIN\Pre-Windows 2000 Compatible Access
描述:Windows 2000 添加的别名。一个允许对域中的所有用户和组进行读访问的向后兼容组。
SID:S-1-5-32-555
名称:BUILTIN\Remote Desktop Users
描述:一个别名。该组的成员被授予远程登录权限。
SID:S-1-5-32-556
名称:BUILTIN\Network Configuration Operators
描述:一个别名。该组的成员拥有管理网络功能配置的部分权限。
SID:S-1-5-32-557
名称:BUILTIN\Incoming Forest Trust Builders
描述:一个别名。该组的成员可以创建到该目录林的传入的单向信任。
SID:S-1-5-32-557
名称:BUILTIN\Incoming Forest Trust Builders
描述:一个别名。该组的成员可以创建到该目录林的传入的单向信任。
SID:S-1-5-32-558
名称:BUILTIN\Performance Monitor Users
描述:一个别名。该组的成员可以进行远程访问以监视此计算机。
SID:S-1-5-32-559
名称:BUILTIN\Performance Log Users
描述:一个别名。该组的成员可以进行远程访问,以便计划此计算机上性能计数器的日志。
SID:S-1-5-32-560
名称:BUILTIN\Windows Authorization Access Group
描述:一个别名。该组的成员可以访问 User 对象上的计算的 tokenGroupsGlobalAndUniversal 属性。
SID:S-1-5-32-561
名称:BUILTIN\Terminal Server License Servers
描述:一个别名。终端服务器许可证服务器组。
一、安全为首 加固系统防护
操作系统的安全性无疑受大家关注最多,虽然Windows 2003稳定的性能受到越来越多用户的青睐,但面对层出不穷的新病毒,加强安全性依旧是当务之急。通常,我们只需要某些细微的改动就能使系统安全提升一个台阶,大家看看下面几点您做到了么?
本日志由 flyinweb 于 2009-06-17 23:02:28 发表到 Windows 中,目前已经被浏览 187 次,评论 0 次;
作者添加了以下标签: windows 2003,安全;
首页只显示了部分日志内容,要查看日志的全部内容请阅读全文;
Windows 2000 下的修改办法
win2k的终端服务可以运行在两种方式下:远程管理或应用程序服务器模式。
远程管理模式:允许一定数量的管理员远程管理这个服务器,这个模式对服务器性能的影响程度最低。
应用程序服务器模式:允许远程用户运行一定数量的应用程序,这个模式优化应用程序响应时间。还记得以前的瘦客户机吧?现在你可以用一台486计算机安装一个win95,用这种模式连上2000服务器,运行以前你无法运行的3DMAX、AutoCAD2000……。
终端服务默认端口号:3389。
更改原因:不想让非法用户连接到服务器进行登录实验。当这台服务器托管在外时更不希望发生这种情况,呵呵,还没忘记2000的输入法漏洞吧?
更改方法:
一、服务器端:
1、第一处
运行regedit,找到[HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Control \ Terminal Server \ Wds \ rdpwd \ Tds \ tcp],看到右边的PortNumber了吗?在十进制状态下改成你想要的端口号吧,比如7126之类的,只要不与其它冲突即可。
2、第二处HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Control \ Terminal Server \ WinStations \ RDP-Tcp,方法同上,记得改的端口号和上面改的一样就行了。
二、客户端:
打开客户端管理连接器,单击已经建好的某个连接,单击“文件(file)”→“导出(Export)”……
用记录本或其它文本编辑软件找开刚导出的这个.cns文件,找到“Server Port =3389”这一行了吗?
把这个默认的3389改成与服务器一样的端口号就行了。
Windows XP/2003 下的修改办法
使用XP或2003的客户端,它可以显示多彩,还可以有声音,功能更强大。但终端客户端连接端口的修改方法与WIN2000有一定区别:
按照原来更改2000的客户端的思路,把XP、2003的默认配置另存(在连接界面上单击“另存为”),和2000不一样的是:XP、2003的配置文件后缀是.rdp,WIN2000的是.cns
用记事本打开这个地default.rdp文件,在里面没有发现什么3389的东东(2000的配置文件是有的),没有这句端口的配置我们就给它加上,假定现在的端口为8933,如下:
server port:i:8933
保存,退出即可。
To: jconsole不能打开,大概两种可能: 1 没有启用独占模式,如O
两个实例分别放在不同的 datadir 里面,会方便很多
今天遇到了“Cleanup failed to process the following paths:-
谢谢分享.有帮助.
根据inotify + rsync的思路,现在有了个c++版本的同步程序,只需指
真是有耐心呀。我做了个pdf 文件 在上面的网站可以下载