写点什么

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:547529

评论

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

爽游做得好,游戏部署方案必不可少,华为云游戏云端部署方案愈发吃香了

平平无奇爱好科技

图+AI 生成未来|悦数图数据库亮相 2023 世界人工智能大会

悦数图数据库

AI 图数据库 大模型 AIGC

利用小程序技术,构建数字警务体系

没有用户名丶

FastGithub:github加速神器,解决github打不开、用户头像无法加载、releases无法上传下载、git-clone、git-pull、git-push失败等问题。

汀丶人工智能

GitHub git加速

模块六:拆分电商服务为微服务

家有两宝

架构实战营

晴数智慧数据集名列北京市首批“人工智能大模型高质量数据集”,入选产业创新伙伴计划

极客天地

全议程公布丨涌现中重塑,PingCAP 用户峰会 2023 邀你共同引领创新力量!

PingCAP

MySQL 数据库 TiDB pingCAP 平凯星辰

构建云上和云下统一的安全方案,华为云致力为企业降本增效

平平无奇爱好科技

Python案例分析|井字棋(Tic Tac Toe)游戏 | 社区征文

TiAmo

Python 年中技术盘点 井字棋游戏

🔥年中技术盘点暨7月主题征文活动开始啦!

InfoQ写作社区官方

热门活动 年中技术盘点

MySQL的match函数在sp中使用的BUG解析

GreatSQL

数据库 greatsql

认知负担的挑战与平台工程的机遇

SEAL安全

DevOps 平台工程 认知负担

​山东大学高校专区入驻飞桨AI Studio,优质教育资源等你来学!

飞桨PaddlePaddle

人工智能 百度 paddle 百度飞桨

数字化转型与架构-规划篇|谁是需求调研的对象?

数字随行

数字化转型

探究C语言中的二叉树

芯动大师

聆心智能上榜“北京市通用人工智能大模型行业应用典型场景案例”

硬科技星球

瓴羊QuickBI数据门户帮助企业高效管理和展示数据,使其更加明确易懂

对不起该用户已成仙‖

PoseiSwap 治理通证POSE登录PancakeSwap,开盘涨幅超2100%

BlockChain先知

网络信息安全尤为重要,华为云如何为企业构建云上云下一体化安全方案?

平平无奇爱好科技

华为云游戏云端部署方案:如何为游戏厂商降本增效

平平无奇爱好科技

休闲类匹配竞技游戏公司为何需要华为云游戏云端部署方案?

平平无奇爱好科技

华为云函数工作流FunctionGraph新手操作指南

华为云PaaS服务小智

云计算 Serverless 华为云 华为开发者大会2023

PoseiSwap 治理通证POSE登录PancakeSwap,开盘涨幅超2100%

股市老人

代码随想录训练营 Day07 - 哈希表(下)

jjn0703

华为云云上云下一体化安全,如何为企业打造统一、高效的安全管理平台

平平无奇爱好科技

云上办公时代,华为云桌面表现如何?

平平无奇爱好科技

货拉拉论文入选中国市场营销国际学术年会CMIC

科技热闻

不能不知道的LED显示屏产业机遇

Dylan

机遇 产业 LED显示屏 led显示屏厂家

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