djm300 / ThreatWaffle

Threat hunting repo for my independent study on threat hunting with OSQuery

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ThreatWaffle

Threat hunting repo for my independent study on threat hunting with OSQuery.

Doorman or Kolide

This repo contains two branches which are Doorman and Kolide. Both are open source OSQuery fleet managers. Koide is used in the master branch.

Setup Windows Domain Controller

Setup domain

  1. mv group_vars/all.example group_vars/all
  2. Vim group_vars/all and set
    1. base_domain
  3. mv group_vars/win_dc.example group_vars/win_dc
  4. vim group_vars/win_dc and set:
    1. ad_domain_name(by default set base_domain)
    2. ad_safe_mode_password
  5. vim group_vars/windows and set :
    1. asnsible_user
    2. ansible_password
  6. vim hosts set:
    1. ip addr for [win_dc]
  7. ansible-playbook -i hosts deploy_windows_dc.yml
  8. Shutdown and create snapshot

Setup domain user(non-admin)

  1. Login into Windows DC
  2. Open server manager
  3. Select “Tools” then “Active Directory Users and Computers”
  4. Select “Users” on the left
  5. Select “Acton” then “New User”
    1. User info 2. Enter "Bill" for Firstname 2. Enter "Gates" for Last Name 2. Enter “Bgates” for logon
    2. Password 2. Enter a password for user 2. UNcheck “User must change password at next logon”
  6. Shutdown and create snapshot

Setup DNS entrie

  1. Open Server Manager
  2. Select "Tools" then "DNS"
  3. WinDC > Forward Lookup Zone > hackinglab.beer
  4. Select "Action" then "New Host(A)"
    1. Enter "graylog" for Name
    2. Enter "" for IP address
    3. Repeat for Kolide

Group policy settings

Enable RDP through firewall

  1. Open Group policy manager
  2. Right-click "Default Domain Policy"
  3. Computer Configuration > Policies > Administrative Templates > Network > Network Connections > Windows Firewall > Domain Profile
  4. Enable "Allow inbound Remote Desktop exceptions" and set IP addresses to "/"
  5. Computer Configuration > Policies > Administrative Templates, Network > Network Connections > Windows Firewall > Domain Profile
  6. Enable "Windows Firewall: Allow inbound Remote Desktop exceptions"

Powershell script block logging

  1. Computer Configuration > Policies > Administrative Templates -> Windows Components -> Windows PowerShell
  2. Enable "Turn on PowerShell Script Block Logging"

Process creation logging

  1. Computer Configuration > Windows Settings > Security Settings > Advanced Audit Policy Configuration > Audit Policies > > Detailed Tracking
  2. Enable for successful "Audit Process Creation"

SMB access via firewall

  1. Computer Configuration > Windows Settings > Security Settings > Windows Firewall with Advanced Security > Windows Firewall with Advanced Security LDAP
  2. Right-click "Inbound Rules" and select "New Rule"
    1. Select "Port" for rule type
    2. Select "TCP" for protocol and enter "445" for port
    3. Select "Allow the connection"
    4. Select all profiles
    5. Enter "Allow PSexec" for name

Setup Kolide OSQuery fleet manager

  1. openssl rand -base64 32
  2. Copy the output from above
  3. vim group_vars/kolide and set:
    1. kolide_jwt_key to output from above
    2. Set username and password for Kolide, MySQL
  4. vim group_vars/all and set
    1. timezone
    2. fleet_hostname
    3. base_domain
    4. Set information for certificate
    5. Slack (optional)
  5. vim hosts
    1. Set management IP address under [kolide]
  6. ansible-playbook -i hosts deploy_kolide.yml -u
  7. https://<Hostname/IP addr of Kolide>
    1. Setup through Kolide setup

Setup Graylog server

  1. vim group_vars/graylog and set
    1. graylog_admin_password
  2. vim hosts and set [graylog]
  3. ansible-playbook -i hosts deploy_graylog.yml -u superadmin

Deploy OSQuery agents

Initial setup

  1. Browse to https://<Hostname/IP addr of Kolide>
  2. Select "Add new host" in top right
  3. Select "Reveal secret" and copy the string
  4. vim group_vars/agents
    1. set osquery_enroll_secret with string from Kolide

Deploy Windows OSQuery agent

** Windows hosts must be WinRM ready for Ansible ** 0. Copy contents of /etc/nginx/ssl/kolide.crt for Kolide server 0. mv conf/agents/certificate.example conf/agents/certificate.crt 0. vim conf/agents/certificate.crt and paste the contents from above 0. mv group_vars/win_agents.example group_vars/win_agents 0. vim group_vars/win_agents and set: 1. ansible_user 1. ansible_password 0. vim hosts 1. Add hosts to win_agents 0. ansible-playbook -i hosts deploy_windows_osquery_agents.yml

Deploy Linux OSQuery agent

  1. vim hosts
    1. Add hosts to linux_agents 0.ansible-playbook -i hosts deploy_linux_osquery_agents.yml

Ansible setup - prod

  1. vim hosts and set [caldera]
  2. mv group_vars/all.example group_vars/all
  3. vim group_vars/all and set:
    1. base_domain
    2. caldera_pass
  4. Create a DNS entry on your DNS server for {{ caldera_pass }}.{{ base_domain }}
  5. ansible-playbook -i hosts deploy_caldera.yml -u

Ansible Kolide OS support

  • Ubuntu Server 16.04 64-bit

Resources/Sources

To do:

  • Set up Mac OSX deployment for OSQuery
  • Docker setup
  • Add DNS setup to DC

About

Threat hunting repo for my independent study on threat hunting with OSQuery