-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathvt-windows-event-stream.cpp
63 lines (52 loc) · 1.87 KB
/
vt-windows-event-stream.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Copyright 2022 The vt-windows-event-stream authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <conio.h>
#include <stdio.h>
#include <windows.h>
#include <winevt.h>
#include <vector>
#pragma comment(lib, "wevtapi.lib")
#include "event-stream.h"
void PrintUsage(const wchar_t* name) {
wprintf(L"Usage: %s <LogPath> <output_file_name> [thread]\n", name);
wprintf(L"\nExamples:\n");
wprintf(L" %s Microsoft-Windows-Sysmon/Operational sysmon.xml\n", name);
wprintf(
L" %s Microsoft-Windows-Sysmon/Operational "
L"\\\\VBOXSVR\\tmp\\sysmon.xml\n",
name);
wprintf(L" %s Security \\\\VBOXSVR\\tmp\\security.xml\n", name);
wprintf(
L" %s Microsoft-Windows-Powershell/Operational "
L"\\\\VBOXSVR\\tmp\\ps.xml\n",
name);
}
int __cdecl wmain(int argc, wchar_t* argv[]) {
LPWSTR channel_path = NULL; // example L"Microsoft-Windows-Sysmon/Operational";
LPWSTR output_file_name = NULL;
if (argc < 3) {
PrintUsage(argv[0]);
return 0;
}
channel_path = argv[1];
output_file_name = argv[2];
if (argc == 3) {
wprintf(L"no thread\n");
return StreamEvents(channel_path, output_file_name);
} else {
wprintf(L"Run thread 60sec\n");
StartStreamEventsThread(channel_path, output_file_name);
Sleep(15 * 1000);
StopEventStreamThreads();
}
}