윈도우 이벤트 로그 분석-Visual Basic Script(vbs)
사용 예제
eventquery.vbs
1. cmdlib.wsc 등록
cmdlib.wsc는 Windows 용 WSC 파일로 Microsoft가 개발했으며 Windows Script Component 파일입니다.
F:\script\vbs>regsvr32 cmdlib.wsc /s
2. 도움말
F:\script\vbs>cscript eventquery.vbs /?
Microsoft (R) Windows Script Host 버전 5.812
Copyright (C) Microsoft Corporation. All rights reserved.
EVENTQUERY.vbs [/S system [/U username [/P password]]] [/FI filter]
[/FO format] [/R range] [/NH] [/V] [/L logname | *]
Description:
The EVENTQUERY.vbs script enables an administrator to list
the events and event properties from one or more event logs.
Parameter List:
/S system Specifies the remote system to connect to.
/U [domain\]user Specifies the user context under which the command should execute.
/P password Specifies the password for the given user context.
/V Specifies that the detailed information should be displayed in the output.
/FI filter Specifies the types of events to filter in or out of the query.
/FO format Specifies the format in which the output is to be displayed.
Valid formats are "TABLE", "LIST", "CSV".
/R range Specifies the range of events to list. Valid Values are:
'N' - Lists 'N' most recent events.
'-N' - Lists 'N' oldest events.
'N1-N2' - Lists the events N1 to N2.
/NH Specifies that the "Column Header" should not be displayed in the output.
Valid only for "TABLE" and "CSV" formats.
/L logname Specifies the log(s) to query.
/? Displays this help/usage.
Valid Filters Operators allowed Valid Values
------------- ------------------ ------------
DATETIME eq,ne,ge,le,gt,lt mm/dd/yy(yyyy),hh:mm:ssAM(/PM)
TYPE eq,ne ERROR, INFORMATION, WARNING, SUCCESSAUDIT, FAILUREAUDIT
ID eq,ne,ge,le,gt,lt non-negative integer
USER eq,ne string
COMPUTER eq,ne string
SOURCE eq,ne string
CATEGORY eq,ne string
NOTE: Filter "DATETIME" can be specified as "FromDate-ToDate" Only "eq" operator can be used for this format.
Examples:
EVENTQUERY.vbs
EVENTQUERY.vbs /L system
EVENTQUERY.vbs /S system /U user /P password /V /L *
EVENTQUERY.vbs /R 10 /L Application /NH
EVENTQUERY.vbs /R -10 /FO LIST /L Security
EVENTQUERY.vbs /R 5-10 /L "DNS Server"
EVENTQUERY.vbs /FI "Type eq Error" /L Application
EVENTQUERY.vbs /L Application
/FI "Datetime eq 06/25/00,03:15:00AM-06/25/00,03:15:00PM"
EVENTQUERY.vbs /FI "Datetime gt 08/03/00,06:20:00PM"
/FI "Id gt 700" /FI "Type eq warning" /L System
EVENTQUERY.vbs /FI "Type eq error OR Id gt 1000 "
3. 조회
F:\script\vbs>cscript //nologo eventquery.vbs /L security | more
------------------------------------------------------------------------------
Listing the events in 'security' log of host 'CHOHB'
------------------------------------------------------------------------------
Type Event Date Time Source ComputerName
------------- ------ ------------------------ ----------------- --------------
감사 성공 4672 2020-03-03 오전 2:03:57 Microsoft-Windows chohb
감사 성공 4624 2020-03-03 오전 2:03:57 Microsoft-Windows chohb
감사 성공 4672 2020-03-03 오전 1:57:02 Microsoft-Windows chohb
......
리스트 형태 조회
F:\script\vbs>cscript //nologo eventquery.vbs /L Security /FO list
------------------------------------------------------------------------------
Listing the events in 'security' log of host 'CHOHB'
------------------------------------------------------------------------------
Type: 감사 성공
Event: 4672
Date Time: 2020-03-03 오전 2:03:57
Source: Microsoft-Windows-Security-Auditing
ComputerName: chohb
Type: 감사 성공
Event: 4624
Date Time: 2020-03-03 오전 2:03:57
Source: Microsoft-Windows-Security-Auditing
ComputerName: chohb
......
특정 이벤트ID 조회
F:\script\vbs>cscript //nologo eventquery.vbs /L Security /FO list /Fi "id eq 4624"
이벤트 상세 내역 조회 : /V
F:\script\vbs>cscript eventquery.vbs /L Security /Fi "id eq 4624" /FO list /V
General VBS
On Error Resume Next
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
Set wshNetwork = WScript.CreateObject("WScript.Network")
strComputer = wshNetwork.ComputerName
'strQuery = "SELECT * FROM Win32_NTLogEvent where logfile='Security' and EventCode='489'"
strQuery = "SELECT * FROM Win32_NTLogEvent where logfile='Security'"
WScript.StdOut.WriteLine ""
WScript.StdOut.WriteLine "====================================="
WScript.StdOut.WriteLine "COMPUTER : " & strComputer
WScript.StdOut.WriteLine "CLASS : ROOT\CIMV2:Win32_NTLogEvent"
WScript.StdOut.WriteLine "QUERY : " & strQuery
WScript.StdOut.WriteLine "====================================="
WScript.StdOut.WriteLine ""
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\ROOT\CIMV2")
Set colItems = objWMIService.ExecQuery(strQuery, "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem in colItems
WScript.StdOut.WriteLine "Category: " & objItem.Category
WScript.StdOut.WriteLine "CategoryString: " & objItem.CategoryString
WScript.StdOut.WriteLine "ComputerName: " & objItem.ComputerName
strData = Join(objItem.Data, ",")
WScript.StdOut.WriteLine "Data: " & strData
WScript.StdOut.WriteLine "EventCode: " & objItem.EventCode
WScript.StdOut.WriteLine "EventIdentifier: " & objItem.EventIdentifier
WScript.StdOut.WriteLine "EventType: " & objItem.EventType
strInsertionStrings = Join(objItem.InsertionStrings, ",")
WScript.StdOut.WriteLine "InsertionStrings: " & strInsertionStrings
WScript.StdOut.WriteLine "Logfile: " & objItem.Logfile
WScript.StdOut.WriteLine "Message: " & objItem.Message
WScript.StdOut.WriteLine "RecordNumber: " & objItem.RecordNumber
WScript.StdOut.WriteLine "SourceName: " & objItem.SourceName
WScript.StdOut.WriteLine "TimeGenerated: " & objItem.TimeGenerated
WScript.StdOut.WriteLine "TimeWritten: " & objItem.TimeWritten
WScript.StdOut.WriteLine "Type: " & objItem.Type
WScript.StdOut.WriteLine "User: " & objItem.User
WScript.StdOut.WriteLine ""
Next
'DFIR > 이벤트 로그 분석' 카테고리의 다른 글
윈도우 이벤트 로그 분석-WMI (0) | 2020.03.03 |
---|---|
윈도우 이벤트 로그 분석-파워쉘(PowerShell) (0) | 2020.03.03 |
윈도우 이벤트 로그 분석-이벤트 관리도구(wevtutil) (0) | 2020.03.03 |
윈도우 이벤트 로그 분석-이벤트 뷰어(Eventvwr) (0) | 2020.03.03 |
윈도우 이벤트 로그 (0) | 2020.03.03 |
윈도우 이벤트 로그
1. 윈도우 이벤트 로그란 ?
윈도우 이벤트 로그는 윈도우의 운용과정에서 발생하는 특정 동작(이벤트)을 체계적으로 기록한 바이너리 로깅 시스템이다.
윈도우도 시스템 방화벽, 응용프로그램 관리 등에 관한 로그를 텍스트 형태로 기록하고 있지만, 이벤트 로그에서는 시스템의 전반적인 동작을 보다 종합적이고 체계적으로 기록하므로 디지털 포렌식 조사 시 중요하게 살펴 보아야 할 대상이다.
단, 시스템 운용 로그의 관점에서 볼 때, 이벤트 로그는 사용자의 행위 보다는 시스템의 운용 상태를 알 수 있는 정보가 많다. 따라서 사건 용의자에 관한 부정 조사 보다는 침해사고 대응에 효과적으로 이용되는 것이 현실이기도 하다.
침해사고 조사 시 이벤트 로그를 면밀하게 살펴 본다면, 악성코드가 실행된 원인을 비롯하여 유입 경로(내부 네트워크) 등 다양한 정보를 획득할 수 있을 것이다.
2. 주요 이벤트 IDs
아래는 침해사고 조사 시 주로 확인되는 몇가지 이벤트 ID에 관한 예시이다. 실제 조사 시에는 아래 표의 이벤트 ID에만 의존해서는 안되며, 숙지하고 있는 주요 이벤트 ID에 관해 빠르게 확인한 후 사건과 관련된 키워드 검색 및 관련 시간대에 존재하는 이벤트 로그를 정밀하게 조사하는 것이 바람직하다.
이벤트 ID는 OS 종류 및 버전별로 서로 다를 수 있으며 OS 업데이트시에도 추가, 변경, 삭제 등의 변화가 있을 수 있다.
'DFIR > 이벤트 로그 분석' 카테고리의 다른 글
윈도우 이벤트 로그 분석-WMI (0) | 2020.03.03 |
---|---|
윈도우 이벤트 로그 분석-파워쉘(PowerShell) (0) | 2020.03.03 |
윈도우 이벤트 로그 분석-Visual Basic Script(vbs) (0) | 2020.03.03 |
윈도우 이벤트 로그 분석-이벤트 관리도구(wevtutil) (0) | 2020.03.03 |
윈도우 이벤트 로그 분석-이벤트 뷰어(Eventvwr) (0) | 2020.03.03 |