Resources

Commands

  • Elastic Search
    • Installation
      • LXC Requirements
         apt install gpg apt-transport-https net-tools unzip
      • Installation
        wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo gpg --dearmor -o /usr/share/keyrings/elasticsearch-keyring.gpg
        echo "deb [signed-by=/usr/share/keyrings/elasticsearch-keyring.gpg] https://artifacts.elastic.co/packages/9.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-9.x.list
         
        sudo apt-get update && sudo apt-get install elasticsearch
         
        sudo /bin/systemctl daemon-reload 
        sudo /bin/systemctl enable elasticsearch.service
      • out-of-memory (OOM) siutation
        sudo nano /etc/elasticsearch/jvm.options.d/heap.options
         
        -Xms1g
        -Xmx1g
         
         
        sudo systemctl daemon-reload 
        sudo systemctl start elasticsearch.service
      • Timing
        timedatectl
        sudo timedatectl set-timezone Africa/Cairo
        sudo timedatectl set-ntp true
  • Kibanna
    • Installation
      sudo apt-get install kibana
       
      sudo /bin/systemctl daemon-reload 
      sudo /bin/systemctl enable kibana.service
      sudo systemctl start kibana.service
    • Debugging
      sudo journalctl -u kibana.service -n 20 --no-pager
  • Fleet
    • Requirements
      • Kibanna server
        /usr/share/kibana/bin/kibana-encryption-keys generate # Copy the keys
        nano /etc/kibana/kibana.yml # Copy them here  
        systemctl restart kibana
    • installation
      curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.4.2-linux-x86_64.tar.gz
      tar xzvf elastic-agent-9.4.2-linux-x86_64.tar.gz
      cd elastic-agent-9.4.2-linux-x86_64
      sudo ./elastic-agent install \
        --fleet-server-es=https://10.10.30.10:9200 \
        --fleet-server-es-insecure \
        --fleet-server-service-token=AAEAAWVsYXN0aWMvZmxlZXQtc2VydmVyL3Rva2VuLTE3ODMxMTE2NDAwMjM6YjAzYXNZd2RRYldEdzdBbFltVmQzZw \
        --fleet-server-policy=fleet-server-policy \
        --fleet-server-port=8220 \
        --install-servers \
        --url=https://10.10.30.11:8220 \
        --force \
        -v
    • General
      sudo systemctl restart elastic-agent
  • Agents
    • Windows
      $ProgressPreference = 'SilentlyContinue' 
      Invoke-WebRequest -Uri https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.4.2-windows-x86_64.msi -OutFile elastic-agent-9.4.2-windows-x86_64.msi 
      .\elastic-agent-9.4.2-windows-x86_64.msi --% INSTALLARGS="--url=https://10.10.30.11:8220 --enrollment-token=cjBnbkxwOEJnOGdUWUZnLWpQZF86MmJWQ29VWG1hTVpWY0tpYmZid2ZsUQ== --insecure"
      • Services
        • Agent
          .\elastic-agent.exe inspect
        • Elastic
          Set-Service -Name "Elastic Agent" -StartupType Automatic
          Start-Service -Name "Elastic Agent"
          Restart-Service -Name "Elastic Agent"
          Get-Service "Elastic Agent"
        • Sysmon
          Get-Service -Name "Sysmon"
          Restart-Service -Name "Sysmon"
    • Linux
      curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.4.2-linux-x86_64.tar.gz 
      tar xzvf elastic-agent-9.4.2-linux-x86_64.tar.gz 
      cd elastic-agent-9.4.2-linux-x86_64 
      sudo ./elastic-agent install --url=https://10.10.30.11:8220 --enrollment-token=Rk1YTU5wOEJEbkVCNVliV1FNRTg6LUx4TUdzUlUwcENSbjhsWHZEN1d4dw== --insecure --force		
  • KQL Examples
    • Sysmon
      winlog.event_data.Hashes: * and winlog.event_data.Image: "C:\\Windows\\System32\\cmd.exe"
  • DevTools
    DELETE /_data_stream/logs-* # Clear Logs

Tools

Notes