1. elastic부터 

elk 설치 메뉴얼: https://www.elastic.co/guide/en/elastic-stack-get-started/7.2/get-started-elastic-stack.html#install-elasticsearch

 

Getting started with the Elastic Stack | Getting Started [7.2] | Elastic

If you don’t see data in Kibana, try changing the date range to a larger range. By default, Kibana shows the last 15 minutes. If you see errors, make sure Metricbeat is running, then refresh the page.

www.elastic.co

간편하게 rpm으로 설치함

 

# curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.2.0-x86_64.rpm
# sudo rpm
-i elasticsearch-7.2.0-x86_64.rpm
# sudo service elasticsearch start

 

데몬 시작하기전 elastic config 파일 수정

기본적인것들을 설정해주었다. 단일 서버에 테스트로 설치하는거라 호스트는 하나만 넣었다.

# vim /etc/elasticsearch/elasticsearch.yml

cluster.name: leopit
node.name: leopit

network.host: 10.10.10.10
http.port: 9200
discovery.seed_hosts: ["10.10.10.10"]
cluster.initial_master_nodes: ["leopit"]

정상 작동 확인

# curl http://127.0.0.1:9200

{ "name" : "leopit", "cluster_name" : "leopit", "cluster_uuid" : "XEHE2JYETNCh5A-ifq8bmQ", "version" : { "number" : "7.2.0", "build_flavor" : "default", "build_type" : "rpm", "build_hash" : "508c38a", "build_date" : "2019-06-20T15:54:18.811730Z", "build_snapshot" : false, "lucene_version" : "8.0.0", "minimum_wire_compatibility_version" : "6.8.0", "minimum_index_compatibility_version" : "6.0.0-beta1" }, "tagline" : "You Know, for Search" }

 

2. kibana

# curl -L -O https://artifacts.elastic.co/downloads/kibana/kibana-7.2.0-linux-x86_64.tar.gz tar xzvf kibana-7.2.0-linux-x86_64.tar.gz
# cd kibana
-7.2.0-linux-x86_64/
# ./bin/kibana

 

kibana 데몬 실행전 컨피그 파일 설정

# vim kibana-7.2.0-linux-x86_64/config/kibana.yml

server.host: "10.10.10.10"
server.name: "leopit"
elasticsearch.hosts: ["http://10.10.10.10:9200"]

 

kibana는 UID가 root인 상태에서는 실행되지 않는다 일반 계정으로 변경해줘야함.

따라서 kibana 설치시 UID가 root인 상태에서 했다면 소유권 변경을 해줘야 함

 

# chown -R leopit kibana-7.2.0-linux-x86_64/*
# su leopit

# ./bin/kibana

 

소유권 변경후 실행하니 잘 되었다.

 

3. logstash

logstash는 sysmon 연동시엔 사용하지 않을거라 설치만 해두었다.

# curl -L -O https://artifacts.elastic.co/downloads/logstash/logstash-7.2.0.rpm
# sudo rpm
-i logstash-7.2.0.rpm

 

4. sysmon

sysmon 10.2 다운로드

https://docs.microsoft.com/en-us/sysinternals/downloads/sysmon

 

Sysmon - Windows Sysinternals

Monitors and reports key system activity via the Windows event log.

docs.microsoft.com

설정파일 다운로드

https://github.com/SwiftOnSecurity/sysmon-config

 

SwiftOnSecurity/sysmon-config

Sysmon configuration file template with default high-quality event tracing - SwiftOnSecurity/sysmon-config

github.com

설치

sysmon.exe -accepteula -i sysmonconfig-export.xml

 

5. winlogbeat

설치메뉴얼: https://www.elastic.co/guide/en/beats/winlogbeat/current/winlogbeat-installation.html

 

Step 1: Install Winlogbeat | Winlogbeat Reference [7.2] | Elastic

If script execution is disabled on your system, you need to set the execution policy for the current session to allow the script to run. For example: PowerShell.exe -ExecutionPolicy UnRestricted -File .\install-service-winlogbeat.ps1.

www.elastic.co

다운로드후 C:\ProgramFiles\에 Winlogbeat 이름으로 옮겨준다.

sysmon을 winlogbeat에 싫어야 하므로 winlogbeat 설정을 아래와 같이 추가해준다.

winlogbeat.yml 파일에 아래와 같이 sysmon 로깅 설정이 되어 있어야 한다. 

 

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

 

설정 완료후 powershell을 관리자 권한으로 실행시켜 아래와 같이 서비스 등록을 해준다.

PS C:\Users\Administrator> cd 'C:\Program Files\Winlogbeat'
PS C:\Program Files\Winlogbeat> .\install-service-winlogbeat.ps1

Security warning
Run only scripts that you trust. While scripts from the internet can be useful,
this script can potentially harm your computer. If you trust this script, use
the Unblock-File cmdlet to allow the script to run without this warning message.
Do you want to run C:\Program Files\Winlogbeat\install-service-winlogbeat.ps1?
[D] Do not run  [R] Run once  [S] Suspend  [?] Help (default is "D"): R

Status   Name               DisplayName
------   ----               -----------
Stopped  winlogbeat         winlogbeat

<TIP> PSSecurityException 에러가 발생할 경우 신뢰하지 않는 스크립트 보호 설정 변경하여 해결
> Set-ExecutionPolicy RemoteSigned 

 

winlogbeat 템플릿 elasticsearch, kibana에 적용

PS C:\Utils\winlogbeat-7.2.0-windows-x86\winlogbeat-7.2.0-windows-x86> .\winlogbeat.exe setup -e `
>> -E output.logstash.enabled=false `
>> -E output.elasticsearch.hosts=['10.10.10.10:9200'] `
>> -E setup.kibana.host=10.10.10.10:5601

> Start-Service winlogbeat

 

키바나에 접근해보니 sysmon 로그가 파싱되어 저장된다.

- Discover 

- sysmon log

+ Recent posts