设为首页 收藏本站
查看: 854|回复: 0

[经验分享] Sysmon + NXlog构建简单的windows安全监控

[复制链接]

尚未签到

发表于 2017-12-7 21:41:09 | 显示全部楼层 |阅读模式
  工具:
  Sysmon (sysmon 5.0) ,NXlog(nxlog-ce-2.9.1716.msi) .
  Sysmon监控系统并生成windows event log,   NXlog将windows event log传输到syslog服务器。
  Sysmon可以监控Process create, Process terminate, Driver loaded, File creation time changed, RawAccessRead, CreateRemoteThread, Sysmon service state changed。
  配置:
  NXlog配置:



## This is a sample configuration file. See the nxlog reference manual about the
## configuration options. It should be installed locally and is also available
## online at http://nxlog.org/docs/
## Please set the ROOT to the folder your nxlog was installed into,
## otherwise it will not start.
#define ROOT C:\Program Files\nxlog
define ROOT C:\Program Files (x86)\nxlog
Moduledir %ROOT%\modules
CacheDir %ROOT%\data
Pidfile %ROOT%\data\nxlog.pid
SpoolDir %ROOT%\data
LogFile %ROOT%\data\nxlog.log
<Extension _syslog>
Module      xm_syslog
</Extension>
<Input in>
Module im_msvistalog
Query <QueryList> <Query Id="0"> <Select Path="Microsoft-Windows-Sysmon/Operational">*</Select> </Query></QueryList>
</Input>
<Output out>
Module      om_udp
Host        security-log.syslogserver.com
Port        639
Exec        to_syslog_snare();
</Output>
<Route 1>
Path        in => out
</Route>

  Sysmon配置:



<Sysmon schemaversion="3.20">
<!-- 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>
<NetworkConnect onmatch="exclude">
<Image condition="end with">chrome.exe</Image>
<SourcePort condition="is">137</SourcePort>
<SourcePortName condition="is">llmnr</SourcePortName>
<DestinationPortName condition="is">llmnr</DestinationPortName>
</NetworkConnect>
<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 -i config.conf 。   
  - nxlog双击运行,记得启动服务。(NXlog可命令行安装 msiexec /i  nxlog-ce-2.9.1716.msi  AGREETOLIECENSE="yes"    ACCEPT=YES  /qr+)
  使用mimikatz抓取hash:
DSC0000.png

DSC0001.png

  附NXlog完整配置样例:



## This is a basic configuration file for Windows Server 2008 * 2012
## to GrayLog2 with GELF support and filtering.
## See the nxlog reference manual about the configuration options.
## It should be installed locally and is also available
## online at http://nxlog.org/nxlog-docs/en/nxlog-reference-manual.html
## Please set the ROOT to the folder your nxlog was installed into,
## otherwise it will not start.
define ROOT C:\Program Files (x86)\nxlog
# define ROOT C:\Program Files\nxlog
Moduledir %ROOT%\modules
CacheDir %ROOT%\data
Pidfile %ROOT%\data\nxlog.pid
SpoolDir %ROOT%\data
LogFile %ROOT%\data\nxlog.log
<Extension gelf>
Module xm_gelf
</Extension>
<Input pr_mseventlog>
Module      im_msvistalog
ReadFromLast    True
# http://msdn.microsoft.com/en-us/library/aa385231.aspx
# http://msdn.microsoft.com/en-us/library/ff604025(v=office.14).aspx
# Level 1 (ID=30  Critical)     severity level events
# Level 2 (ID=40  Error)        severity level events
# Level 3 (ID=50  Warning)      severity level events
# Level 4 (ID=80  Information)  severity level events
# Level 5 (ID=100 Verbose)      severity level events
# All channels are included by default which are listed in the registry under these:
# HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WINEVT\Channels
# HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\eventlog\System
#
# <Select Path='Key Management Service'>*</Select></Query>\
# <Select Path='Internet Explorer'>*</Select></Query>\
# <Select Path='HardwareEvents'>*</Select></Query>\
#
Query   <QueryList>\
<Query Id="0">\
<Select Path="Security">*</Select>\
<Select Path="System">*[System/Level=4]</Select>\
<Select Path="Application">*[Application/Level=2]</Select>\
<Select Path="Setup">*[System/Level=3]</Select>\
<Select Path='Windows PowerShell'>*</Select>\
</Query>\
</QueryList>
# REGEX EXAMPLES:
# "\s" equals one white space character, and ".*" equals any one char
# Line Contains both "bubble" and "gum"
#   Search pattern: ^(?=.*?\bbubble\b)(?=.*?\bgum\b).*
# Line does Not Contain "boy"
#   Search pattern: ^(?!.*boy).*
# Line Contains "bubble" but Neither "gum" Nor "bath"
#   Search pattern: ^(?=.*bubble)(?!.*gum)(?!.*bath).*
# Uncomment next line to view all logs, we can view output to help
# create the regex, next line shows my $raw_event data to parse:
# 2013-11-18 15:23:02 INFO 2013-12-18 15:23:01 ahost.adomain.local INFO 62464 UVD Information
# Exec   log_info($raw_event) ;
Exec if ($raw_event =~ /INFO\s+62464/) drop();
</Input>
<Output out>
Module      om_udp
Host        10.247.x.x
Port        12201
OutputType  GELF
</Output>
<Route 1>
Path    pr_mseventlog  => out
</Route>

  参考:
  http://www.freebuf.com/sectool/122779.html
  https://technet.microsoft.com/en-us/sysinternals/dn798348
  https://nxlog.co/docs/sysmon/audit-logging-on-windows-with-sysmon-and-nxlog.html
  http://www.ilanni.com/?p=595

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-421930-1-1.html 上篇帖子: MySQL 5.7 在windows下修改max_allowed_packet变量 下篇帖子: My SQL 和SQL Server区别
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表