写点什么

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

评论

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

从特斯拉人形机器人亮相看AI人工智能模型落地面临的两个难题

felix

落地 机器人 AI人工智能

Go学习之路-1.认识GO语言

子不语Any

Go 后端 10月月更

Qt解压带有密码的加密文件

中国好公民st

c++ Qt Company 10月月更

【一Go到底】第一天---初识Goooooooooooooooooooooooo

指剑

Go go并发 10月月更

Python应用之计算三角形面积

芯动大师

10月月更 Python代码 计算三角形面积

【从0到1学算法】1. 如何获取题中关键信息

Geek_65222d

10月月更

微服务稳定性保障

穿过生命散发芬芳

微服务 10月月更

开发者有话说|程序猿工作多年之后的感悟

慕枫技术笔记

个人成长

MyBatis学习笔记之JDBC

薛定谔的猫

mybatis JDBC 10月月更

16个分论坛出品标准大揭秘,期待你的申请!

开源社

大数据ELK(十):使用VSCode操作猎聘网职位搜索案例

Lansonli

ELK 10月月更

mysql中的事务隔离级别序列化如何实现

知识浅谈

MySQL 隔离级别 10月月更

一起玩OptaPlanner-Study,玩转第一个程序

积木编程

COSCon'22主论坛来袭 开源站在十字路口

开源社

简述构建微服务架构的四大挑战

穿过生命散发芬芳

微服务 10月月更

OpenHarmony如何控制屏幕亮度

坚果

OpenHarmony 10月月更

【LeetCode】重新格式化电话号码Java题解

Albert

LeetCode 10月月更

存储优化--分区与冷热分离

喵叔

10月月更

2022-10-01:给定一个字符串 s,计算 s 的 不同非空子序列 的个数 因为结果可能很大,所以返回答案需要对 10^9 + 7 取余 。 字符串的 子序列 是经由原字符串删除一些(也可能不删除

福大大架构师每日一题

算法 rust 福大大

体验 Orbeon form PE 版本提供的 JavaScript Embedding API

汪子熙

Java SAP commerce 10月月更 oberon

《零代码教练指南》正式发布

明道云

面试官:高并发场景下,你们是怎么保证数据的一致性的?

一灯架构

Java MySQL 10月月更

数组操作の旋转二维数组

掘金安东尼

算法 10月月更

用任意类型编写代码——一文带你了解泛型编程

宇宙之一粟

Java 泛型编程 10月月更

[架构实战] 学习笔记二

爱学习的麦子

今日国庆,祝福祖国!【文末超级福利】

图灵教育

读书 国庆节

架构师的十八般武艺:线上运维

agnostic

运维

Spring Boot 集成 Redis 配置 MyBatis 二级缓存

微枫Micromaple

redis 缓存 mybatis springboot 10月月更

跟随一组图片,了解Go Channel的底层实现

董哥的黑板报

Go 后端 服务端 操作系统 runtime

今日国庆,祝福祖国!【文末超级福利】

图灵社区

读书 国庆节

ESP32-C3 学习测试 蓝牙 篇(四、GATT Server 示例解析)

矜辰所致

蓝牙 ESP32-C3 10月月更 GATT

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