Windows server 共用操作日誌設置

来源:https://www.cnblogs.com/98record/archive/2023/02/08/windows-server-gong-xiang-cao-zuo-ri-zhi.html
-Advertisement-
Play Games

Windows server 共用的文件操作日誌預設是沒有打開的,需要手動打開,本篇文章將詳細說明如何打開。並且如何將這個日誌輸出到ELK日誌系統中。 手動打開操作日誌 1、打開你的共用審核功能 舉例:我需要監控D盤的文件讀取、寫入、刪除等操作 右鍵D盤屬性 安全 高級 審核 繼續 添加需要監視的用 ...


Windows server 共用的文件操作日誌預設是沒有打開的,需要手動打開,本篇文章將詳細說明如何打開。並且如何將這個日誌輸出到ELK日誌系統中。

手動打開操作日誌

1、打開你的共用審核功能

舉例:我需要監控D盤的文件讀取、寫入、刪除等操作

  • 右鍵D盤屬性

  • 安全 高級 審核 繼續

  • 添加需要監視的用戶跟許可權,操作如下


2、設置本地安全策略

  • 進入本地安全策略

  • 如下圖找到「審批對象訪問」,雙擊修改屬性為成功

3、測試是否成功

進入剛剛設置了審核的目錄,我這進入D盤,在D盤下創建文件或目錄,然後將它刪除。操作完後如下查看確認是否有日誌存在

  • 打開事件查看器

  • 單擊進入安全

  • 日誌太多篩選一下日誌,如下圖

  • 剛我將「 D:測試共用盤可刪\新建文件夾\2023-02-08 」刪除了,可以看一下我的日誌信息如下:

將日誌傳到ELK日誌系統

假設目前你已經有一套ELK系統了,直接跳過。不會的可以看一下我的歷史文章
rpm+二進位包部署ELK
Docker部署ELK

1、安裝winlogbeat

  1. 下載軟體

我已將我的包上傳到雲盤了,有需要點我下載

  1. 解壓 將文件夾放至長期不動的固定目錄下(只是建議),例如我這放到C:\Program Files
  2. 進入文件夾,雙擊修改winlogbeat.yml文件,需要修改的配置都有用中文註釋瞭如下
###################### Winlogbeat Configuration Example ########################

# This file is an example configuration file highlighting only the most common
# options. The winlogbeat.reference.yml file from the same directory contains
# all the supported options with more comments. You can use it as a reference.
#
# You can find the full configuration reference here:
# https://www.elastic.co/guide/en/beats/winlogbeat/index.html

# ======================== Winlogbeat specific options =========================

# event_logs specifies a list of event logs to monitor as well as any
# accompanying options. The YAML data type of event_logs is a list of
# dictionaries.
#
# The supported keys are name (required), tags, fields, fields_under_root,
# forwarded, ignore_older, level, event_id, provider, and include_xml. Please
# visit the documentation for the complete details of each option.
# https://go.es.io/WinlogbeatConfig

winlogbeat.event_logs:
  - name: Application
    ignore_older: 72h

  - name: System

  - name: Security
    processors:
      - script:
          lang: javascript
          id: security
          file: ${path.home}/module/security/config/winlogbeat-security.js

  - name: Microsoft-Windows-Sysmon/Operational
    processors:
      - script:
          lang: javascript
          id: sysmon
          file: ${path.home}/module/sysmon/config/winlogbeat-sysmon.js

  - name: Windows PowerShell
    event_id: 400, 403, 600, 800
    processors:
      - script:
          lang: javascript
          id: powershell
          file: ${path.home}/module/powershell/config/winlogbeat-powershell.js

  - name: Microsoft-Windows-PowerShell/Operational
    event_id: 4103, 4104, 4105, 4106
    processors:
      - script:
          lang: javascript
          id: powershell
          file: ${path.home}/module/powershell/config/winlogbeat-powershell.js

  - name: ForwardedEvents
    tags: [forwarded]
    processors:
      - script:
          when.equals.winlog.channel: Security
          lang: javascript
          id: security
          file: ${path.home}/module/security/config/winlogbeat-security.js
      - script:
          when.equals.winlog.channel: Microsoft-Windows-Sysmon/Operational
          lang: javascript
          id: sysmon
          file: ${path.home}/module/sysmon/config/winlogbeat-sysmon.js
      - script:
          when.equals.winlog.channel: Windows PowerShell
          lang: javascript
          id: powershell
          file: ${path.home}/module/powershell/config/winlogbeat-powershell.js
      - script:
          when.equals.winlog.channel: Microsoft-Windows-PowerShell/Operational
          lang: javascript
          id: powershell
          file: ${path.home}/module/powershell/config/winlogbeat-powershell.js

# ====================== Elasticsearch template settings =======================

setup.template.settings:
  index.number_of_shards: 1
  #index.codec: best_compression
  #_source.enabled: false
#  setup.template.enabled: true
#  setup.template.overwrite: true 
#  setup.dashboards.index: "share-*"
#  setup.ilm.enabled: false


# ================================== General ===================================

# The name of the shipper that publishes the network data. It can be used to group
# all the transactions sent by a single shipper in the web interface.
#name:

# The tags of the shipper are included in their own field with each
# transaction published.
#tags: ["service-X", "web-tier"]

# Optional fields that you can specify to add additional information to the
# output.
#fields:
#  env: staging

# ================================= Dashboards =================================
# These settings control loading the sample dashboards to the Kibana index. Loading
# the dashboards is disabled by default and can be enabled either by setting the
# options here or by using the `setup` command.
#setup.dashboards.enabled: false

# The URL from where to download the dashboards archive. By default this URL
# has a value which is computed based on the Beat name and version. For released
# versions, this URL points to the dashboard archive on the artifacts.elastic.co
# website.
#setup.dashboards.url:

# =================================== Kibana ===================================

# Starting with Beats version 6.0.0, the dashboards are loaded via the Kibana API.
# This requires a Kibana endpoint configuration.
setup.kibana:

  # Kibana Host
  # Scheme and port can be left out and will be set to the default (http and 5601)
  # In case you specify and additional path, the scheme is required: http://localhost:5601/path
  # IPv6 addresses should always be defined as: https://[2001:db8::1]:5601
  #host: "localhost:5601"

  # Kibana Space ID
  # ID of the Kibana Space into which the dashboards should be loaded. By default,
  # the Default Space will be used.
  #space.id:

# =============================== Elastic Cloud ================================

# These settings simplify using Winlogbeat with the Elastic Cloud (https://cloud.elastic.co/).

# The cloud.id setting overwrites the `output.elasticsearch.hosts` and
# `setup.kibana.host` options.
# You can find the `cloud.id` in the Elastic Cloud web UI.
#cloud.id:

# The cloud.auth setting overwrites the `output.elasticsearch.username` and
# `output.elasticsearch.password` settings. The format is `<user>:<pass>`.
#cloud.auth:

# ================================== Outputs ===================================

# Configure what output to use when sending the data collected by the beat.

# ---------------------------- Elasticsearch Output ----------------------------
output.elasticsearch:
  # Array of hosts to connect to.
  # 修改為你的es IP地址,如果你是es集群的話拿都需要加進來。例如我ES集群中有三台那麼便都添加了。
   hosts: ["10.11.48.159:9200","10.12.48.161:9200","10.13.48.160:9200"]
   # 修改存入的ES索引名稱,預設索引名稱是 winlogbeat開頭的,可能你有多個winlogbeat那麼名稱會衝突,建議修改。
   index: "share-%{+yyyy.MM.dd}"
  # Protocol - either `http` (default) or `https`.
  #protocol: "https"

  # Authentication credentials - either API key or username/password.
  #api_key: "id:api_key"
  #username: "elastic"
  #password: "changeme"

# ------------------------------ Logstash Output -------------------------------
#output.logstash:
  # The Logstash hosts
  #hosts: ["localhost:5044"]

  # Optional SSL. By default is off.
  # List of root certificates for HTTPS server verifications
  #ssl.certificate_authorities: ["/etc/pki/root/ca.pem"]

  # Certificate for SSL client authentication
  #ssl.certificate: "/etc/pki/client/cert.pem"

  # Client Certificate Key
  #ssl.key: "/etc/pki/client/cert.key"

# ================================= Processors =================================
processors:
  - add_host_metadata:
      when.not.contains.tags: forwarded
  - add_cloud_metadata: ~

# ================================== Logging ===================================

# Sets log level. The default log level is info.
# Available log levels are: error, warning, info, debug
#logging.level: debug

# At debug level, you can selectively enable logging only for some components.
# To enable all selectors use ["*"]. Examples of other selectors are "beat",
# "publisher", "service".
#logging.selectors: ["*"]

# ============================= X-Pack Monitoring ==============================
# Winlogbeat can export internal metrics to a central Elasticsearch monitoring
# cluster.  This requires xpack monitoring to be enabled in Elasticsearch.  The
# reporting is disabled by default.

# Set to true to enable the monitoring reporter.
#monitoring.enabled: false

# Sets the UUID of the Elasticsearch cluster under which monitoring data for this
# Winlogbeat instance will appear in the Stack Monitoring UI. If output.elasticsearch
# is enabled, the UUID is derived from the Elasticsearch cluster referenced by output.elasticsearch.
#monitoring.cluster_uuid:

# Uncomment to send the metrics to Elasticsearch. Most settings from the
# Elasticsearch output are accepted here as well.
# Note that the settings should point to your Elasticsearch *monitoring* cluster.
# Any setting that is not set is automatically inherited from the Elasticsearch
# output configuration, so if you have the Elasticsearch output configured such
# that it is pointing to your Elasticsearch monitoring cluster, you can simply
# uncomment the following line.
#monitoring.elasticsearch:

# ============================== Instrumentation ===============================

# Instrumentation support for the winlogbeat.
#instrumentation:
    # Set to true to enable instrumentation of winlogbeat.
    #enabled: false

    # Environment in which winlogbeat is running on (eg: staging, production, etc.)
    #environment: ""

    # APM Server hosts to report instrumentation results to.
    #hosts:
    #  - http://localhost:8200

    # API Key for the APM Server(s).
    # If api_key is set then secret_token will be ignored.
    #api_key:

    # Secret token for the APM Server(s).
    #secret_token:


# ================================= Migration ==================================

# This allows to enable 6.7 migration aliases
#migration.6_to_7.enabled: true
# 如果你修改了索引名稱則以下配置也需要增加,不然無法生效。這裡的share命名需與上面的index命名首碼一致。
setup.template.enabled: true
setup.template.overwrite: true
setup.template.name: "share"       
setup.template.pattern: "share-*" 
setup.ilm.enabled: false
  1. 檢查配置
# 進入目錄
cd "C:\Program Files\winlogbeat-7.13.0-windows-x86_64"
.\winlogbeat.exe test config -c .\winlogbeat.yml -e

檢查期間如果提示為OK,說明配置文件沒問題

  1. 輸入一下命令啟動
# 進入目錄
cd "C:\Program Files\winlogbeat-7.13.0-windows-x86_64"
# 執行下麵命令後,需要輸入Y,回車。啟用執行不信任的腳本功能
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
# 將winlogbeat註冊成系統服務
.\install-service-winlogbeat.ps1
# 啟動
Start-Service winlogbeat
  1. 檢查確認

需要確認兩個地方分別是:

  1. 在Windows winlogbeat 是否啟動
  1. kibana是否存在了剛纔創建的索引
  1. 測試

刪除或者創建文件,然後在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


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 教程簡介 CICS快速指南 - 從CICS概述,環境,基本術語,Nucleus,事務,COBOL基礎知識,BMS,MAP,介面塊,偽編程,輔助密鑰,文件處理,錯誤處理,控制操作,簡單而簡單的步驟學習CICS臨時存儲,互通,狀態代碼。 CICS代表客戶信息控制系統。 CICS由IBM於1968年開發。 ...
  • 1. 概述 本地更新腳本是基於arthas工具的retransform命令熱替換class,此方法用於在不重啟項目的前提下,替換更新的class,如關鍵類添加列印日誌,排查線上問題 但是arthas工具的命令稍顯複雜,有那個時間還不如重新部署,因此需要一個可以快速替換的工具來進行替換 2. 方法一: ...
  • 教程簡介 亞馬遜商城快速指南 - 從簡單和簡單的步驟開始學習亞馬遜商城,從基本到高級概念,包括為什麼選擇亞馬遜?,亞馬遜優勢,帳戶類型,銷售什麼?,產品列表,費用,帳戶設置,購買盒,運輸方式,列出新產品,定價工具,獲取最高利潤,價格計算器,稅務處理,運輸流程,亞馬遜賣家中心,管理庫存,創建報告,管理 ...
  • 隨著技術的進步,跨平臺開發已經成為了標配,在此大背景下,ASP.NET Core也應運而生。本文主要基於ASP.NET Core+Element+Sql Server開發一個校園圖書管理系統為例,簡述基於MVC三層架構開發的常見知識點,前三篇篇文章簡單介紹瞭如何搭建開發框架,登錄功能,主頁面功能,以... ...
  • WPF框架代碼很龐雜不容易學習,這裡記錄我自己學習的點點滴滴。以wpf-4.8.0-rc1.19455.14為探索對象,相關代碼可在WPF倉庫下載。代碼結構大致如下: PresentationFramework 是最頂層抽象介面,開發中用到的大部分類都來源於此,包含各個控制項,圖形,動畫,綁定,XAM ...
  • 概述 開放封閉原則是面向對象所有原則的核心。對功能擴展開放,面向修改代碼封閉。 需求改變時,在小改變軟體實體源代碼(類、介面、方法等)的前提下通過擴展功能使其滿足新的需求。 需求 描述不同需求的用戶去銀行辦理不同的業務 分析需求 1、在這段程式中 會有多少個對象2、每個對象的屬性和行為對象1: 用戶 ...
  • docker問題 1. 安裝 docker 下載依賴環境 yum -y install yum-utils device-mapper-persistent-data lvm2 指定Docker鏡像源 # 使用的是阿裡的 yum-config-manager --add-repo http://mi ...
  • 一鍵部署nfs、rsync、sersync 項目代碼: 鏈接:https://pan.baidu.com/s/13I0BBAYsdK-KmPekZ5VpdA 提取碼:u2tw --來自百度網盤超級會員V6的分享 目錄結構 [root@m01 /ansible/roles]# tree -F . ├─ ...
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...