【安全运维】在Windows平台利用sysmon进行安全分析

在Windows平台利用sysmon进行安全分析
Sysmon是由Windows Sysinternals出品的Sysinternals系列中的工具。它以系统服务和设备驱动程序的方法安装在系统上,并保持常驻性,是一款轻量级且强大的安全监控工具。

1、安装使用

下载链接:https://docs.microsoft.com/en-us/sysinternals/downloads/sysmon
下载后解压,里面覆盖了32位和64位平台的程序。

Copyright (C) 2014-2020 Mark Russinovich and Thomas Garnier
Sysinternals - www.sysinternals.com

Usage:
Install:                 Sysmon64.exe -i [<configfile>]
Update configuration:    Sysmon64.exe -c [<configfile>]
Install event manifest:  Sysmon64.exe -m
Print schema:            Sysmon64.exe -s
Uninstall:               Sysmon64.exe -u [force]
  -c   Update configuration of an installed Sysmon driver or dump the
       current configuration if no other argument is provided. Optionally
       take a configuration file.
  -i   Install service and driver. Optionally take a configuration file.
  -m   Install the event manifest (done on service install as well).
  -s   Print configuration schema definition of the specified version.
       Specify 'all' to dump all schema versions (default is latest).
  -u   Uninstall service and driver. Adding force causes uninstall to proceed
       even when some components are not installed.

The service logs events immediately and the driver installs as a boot-start driver to capture activity from early in
the boot that the service will write to the event log when it starts.

On Vista and higher, events are stored in "Applications and Services Logs/Microsoft/Windows/Sysmon/Operational". On
older systems, events are written to the System event log.

Use the '-? config' command for configuration file documentation.More examples are available on the Sysinternals
website.

Specify -accepteula to automatically accept the EULA on installation, otherwise you will be interactively prompted to
accept it.

Neither install nor uninstall requires a reboot.

最常用的安装方式:

sysmon -accepteula  –i -n

推荐使用大佬们配置好的配置文件,以下给出的配置文件链接预定义了高质量的事件跟踪模板:
https://github.com/SwiftOnSecurity/sysmon-config

sysmon.exe -accepteula -i sysmonconfig-export.xml #指定使用该配置文件进行安装

2、分析范例:使用CS马进行分析

sysmon的日志记录在windows事件查看器--应用程序和服务日志--Microsoft--windows--sysmon,逐级展开进入到sysmon下:

为了便于分析,这里手动清空下。
CS生成使用office宏的payload,直接执行:

上图可以看到已经上线了。接下来到sysmon里看下能不能找到蛛丝马迹
前两个是指在explorer环境下使用word打开了这个文档,然后又调用了rundll32.exe,重点从第三个“CreateRemoteThread detected:”开始细看

将winword进程注入到rundll32.exe实现程序隐藏,新的进程ID是1056。

向teamserver服务器的外联请求:
Network connection detected为网络连接事件

进程ID1056,进程名为rundll32.exe跟上面是贴合的。目标端口80 目标IP为teamserver的IP地址。

附:sysmon所有事件对应的官方定义和解释
https://docs.microsoft.com/en-us/sysinternals/downloads/sysmon

3、sysmon辅助分析工具

sysmon虽然很方便,可以在日志管理中进行分析日志,但仍不够直观,查询不够方便快速,以下介绍的三款sysmon辅助工具将大大提升使用sysmon的日志分析工具时的效率。

Sysmon View:离线Sysmon日志可视化工具。
Sysmon Shell: Sysmon配置实用程序。
Sysmon Box: Sysmon和网络捕获日志实用程序。

下载地址:https://github.com/nshalabi/SysmonTools
下载速度过慢,是因为做着没有删除.git文件夹导致里面夹杂了很多临时文件还有代码。本身这三个工具源文件是很小的。

3.1 sysmon view

进程的概览信息

更快速的安全日志查询


将日志中的线索自动按应用程序树状结构进行展示,可直接双击查询

3.2 sysmon shell

sysmon shell里预定义了很多事件选项,可灵活自定义生成XML模板文件。

上图的红色标注部分就是本文开头用的那个模板;
也可以打开这个模板然后自定义。

3.3 sysmon box

进入wireshark的安装目录,使用tshark或直接打开wireshark看哪个网卡是正在用的。

./tshark.exe -D #检测正在使用的网卡

利用wireshark进行抓包,停止后自动生成pcap文件和sysmon view DB文件。
然后再sysmon view中进行可视化分析。

posted @ 2020-08-20 15:49  thecat'sblog  阅读(1917)  评论(0编辑  收藏  举报