阿里、蚂蚁、晟腾、中科加禾精彩分享 AI 基础设施洞见,现购票可享受 9 折优惠 |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:546550

评论

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

缓存数据的淘汰之路(上)

卢卡多多

28天写作 签约计划第二季 12月日更

「MySQL」数据库备份和还原

恒生LIGHT云社区

MySQL 数据库 MySQL 数据库

羊肉泡馍我们来了,尚硅谷西安分校设立首期特惠

编程江湖

编程开发

【混合云小知识】混合云应用场景包含哪些?

行云管家

云计算 混合云

结算中心全国集中化支撑解决之道

鲸品堂

CSS之选择器

Augus

CSS 12月日更

华为云应用构建技术实践精选集

华为云开发者联盟

云计算 华为云 内容合集 技术专题合集 应用构建

【喜讯】尚硅谷西安分校成立啦

@零度

尚硅谷 西安分校成立

怎么排查是哪里出现了数据倾斜

编程江湖

大数据 数据倾斜

热门盘点:企业该如何对待低代码?应不应该选择低代码?

优秀

低代码

一个渐进式微前端框架 - Fronts

RingCentral铃盛

架构 大前端 测试 经验分享

斟茶兵——远程进程管理

白粥

进程管理 运维开发 系统维护 离职交接 日常工作

大数据开发之Hadoop家族都有谁

@零度

大数据 hadoop

Cypress 基础 - 元素的定位

Jerry Wang

CSS html Cypress 28天写作 12月日更

The Data Way Vol.7|从故事里寻找开源的『内核』

SphereEx

Apache 开源 播客 Meetup SphereEx

如何用GoldWave将音频添加生成机械化音效

懒得勤快

EasyRecovery如何恢复ps的psd文件

淋雨

数据恢复 EasyRecovery

再添神器!Paddle.js 发布 OCR SDK

百度开发者中心

OCR paddle.js

30个类手写Spring核心原理之环境准备(1)

Tom弹架构

Java spring 源码

java序列化实现原理和深度分析

Java个体户

Java

埃文科技上榜CCSIP 2021中国网络安全产业全景图3大安全模块

郑州埃文科技

网络安全 ip技术 全景图

解析云原生2.0架构设计的8大关键趋势

华为云开发者联盟

云原生 架构设计 数据治理 存算分离 分布式云

零代码训练营第七期本月启动,现正开放报名!

明道云

Linux一学就会之重定向和文件的查找(Linux下一切皆文件)

学神来啦

Linux 运维 linux云计算 linux一学就会

万字详解什么是生成对抗网络GAN

华为云开发者联盟

算法 推荐算法 GAN 强化学习 生成对抗网络

🍃【Spring专题】「实战系列」spring注解@ConditionalOnExpression详细使用说明

洛神灬殇

spring Spring Framework Condition 12月日更 ConditionOnExpression

产品经理进阶(一)Web APP UI一致性设计

No Silver Bullet

产品经理 12月日更

2021年11月国产数据库大事记

墨天轮

数据库 opengauss TiDB oceanbase 国产数据库

探索圈外的世界 | GTLC 全球技术领导力峰会·厦门站圆满收官

TGO鲲鹏会

区块链 方法论 技术管理 GTLC

保险行业办理过等保选择哪家好?有成功案例吗?

行云管家

网络安全 等保 等级保护 等保2.0

EMQ 映云科技走进高校,与浙大城市学院联合促进物联网人才培养

EMQ映云科技

物联网 mqtt

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