将Sysmon配置为服务并记录日志

发布时间:2021-05-19编辑:佚名阅读(1372)

介绍

Sysmon是微软的一款免费的轻量级系统监控工具。它通过系统服务和驱动程序实现记录进程创建,网络连接以及文件创建时间更改的详细信息,并把相关的信息写入并展示在windows的日志事件里。我们可以通过读取Windows的日志,了解Windows的安全状态。

Sysmon安装后分为用户态系统服务,即ring3层的exe, 驱动(Flt的minifilter)两部分,下面开始上篇的讲解,ring3实现对网络数据记录以及对驱动返回的数据进行解析,而驱动部分则返回进程相关的信息以及进程访问文件注册表的数据给ring3,我们首选讲解ring3的实现原理。用户态通过ETW(Event Tracing for Windows)实现对网络数据记录,通过EventLog对驱动返回的数据进行解析,驱动部分则通过进、线程,模块的回调函数收集进程相关的信息,通过Minifilter文件过滤驱动和注册表回调函数记录访问文件、注册表的数据。

从功能上来讲,Sysmon是一款优秀的HIDS、EDR的主机入侵检测引擎,其依托于Windows内核层进、线程,模块,注册表回调,及文件过滤驱动针对相应的行为进行实时的增、删、改信息收集并通过ETW存储并展示于Windows日志。

安装

下载地址

https://download.sysinternals.com/files/Sysmon.zip
   Install:    Sysmon.exe -i <configfile>
   [-h <[sha1|md5|sha256|imphash|*],...>] [-n [<process,...>]]
   [-l (<process,...>)]

   Configure:  Sysmon.exe -c <configfile>
                 [--|[-h <[sha1|md5|sha256|imphash|*],...>] [-n [<process,...>]]
                  [-l [<process,...>]]]

   Uninstall:  Sysmon.exe -u

-c 更新或显示配置

-h 指定hash记录的算法

-i 安装,可用xml文件来更新配置文件

-l 记录加载模块,可指定进程

-m 安装事件清单

-n 记录网络链接

-r 检测证书是否撤销

-u 卸载服务和驱动

一键安装:

sysmon -accepteula –i -n
指定配置文件(安装时请用-i)

sysmon -c xxx.xml
注:安装需要管理员权限并重启,windows 7 或者以上,服务器系统windows server 2012 及以上。

配置样例

<Sysmon schemaversion="4.21">
<!-- Capture all hashes -->
<HashAlgorithms>*</HashAlgorithms> <!--哈希配置(默认使用sha1) -->
<EventFiltering> <!--事件筛选-->
<!-- Log all drivers except if the signature -->
<!-- contains Microsoft or Windows -->
<DriverLoad onmatch="exclude"> <!--默认记录所有日志 除非标记 ? -->
     <Signature condition="contains">microsoft</Signature>
     <Signature condition="contains">windows</Signature>
</DriverLoad>
<!-- Do not log process termination -->
<!--不记录进程终止-->
<ProcessTerminate onmatch="include" />
<!-- Log network connection if the destination port equal 443 -->
<!-- or 80, and process isn't InternetExplorer -->
<NetworkConnect onmatch="include">
     <DestinationPort>443</DestinationPort> <!-- 记录443 端口连接记录-->
     <DestinationPort>80</DestinationPort>
</NetworkConnect>
<NetworkConnect onmatch="exclude">
     <Image condition="end with">iexplore.exe</Image>
</NetworkConnect>
</EventFiltering>
</Sysmon>

-- 配置条目直接位于Sysmon 标签下, 过滤器位于 EventFiltering 标签下

ProcessCreate            进程创建

FileCreateTime           文件创建时间更改

NetworkConnect           检测到网络连接

ProcessTerminate         进程终止

DriverLoad               驱动程序已加载

ImageLoad                镜像加载

CreateRemoteThread       已检测到创建远程线程

RawAccessRead            检测到原始访问读取

ProcessAccess            已访问的进程

FileCreate               文件创建

RegistryEvent            添加或删除注册表对象

RegistryEvent            注册表值设置

RegistryEvent            注册表对象已重命名

FileCreateStreamHash     已创建文件流

PipeEvent                管道创建

PipeEvent                管道已连接

WmiEvent                 检测到WmiEventFilter活动 -- WmiEventFilter activity detected

WmiEvent                 检测到WmiEventConsumer活动 -- WmiEventConsumer activity detected

WmiEvent                 检测到WmiEventConsumerToFilter活动 -- WmiEventConsumerToFilter activity 

DnsQuery                 DNS查询

sysmon 安装完成后,可以看到对应的Sysmon服务

sysmon 的日志位于,C:\Windows\System32\winevt\Logs\Microsoft-Windows-Sysmon%4Operational.evtx

  关键字:Sysmon配置服务记录日志


鼓掌

2

正能量

0

0

呵呵

0


评论区