AI实践哪家强?来 AICon, 解锁技术前沿,探寻产业新机! 了解详情
写点什么

Windows Sysinternal 实用内部监控工具:sysmon

  • 2020-02-25
  • 本文字数:2819 字

    阅读完需:约 9 分钟

Windows Sysinternal 实用内部监控工具:sysmon

Sysmon 是 Windows Sysinternals 系列中的一款工具。如果你想实时监控 Windows 系统又对其他第三方软件有顾虑,使用 Sysmon 这款轻量级 Microsoft 自带内部软件是最好的选择。

Sysmon 有啥用?

在打开应用或者任何进程创建的行为发生时,Sysmon 会使用 sha1(默认),MD5,SHA256 或 IMPHASH 记录进程镜像文件的 hash 值,包含进程创建过程中的进程 GUID,每个事件中包含 session 的 GUID。除此之外记录磁盘和卷的读取请求/网络连接(包括每个连接的源进程,IP 地址,端口号,主机名和端口名),重要的是还可在生成初期进程事件能记录在复杂的内核模式运行的恶意软件。

安装步骤

https://download.sysinternals.com/files/Sysmon.zip 下载 Sysmon,打开 CMD(Admin 权限)到放置路径下运行


Sysmon 启动

在实际生产环境应用时,根据不同的配置,这时候自定义监控规则显得尤为重要,又由于避免产生庞大的数据记录,需要通过精简配置来达到高效率日志生成。


Sysmon 提供了 xml 格式的配置文件来让用户自定义过滤规则,配置文件的东西比较多,以下提供一个测试用例。(xml 大小写敏感)


<Sysmon schemaversion="4.23">      <!-- Capture all hashes -->      <HashAlgorithms>*</HashAlgorithms>      <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>          <DestinationPort>80</DestinationPort>        </NetworkConnect>        <NetworkConnect onmatch="exclude">          <Image condition="end with">iexplore.exe</Image>        </NetworkConnect>      </EventFiltering>    </Sysmon>
复制代码


完成了 XML 的编写,即可上传到 Sysmon

默认配置

上传配置

配置检查


在上面我们看到了不同标识的 tag 用来定义 xml 配置文件,下面列出可选择的事件过滤器(tag)


ProcessCreate进程创建ProcessAccess进程访问
FileCreateTime进程创建时间FileCreate文件创建
NetworkConnect网络链接RegistryEvent注册表事件
ProcessTermina进程结束FileCreateStreamHash文件流创建
DriverLoad驱动加载PipeEvent管道事件
ImageLoad镜像加载WmiEventWMI事件
CreateRemoteThread远程线程创建DNSEvnetDNS事件
RawAccessRead驱动器读取Error报错


具体详细内容可参考 https://technet.microsoft.com/en-us/sysinternals/sysmon。


onmatch 选项只能设置为 include 或 exclude。


condition 根据不同的需求可设置为如下值:


ConditionDescription
IsDefault, values are equals
is notValues are different
ContainsThe field contains this value
ExcludesThe field does not contain this value
begin withThe field begins with this value
end withThe field ends with this value
less thanLexicographical comparison is less than zero
more thanLexicographical comparison is more than zero
ImageMatch an image path (full path or only image name). For example: lsass.exe will match c:\windows\system32\lsass.exe


在实际生产中请根据实际情况调整,以下为个人用例


<Sysmon schemaversion="4.23">  <!-- Capture all hashes -->  <HashAlgorithms>*</HashAlgorithms>  <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>    <ProcessTerminate onmatch="include" >            <Image condition="end with">MsMpEng.exe</Image>    </ProcessTerminate>    <!-- Log network connection if the destination port equal 443 -->    <!-- or 80, and process isn't InternetExplorer -->    <!--NetworkConnect onmatch="include">      <DestinationPort>443</DestinationPort>      <DestinationPort>80</DestinationPort >    </NetworkConnect -->    <FileCreateTime onmatch="exclude" >      <Image condition="end with">chrome.exe</Image>    </FileCreateTime>    <ImageLoad onmatch="include">      <Signed condition="is">false</Signed>    </ImageLoad>    <!-- Log access rights for lsass.exe or winlogon.exe is not PROCESS_QUERY_INFORMATION -->    <ProcessAccess onmatch="exclude">      <GrantedAccess condition="is">0x1400</GrantedAccess>    </ProcessAccess>    <ProcessAccess onmatch="include">
<TargetImage condition="end with">lsass.exe</TargetImage> <TargetImage condition="end with">winlogon.exe</TargetImage> </ProcessAccess> <CreateRemoteThread onmatch="include"> <TargetImage condition="end with">explorer.exe</TargetImage> <TargetImage condition="end with">svchost.exe</TargetImage> <TargetImage condition="end with">winlogon.exe</TargetImage> <SourceImage condition="end with">powershell.exe</SourceImage> </CreateRemoteThread> </EventFiltering></Sysmon>
复制代码

Sysmon 日志

Process Event

在 EventViewer->Applications and Services ->Microsoft->Windows->Sysmon 即可找到 Sysmon 监控得到的日志,如下图以 QQ 浏览器为例(非 Microsoft 三方软件,因为 Microsoft 软件已被列入白名单):



记录下来 QQ 浏览器访问了进程,属于进程访问事件。



关键的一点就是 GrantedAccess 的值为 0x1410,这个值表示 QQ 浏览器对 lsass 拥有上述受限制的访问权限,包括写进程内存和读进程内存,这样就能获取到用户口令。

Network Event

访问网站,可以看到连接的详细信息,包括 ip,端口,pid 等,如图通过 Sysmon 监控到 Outlook 对网络的访问



通过 CMD 对自己进行 ping 操作


日志记录

目前的恶意软件为了对抗检测很多都有日志删除功能,Sysmon 跟 EventView 的配合可以更好的将日志定制保存位置。


总结

Sysmon 作为 Microsoft 自创配合 Windows 的监控软件,结合其他 Windows 工具能让监控系统变得更容易和更效率,相对于其他第三方的监控软件提供了更安全高效和最轻量级的服务。


作者介绍:


周克,世纪互联蓝云 Office 365 认证服务运维专家 。


2020-02-25 17:547584

评论

发布
暂无评论
发现更多内容

低代码平台的流程引擎设计指南

Baidu AICLOUD

低代码 爱速搭

Rust的安全性和稳健型

非凸科技

EFCore之CodeFirst

青柚1943

ORM SqlServer NET6 EFCore

关于服务器数据迁移,介绍在服务器数据迁移计划中的7个步骤

镭速

3d建筑软件:Vectorworks 2023激活版

真大的脸盆

Mac Mac 软件 3D建筑动画

AREX-携程无代码侵入的自动化回归测试平台

AREX 中文社区

开源 自动化测试 回归测试

工业数字孪生:西门子工业网络与设备虚拟调试案例

Openlab_cosmoplat

工业互联网 开源社区 数字孪生

天工人巧日争新:昇腾AI的绚丽今日

脑极体

AI

Sugar BI 增强分析能力全场景解析

Baidu AICLOUD

BI

关于 SysOM 2.0 网络/存储相关诊断功能介绍及案例展示 | 第 72-73 期

OpenAnolis小助手

开源 直播 系统运维 技术分享 龙蜥大讲堂

研发效能度量从 0 到 1 的『六脉神剑』

思码逸研发效能

研发效能 效能度量 研发效能度量

vue项目中babel的最佳实践

虎妞先生

前端 Vue 3 vue cli babel

【云原生】k8s 环境快速部署(一小时以内部署完)

Java你猿哥

Java 学习 k8s Spring Boot ssm

DSC:数仓SQL脚本迁移的神奇工具

华为云开发者联盟

数据库 后端 华为云 华为云开发者联盟 企业号 3 月 PK 榜

MySQL创建用户与授权

源字节1号

软件开发 前端开发 后端开发 小程序开发

十问babel

虎妞先生

前端工程化 babel 前端‘’

Tapdata Cloud 基础课:新功能详解之「授权系统自动分析」,一键定位任务报错原因,快速获取修复建议

tapdata

大数据

为什么CMS和G1都改用三色标记法,是可达性分析不香吗?

Java全栈架构师

Java 程序员 后端 JVM 架构师

Java中让两个线程交替执行的实现方式

Janwee

并发 信号量 java 多线程、

活动推荐 | 博睿数据数智领航营火热报名中

博睿数据

保险 博睿数据 活动报名 数智领航营

MQTT 5.0新特性:属性与载荷

EMQ映云科技

物联网 IoT mqtt 企业号 3 月 PK 榜 载荷

最新Blender 3.3安装包+详细安装教程

Finovy Cloud

blender 3D软件

DBA必备的Mysql知识点:数据类型和运算符

华为云开发者联盟

数据库 后端 华为云 华为云开发者联盟 企业号 3 月 PK 榜

办公要有新享法,「MIAOYUN生活梦想家」焕新升级!

MIAOYUN

搬迁公告 乔迁 办公升级

Seata-go 1.1.0 发布,补齐 AT 模式支持

SOFAStack

开源 互联网 开发者 开发 Seata框架

尚硅谷Node.js实战教程发布

小谷哥

2023主流系统 固资管理助力转型升级一步到位

加入高科技仿生人

低代码 企业数字化转型 资产管理

倒计时2天:百度“文心一言”即将上线!

引迈信息

人工智能 低代码 AIGC ChatGPT 文心一言

我在京东做研发第五期:京东云自研服务器,如何将开发成本降低 60% 的同时还更低碳环保?

京东科技开发者

cpu 服务器 环保 节能 企业号 3 月 PK 榜

Windows Sysinternal 实用内部监控工具:sysmon_架构_周克_InfoQ精选文章