甲方安全建设之日志采集实操干货

这篇具有很好参考价值的文章主要介绍了甲方安全建设之日志采集实操干货。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

前言

没有永远的安全,如何在被攻击的情况下,快速响应和快速溯源分析攻击动作是个重要的话题。想要分析攻击者做了什么、怎么攻击进来的、还攻击了谁,那么日志是必不可少的一项,因此我们需要尽可能采集多的日志来进行分析攻击者的动作,甚至在攻击者刚落脚的时候就阻断攻击者。

安装Elastic+Kibana

Docker安装

这边根据官方文档:https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html 使用Docker安装了Elastic和Kibana

# 安装es
docker network create elastic
​
docker pull docker.elastic.co/elasticsearch/elasticsearch:8.12.1
​
docker run --name es01 --net elastic -p 9200:9200 -it -m 1GB docker.elastic.co/elasticsearch/elasticsearch:8.12.1
​
# 记录es的密码和注册kibana所需要的token
​
# 测试es是否正确运行
export ELASTIC_PASSWORD="es_your_password"
​
docker cp es01:/usr/share/elasticsearch/config/certs/http_ca.crt .
​
curl --cacert http_ca.crt -u elastic:$ELASTIC_PASSWORD https://localhost:9200
​
# 安装kibana
docker pull docker.elastic.co/kibana/kibana:8.12.1
​
docker run --name kib01 --net elastic -p 5601:5601 docker.elastic.co/kibana/kibana:8.12.1
​
会给出kibana的注册地址,访问填入上述记录的token即可。
​

不知道是机器性能问题还是Docker安装的问题,es容器经常会挂掉。

RPM安装

根据https://www.elastic.co/guide/en/elasticsearch/reference/current/rpm.html、https://www.elastic.co/guide/en/kibana/current/rpm.html官方文档,可以yum install安装。因为公司访问镜像源被封,因此使用上述文档中下载rpm安装:

# 安装es
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.12.1-x86_64.rpm
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.12.1-x86_64.rpm.sha512
shasum -a 512 -c elasticsearch-8.12.1-x86_64.rpm.sha512 
sudo rpm --install elasticsearch-8.12.1-x86_64.rpm
​
安装kibana
wget https://artifacts.elastic.co/downloads/kibana/kibana-8.12.1-x86_64.rpm
wget https://artifacts.elastic.co/downloads/kibana/kibana-8.12.1-x86_64.rpm.sha512
shasum -a 512 -c kibana-8.12.1-x86_64.rpm.sha512 
sudo rpm --install kibana-8.12.1-x86_64.rpm

依然在安装es的rpm时,会吐出es/kibana的密码:

The generated password for the elastic built-in superuser is : Fq*S7jxCjFfPu6nN8NG8

es服务可能启动不了,但是安装时会给出启动命令:

 sudo systemctl daemon-reload
 sudo systemctl enable elasticsearch.service

测试es启动是否正常:

export ELASTIC_PASSWORD="Fq*S7jxCjFfPu6nN8NG8"
curl --cacert /etc/elasticsearch/certs/http_ca.crt -u elastic:$ELASTIC_PASSWORD https://localhost:9200

记得改下配置文件,使其监听在0.0.0.0上面:

# /etc/elasticsearch/elasticsearch.yml
​
# Allow HTTP API connections from anywhere
# Connections are encrypted and require user authentication
http.host: 0.0.0.0
​
# Allow other nodes to join the cluster from anywhere
# Connections are encrypted and mutually authenticated
transport.host: 0.0.0.0

kibana一样,记得改下配置文件,使其监听在0.0.0.0上面:

# /etc/kibana/kibana.yml
server.host: "0.0.0.0"

安装Fleet和Elastic Agent

在Kibana上,Management->Fleet->Add Fleet Server,先安装Fleet Server,URL填写https协议,端口可以填默认的8220。装好Fleet Server后再装Elastic Agent,Fleet Server也是一个Agent,因此不能在同一台机器上同时装Fleet Server和Elastic Agent。

甲方安全建设之日志采集实操干货

为了使其Elastic Agent附带Security能力,可以添加各式各样的integrations集成,如到Security->Manage->Get started->Add security integrations安装安全集成:

甲方安全建设之日志采集实操干货

甲方安全建设之日志采集实操干货

测试告警

注意,如果有如下错误需解决,否则会无法查阅规则:

甲方安全建设之日志采集实操干货

甲方安全建设之日志采集实操干货

【----帮助网安学习,以下所有学习资料免费领!加vx:dctintin,备注 “博客园” 获取!】

 ① 网安学习成长路径思维导图
 ② 60+网安经典常用工具包
 ③ 100+SRC漏洞分析报告
 ④ 150+网安攻防实战技术电子书
 ⑤ 最权威CISSP 认证考试指南+题库
 ⑥ 超1800页CTF实战技巧手册
 ⑦ 最新网安大厂面试题合集(含答案)
 ⑧ APP客户端安全检测指南(安卓+IOS)

有些规则没开,记得开下,比如我把reverse shell规则打开后:Security->Dashboards->Detection & Response可以看到一些概览:

甲方安全建设之日志采集实操干货

记录Windows事件管理器日志

安装

Windows事件管理器日志不是单纯的文本,因此需要借助一些工具来帮助我们完成采集的目的。这里使用winlogbeat(https://www.elastic.co/cn/beats/winlogbeat)完成。官方提供了很详细的安装文档(https://www.elastic.co/guide/en/beats/winlogbeat/current/winlogbeat-installation-configuration.html),核心就是配置想要记录的日志类型和对外传输的方案,这里我使用的方案为:

  1. 记录的日志类型,我没改,默认就是Security、Application,甚至还有Sysmon

  2. 对外传输,我使用了传输到elastic

配置好winlogbeat.yml后可以进行测试配置文件对不对:

.\winlogbeat.exe test config -c .\winlogbeat.yml -e

下面为我的配置文件信息:

###################### 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, id, xml_query, tags, fields, fields_under_root,
# forwarded, ignore_older, level, event_id, provider, and include_xml.
# The xml_query key requires an id and must not be used with the name,
# ignore_older, level, event_id, or provider keys. 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
​
  - name: Microsoft-Windows-Sysmon/Operational
​
  - name: Windows PowerShell
    event_id: 400, 403, 600, 800
​
  - name: Microsoft-Windows-PowerShell/Operational
    event_id: 4103, 4104, 4105, 4106
​
  - name: ForwardedEvents
    tags: [forwarded]
​
# ====================== Elasticsearch template settings =======================
​
setup.template.settings:
  index.number_of_shards: 1
  #index.codec: best_compression
  #_source.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 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 dashboard archive. By default, this URL
# has a value that 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.
  hosts: ["your_ip:9200"]
​
  # Protocol - either `http` (default) or `https`.
  #protocol: "https"
​
  # Authentication credentials - either API key or username/password.
  #api_key: "id:api_key"
  username: "elastic"
  password: "passwords"
​
  # Pipeline to route events to security, sysmon, or powershell pipelines.
  pipeline: "winlogbeat-%{[agent.version]}-routing"
​
# ------------------------------ 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 outputs 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
​
​

数据检索

这时候,可能elastic上面搜不到数据,是因为winlogbeat使用了他自己的索引,默认为winlogbeat-version,笔者测试时,发现kibana上迟迟出现不了该索引,还以为数据传输没成功呢,因此通过如下手段进行排查,先获取es上面的索引信息:

http://your_ip:9200/_cat/indices?v

发现有类似winlogbeat的索引信息:

yellow open   .ds-winlogbeat-8.12.0-2024.02.03-000001   UpWhWCpdR-2WgMVe_kiH9A   1   1     192705            0    131.1mb        131.1mb
​

后面尝试在kibana上创建一个新的索引即可,v7.17.12版本的kibana创建索引的过程如下:discover->选项->View Discover settings

甲方安全建设之日志采集实操干货

找到“索引模式”创建一个新的索引即可:

甲方安全建设之日志采集实操干货

甲方安全建设之日志采集实操干货

这时候就可以检索事件管理器日志了:

甲方安全建设之日志采集实操干货

更多网安技能的在线实操练习,请点击这里>>

  文章来源地址https://www.toymoban.com/news/detail-844386.html

  

到了这里,关于甲方安全建设之日志采集实操干货的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 网络安全面试题整理——甲方类(含答案解析)

    以下是对目前部分热门的甲方面试/笔试题(偏管理和运营)的总结和思考,希望可以帮助到正在准备甲方面试的你们; 愿我们披荆斩棘,享受前进路上的每一处风景 1. 简述一下目前主流编程语言的相关漏洞 答:这个题的相关思路就是聊一聊目前主流语言的漏洞,你可以从两

    2024年02月08日
    浏览(42)
  • 【实操干货】如何开始用Qt Widgets编程?(三)

    Qt 是目前最先进、最完整的跨平台C++开发工具。它不仅完全实现了一次编写,所有平台无差别运行,更提供了几乎所有开发过程中需要用到的工具。如今,Qt已被运用于超过70个行业、数千家企业,支持数百万设备及应用。 在本文中,我们通过使用C++和Qt Widgets模块实现一个简

    2024年02月11日
    浏览(39)
  • 【实操干货】如何开始用Qt Widgets编程?(二)

    Qt 是目前最先进、最完整的跨平台C++开发工具。它不仅完全实现了一次编写,所有平台无差别运行,更提供了几乎所有开发过程中需要用到的工具。如今,Qt已被运用于超过70个行业、数千家企业,支持数百万设备及应用。 在本文中,我们通过使用C++和Qt Widgets模块实现一个简

    2024年02月13日
    浏览(30)
  • 巧用ChatGPT编写万字长文的论文,纯干货实操

    文 / 韩彬(微信公众号:量子论) 用ChatGPT写文章属于它的基本操作了,现在我们看看如何使用ChatGPT编写论文级的文章。 论文的编写步骤通常有这四步: 1、定主题 2、写提纲 3、填内容 4、改标题(可选项) 这几点其实可以运用于我们对ChatGPT的操作。 这里面有个小技巧,建

    2024年02月01日
    浏览(33)
  • 华为 1+X 网络系统运维与建设中级实操模拟题

    目 实验拓扑 配置中的注意事项:(针对新手) 实验目的 实验要求 实验步骤 一、搭建实验拓扑 二、配置主机名称 三、配置链路聚合 四、VLAN 配置 五、配置 RSTP 协议 六、配置 IP 地址 七、配置 VRRP 协议。 八、配置 OSPF 协议 九、配置 PAP 和 CHAP 认证 十、配置静态路由 十一、

    2024年02月05日
    浏览(37)
  • 【数据中台建设系列之二】数据中台-数据采集

    ​ 【数据中台建设系列之二】数据中台-数据采集 上篇文章介绍了数据中台的元数据管理,相信大家对元数据模块的设计和开发有了一定的了解,本编文章将介绍数据中台另一个重要的模块—数据采集。 一、什么是数据采集 数据采集简单来说就是从各种数据源中抓取、捕获

    2024年02月08日
    浏览(36)
  • 数据通讯平台建设方案(物联网数据采集平台)

    软件开发全资料获取:软件项目开发全套文档下载_软件项目技术实现文档-CSDN博客 对不同的数据协议、数据模式进行采集适配。基于XX智慧平台统一数据交换标准,与第三方系统对接,实现数据交换;实现不同场景中的在线监测仪表以及其他物联传感设备的通讯和数据交换。

    2024年02月01日
    浏览(27)
  • Linux日志收集实操实验命令(保姆级)

    ♥️ 作者:小刘在C站 ♥️ 个人主页: 小刘主页 ♥️ 每天分享云计算网络运维课堂笔记,努力不一定有回报,但一定会有收获加油!一起努力,共赴美好人生! ♥️ 夕阳下,是最美的绽放,树高千尺,落叶归根人生不易,人间真情 目录 修改主机名:efk 1.安装elasticsearch

    2023年04月09日
    浏览(38)
  • B站基于Clickhouse的下一代日志体系建设实践

    01 背景介绍 日志作为线上定位问题排障的重要手段,在可观测领域有着不可替代的作用。 稳定性、成本、易用性、可扩展性都是日志系统需要追求的关键点。 B站基于Elastic Stack的日志系统(Billions) 从2017建设以来, 已经服务了超过5年,目前规模超过500台机器,每日写入日

    2024年02月05日
    浏览(68)
  • 1、电商数仓(用户行为采集平台)数据仓库概念、用户行为日志、业务数据、模拟数据、用户行为数据采集模块、日志采集Flume

    数据仓库( Data Warehouse ),是为企业制定决策,提供数据支持的。可以帮助企业,改进业务流程、提高产品质量等。 数据仓库的输入数据通常包括:业务数据、用户行为数据和爬虫数据等。 业务数据:就是各行业在处理事务过程中产生的数据。比如用户在电商网站中登录、

    2024年02月12日
    浏览(33)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包