Windows日志的保护与伪造
作者: 来源: 添加时间:2006-5-23 8:58:26strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate,(Security)}!\\" & _
strComputer & "\root\cimv2") '获得VMI对象
Set colLogFiles = objWMIService.ExecQuery _
("Select * from Win32_NTEventLogFile")
For each objLogfile in colLogFiles
strLogFileName = objLogfile.Name
Set wmiSWbemObject = GetObject _
("winmgmts:{impersonationLevel=Impersonate}!\\.\root\cimv2:" _
& "Win32_NTEventlogFile.Name='" & strLogFileName & "'")
wmiSWbemObject.MaxFileSize = 2500000000
wmiSWbemObject.OverwriteOutdated = 14
wmiSWbemObject.Put_
Next
将上述脚本用记事本存盘为vbs为后缀的即可使用。
另外需要说明的是代码中的strComputer="."在Windows脚本中的含义相当于localhost,如果要在远程主机上执行代码,只需要把"."改动为主机名,当然首先得拥有对方主机的管理员权限并建立IPC连接.本文中的代码所出现的strComputer均可作如此改动。
2. 日志的查询与备份:
一个优秀的管理员是应该养成备份日志的习惯,如果有条件的话还应该把日志转存到备份机器上或直接转储到打印机上,在这里推荐微软的resourceKit工具箱中的dumpel.exe,他的常用方法:
dumpel -f filename -s \\server -l log
-f filename 输出日志的位置和文件名
-s \\server 输出远程计算机日志
-l log log 可选的为system,security,application,可能还有别的如DNS等.
如要把目标服务器server上的系统日志转存为backupsystem.log可以用以下格式:
dumpel \\server -l system -f backupsystem.log
再利用计划任务可以实现定期备份系统日志。
另外利用脚本编程的VMI对象也可以轻而易举的实现日志备份: