翼度科技»论坛 云主机 服务器技术 查看内容

Windows server 共享操作日志设置

4

主题

4

帖子

12

积分

新手上路

Rank: 1

积分
12
Windows server 共享的文件操作日志默认是没有打开的,需要手动打开,本篇文章将详细说明如何打开。并且如何将这个日志输出到ELK日志系统中。
手动打开操作日志

1、打开你的共享审核功能

举例:我需要监控D盘的文件读取、写入、删除等操作

  • 右键D盘属性


  • 安全  高级  审核  继续

  • 添加需要监视的用户跟权限,操作如下


2、设置本地安全策略


  • 进入本地安全策略

  • 如下图找到「审批对象访问」,双击修改属性为成功

3、测试是否成功

进入刚刚设置了审核的目录,我这进入D盘,在D盘下创建文件或目录,然后将它删除。操作完后如下查看确认是否有日志存在

  • 打开事件查看器


  • 单击进入安全


  • 日志太多筛选一下日志,如下图


  • 刚我将「 D:测试共享盘可删\新建文件夹\2023-02-08 」删除了,可以看一下我的日志信息如下:

将日志传到ELK日志系统

假设目前你已经有一套ELK系统了,直接跳过。不会的可以看一下我的历史文章
rpm+二进制包部署ELK
Docker部署ELK
1、安装winlogbeat


  • 下载软件
我已将我的包上传到云盘了,有需要点我下载

  • 解压  将文件夹放至长期不动的固定目录下(只是建议),例如我这放到C:\Program Files 下
  • 进入文件夹,双击修改winlogbeat.yml文件,需要修改的配置都有用中文注释了如下
  1. ###################### Winlogbeat Configuration Example ########################
  2. # This file is an example configuration file highlighting only the most common
  3. # options. The winlogbeat.reference.yml file from the same directory contains
  4. # all the supported options with more comments. You can use it as a reference.
  5. #
  6. # You can find the full configuration reference here:
  7. # https://www.elastic.co/guide/en/beats/winlogbeat/index.html
  8. # ======================== Winlogbeat specific options =========================
  9. # event_logs specifies a list of event logs to monitor as well as any
  10. # accompanying options. The YAML data type of event_logs is a list of
  11. # dictionaries.
  12. #
  13. # The supported keys are name (required), tags, fields, fields_under_root,
  14. # forwarded, ignore_older, level, event_id, provider, and include_xml. Please
  15. # visit the documentation for the complete details of each option.
  16. # https://go.es.io/WinlogbeatConfig
  17. winlogbeat.event_logs:
  18.   - name: Application
  19.     ignore_older: 72h
  20.   - name: System
  21.   - name: Security
  22.     processors:
  23.       - script:
  24.           lang: javascript
  25.           id: security
  26.           file: ${path.home}/module/security/config/winlogbeat-security.js
  27.   - name: Microsoft-Windows-Sysmon/Operational
  28.     processors:
  29.       - script:
  30.           lang: javascript
  31.           id: sysmon
  32.           file: ${path.home}/module/sysmon/config/winlogbeat-sysmon.js
  33.   - name: Windows PowerShell
  34.     event_id: 400, 403, 600, 800
  35.     processors:
  36.       - script:
  37.           lang: javascript
  38.           id: powershell
  39.           file: ${path.home}/module/powershell/config/winlogbeat-powershell.js
  40.   - name: Microsoft-Windows-PowerShell/Operational
  41.     event_id: 4103, 4104, 4105, 4106
  42.     processors:
  43.       - script:
  44.           lang: javascript
  45.           id: powershell
  46.           file: ${path.home}/module/powershell/config/winlogbeat-powershell.js
  47.   - name: ForwardedEvents
  48.     tags: [forwarded]
  49.     processors:
  50.       - script:
  51.           when.equals.winlog.channel: Security
  52.           lang: javascript
  53.           id: security
  54.           file: ${path.home}/module/security/config/winlogbeat-security.js
  55.       - script:
  56.           when.equals.winlog.channel: Microsoft-Windows-Sysmon/Operational
  57.           lang: javascript
  58.           id: sysmon
  59.           file: ${path.home}/module/sysmon/config/winlogbeat-sysmon.js
  60.       - script:
  61.           when.equals.winlog.channel: Windows PowerShell
  62.           lang: javascript
  63.           id: powershell
  64.           file: ${path.home}/module/powershell/config/winlogbeat-powershell.js
  65.       - script:
  66.           when.equals.winlog.channel: Microsoft-Windows-PowerShell/Operational
  67.           lang: javascript
  68.           id: powershell
  69.           file: ${path.home}/module/powershell/config/winlogbeat-powershell.js
  70. # ====================== Elasticsearch template settings =======================
  71. setup.template.settings:
  72.   index.number_of_shards: 1
  73.   #index.codec: best_compression
  74.   #_source.enabled: false
  75. #  setup.template.enabled: true
  76. #  setup.template.overwrite: true
  77. #  setup.dashboards.index: "share-*"
  78. #  setup.ilm.enabled: false
  79. # ================================== General ===================================
  80. # The name of the shipper that publishes the network data. It can be used to group
  81. # all the transactions sent by a single shipper in the web interface.
  82. #name:
  83. # The tags of the shipper are included in their own field with each
  84. # transaction published.
  85. #tags: ["service-X", "web-tier"]
  86. # Optional fields that you can specify to add additional information to the
  87. # output.
  88. #fields:
  89. #  env: staging
  90. # ================================= Dashboards =================================
  91. # These settings control loading the sample dashboards to the Kibana index. Loading
  92. # the dashboards is disabled by default and can be enabled either by setting the
  93. # options here or by using the `setup` command.
  94. #setup.dashboards.enabled: false
  95. # The URL from where to download the dashboards archive. By default this URL
  96. # has a value which is computed based on the Beat name and version. For released
  97. # versions, this URL points to the dashboard archive on the artifacts.elastic.co
  98. # website.
  99. #setup.dashboards.url:
  100. # =================================== Kibana ===================================
  101. # Starting with Beats version 6.0.0, the dashboards are loaded via the Kibana API.
  102. # This requires a Kibana endpoint configuration.
  103. setup.kibana:
  104.   # Kibana Host
  105.   # Scheme and port can be left out and will be set to the default (http and 5601)
  106.   # In case you specify and additional path, the scheme is required: http://localhost:5601/path
  107.   # IPv6 addresses should always be defined as: https://[2001:db8::1]:5601
  108.   #host: "localhost:5601"
  109.   # Kibana Space ID
  110.   # ID of the Kibana Space into which the dashboards should be loaded. By default,
  111.   # the Default Space will be used.
  112.   #space.id:
  113. # =============================== Elastic Cloud ================================
  114. # These settings simplify using Winlogbeat with the Elastic Cloud (https://cloud.elastic.co/).
  115. # The cloud.id setting overwrites the `output.elasticsearch.hosts` and
  116. # `setup.kibana.host` options.
  117. # You can find the `cloud.id` in the Elastic Cloud web UI.
  118. #cloud.id:
  119. # The cloud.auth setting overwrites the `output.elasticsearch.username` and
  120. # `output.elasticsearch.password` settings. The format is `<user>:<pass>`.
  121. #cloud.auth:
  122. # ================================== Outputs ===================================
  123. # Configure what output to use when sending the data collected by the beat.
  124. # ---------------------------- Elasticsearch Output ----------------------------
  125. output.elasticsearch:
  126.   # Array of hosts to connect to.
  127.   # 修改为你的es IP地址,如果你是es集群的话拿都需要加进来。例如我ES集群中有三台那么便都添加了。
  128.    hosts: ["10.11.48.159:9200","10.12.48.161:9200","10.13.48.160:9200"]
  129.    # 修改存入的ES索引名称,默认索引名称是 winlogbeat开头的,可能你有多个winlogbeat那么名称会冲突,建议修改。
  130.    index: "share-%{+yyyy.MM.dd}"
  131.   # Protocol - either `http` (default) or `https`.
  132.   #protocol: "https"
  133.   # Authentication credentials - either API key or username/password.
  134.   #api_key: "id:api_key"
  135.   #username: "elastic"
  136.   #password: "changeme"
  137. # ------------------------------ Logstash Output -------------------------------
  138. #output.logstash:
  139.   # The Logstash hosts
  140.   #hosts: ["localhost:5044"]
  141.   # Optional SSL. By default is off.
  142.   # List of root certificates for HTTPS server verifications
  143.   #ssl.certificate_authorities: ["/etc/pki/root/ca.pem"]
  144.   # Certificate for SSL client authentication
  145.   #ssl.certificate: "/etc/pki/client/cert.pem"
  146.   # Client Certificate Key
  147.   #ssl.key: "/etc/pki/client/cert.key"
  148. # ================================= Processors =================================
  149. processors:
  150.   - add_host_metadata:
  151.       when.not.contains.tags: forwarded
  152.   - add_cloud_metadata: ~
  153. # ================================== Logging ===================================
  154. # Sets log level. The default log level is info.
  155. # Available log levels are: error, warning, info, debug
  156. #logging.level: debug
  157. # At debug level, you can selectively enable logging only for some components.
  158. # To enable all selectors use ["*"]. Examples of other selectors are "beat",
  159. # "publisher", "service".
  160. #logging.selectors: ["*"]
  161. # ============================= X-Pack Monitoring ==============================
  162. # Winlogbeat can export internal metrics to a central Elasticsearch monitoring
  163. # cluster.  This requires xpack monitoring to be enabled in Elasticsearch.  The
  164. # reporting is disabled by default.
  165. # Set to true to enable the monitoring reporter.
  166. #monitoring.enabled: false
  167. # Sets the UUID of the Elasticsearch cluster under which monitoring data for this
  168. # Winlogbeat instance will appear in the Stack Monitoring UI. If output.elasticsearch
  169. # is enabled, the UUID is derived from the Elasticsearch cluster referenced by output.elasticsearch.
  170. #monitoring.cluster_uuid:
  171. # Uncomment to send the metrics to Elasticsearch. Most settings from the
  172. # Elasticsearch output are accepted here as well.
  173. # Note that the settings should point to your Elasticsearch *monitoring* cluster.
  174. # Any setting that is not set is automatically inherited from the Elasticsearch
  175. # output configuration, so if you have the Elasticsearch output configured such
  176. # that it is pointing to your Elasticsearch monitoring cluster, you can simply
  177. # uncomment the following line.
  178. #monitoring.elasticsearch:
  179. # ============================== Instrumentation ===============================
  180. # Instrumentation support for the winlogbeat.
  181. #instrumentation:
  182.     # Set to true to enable instrumentation of winlogbeat.
  183.     #enabled: false
  184.     # Environment in which winlogbeat is running on (eg: staging, production, etc.)
  185.     #environment: ""
  186.     # APM Server hosts to report instrumentation results to.
  187.     #hosts:
  188.     #  - http://localhost:8200
  189.     # API Key for the APM Server(s).
  190.     # If api_key is set then secret_token will be ignored.
  191.     #api_key:
  192.     # Secret token for the APM Server(s).
  193.     #secret_token:
  194. # ================================= Migration ==================================
  195. # This allows to enable 6.7 migration aliases
  196. #migration.6_to_7.enabled: true
  197. # 如果你修改了索引名称则以下配置也需要增加,不然无法生效。这里的share命名需与上面的index命名前缀一致。
  198. setup.template.enabled: true
  199. setup.template.overwrite: true
  200. setup.template.name: "share"      
  201. setup.template.pattern: "share-*"
  202. setup.ilm.enabled: false
复制代码

  • 检查配置
  1. # 进入目录
  2. cd "C:\Program Files\winlogbeat-7.13.0-windows-x86_64"
  3. .\winlogbeat.exe test config -c .\winlogbeat.yml -e
复制代码
检查期间如果提示为OK,说明配置文件没问题


  • 输入一下命令启动
  1. # 进入目录
  2. cd "C:\Program Files\winlogbeat-7.13.0-windows-x86_64"
  3. # 执行下面命令后,需要输入Y,回车。启用执行不信任的脚本功能
  4. Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
  5. # 将winlogbeat注册成系统服务
  6. .\install-service-winlogbeat.ps1
  7. # 启动
  8. Start-Service winlogbeat
复制代码

  • 检查确认
需要确认两个地方分别是:

  • 在Windows winlogbeat 是否启动


  • kibana是否存在了刚才创建的索引


  • 测试
删除或者创建文件,然后在kibana中搜索。搜索删除语法event.code:"4663" and message : DELETE

PS:kibana的使用自行探索,在此不做介绍了哦
参考链接

https://blog.csdn.net/yk20091201/article/details/90756738
https://www.cnblogs.com/lhxsoft/p/15994432.html
https://blog.csdn.net/weixin_43719616/article/details/114790067
https://iminto.github.io/post/filebeat%E4%BF%AE%E6%94%B9index%E7%9A%84%E4%B8%80%E4%B8%AA%E5%9D%91/
https://blog.51cto.com/studyit2016/2084858
https://www.doit.com.cn/p/137278.html

来源:https://www.cnblogs.com/98record/p/windows-server-gong-xiang-cao-zuo-ri-zhi.html
免责声明:由于采集信息均来自互联网,如果侵犯了您的权益,请联系我们【E-Mail:cb@itdo.tech】 我们会及时删除侵权内容,谢谢合作!

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x

举报 回复 使用道具