• Stars
    star
    158
  • Rank 237,131 (Top 5 %)
  • Language Jinja
  • License
    BSD 2-Clause "Sim...
  • Created over 8 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Ansible role to harden windows system

Appveyor - Master Appveyor - Devel

Windows harden ansible role

Ansible role to harden windows system.

  • install EMET, Powershell v5
  • LSA hardening, review javascript/hta file association
  • review log settings, enabling command-line, powershell and WMI logging
  • try to harden adobe reader, flash
  • basic application firewall blocks

ATTENTION! It's a work in progress. Pay attention to test carefully role and fit to your context unless you want to lock yourself. This role is continuous development as security landscape is constantly evolving.

Legal disclaimer! Depending on settings, very detailed activity log can be created. Only apply to your own system else for most countries (ex: Europe), user must have been warned and agreed (usually through internal policy, code of conduct...)

Requirements & Dependencies

Ansible

It was tested on the following versions:

  • 2.0 (min required for Win)
  • 2.2
  • 2.3 (required for testing part - become_method: runas)
  • 2.4 (required since s/include:/include_tasks:/)
  • 2.5

Operating systems

Tested with vagrant on Ubuntu 14.04 and 16.04. Only tested against Win10 and Ws2016 Evaluation. Follow http://kitchen.ci/blog/test-kitchen-windows-test-flight-with-vagrant/

Example Playbook

Just include this role in your list. For example

- host: all
  roles:
    - juju4.harden-windows

Run

$ ansible -i inventory -m win_ping win --ask-pass
$ ansible-playbook -i inventory --limit win site.yml

Variables

Sample. See defaults/main.yml for full scope

harden_eventlogs_maxsize: 314572

Continuous integration

This role has a travis basic test (for github, syntax check only) and a Vagrantfile (test/vagrant).

$ cd /path/to/roles/juju4.harden-windows/test/vagrant
$ vagrant up
$ vagrant provision
$ vagrant destroy
$ ansible -i .vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory -m win_ping -e ansible_winrm_server_cert_validation=ignore -e ansible_ssh_port=55986 all

Role has also a packer config which allows to create image for virtualbox and vmware based on https://github.com/jonashackt/ansible-windows-docker-springboot/, https://github.com/boxcutter/windows and https://github.com/gusztavvargadr/packer. Plan for about 50GB of free disk space and 1h to build one image.

$ cd /path/to/packer-build
$ cp -Rd /path/to/juju4.harden-windows/packer .
## update packer-*.json with your current absolute ansible role path for the main role
$ cd packer
$ packer build *.json
$ packer build -only=virtualbox-iso *.json
## if you want to enable extra log
$ PACKER_LOG_PATH="packerlog.txt" PACKER_LOG=1 packer build *.json
# for Azure, ensure you download and setup connection plugin. Default is for v2.6, Sep 2018
$ . ~/.azure/credentials
$ packer build azure-windows_server_2016.json
$ packer build -var-file=variables.json azure-windows_server_2016.json

See also

Troubleshooting & Known issues

  • Ensure you follow ansible guide to be able to connect http://docs.ansible.com/ansible/intro_windows.html

  • 'The property 'changed' cannot be found on this object. Verify that the property exists and can be set.' ansible/ansible#17139 Ansible bug in 2.1.1, ok in 2.0.1 and 2.1.2

  • AdobeReader chocolatey install issue

  • most windows module in ansible are not idempotent

  • Ansible win_firewall_rule module does not seem mature enough currently, especially if using non-english windows. Consider it experimental

  • ConnectTimeout: HTTPSConnectionPool(host='192.168.1.1', port=5986): Max retries exceeded with url: /wsman (Caused by ConnectTimeoutError(<requests.packages.urllib3.con) ansible/ansible#16460

  • packer build sometimes fails

==> virtualbox-iso: Deleting output directory...
Build 'virtualbox-iso' errored: Error uploading VirtualBox version: Error restoring file from $env:TEMP\winrmcp-affcbaf4-440e-481f-7ea4-16ae1b0b7121.tmp to .vbox_version: restore operation returned code=16001

Restarting is usually enough. Normally addressed per https://github.com/jonashackt/ansible-windows-docker-springboot/commit/89ad651fb7a79ee98b12ea0d5718727a5926ef9e

==> virtualbox-iso: Deleting output directory...
Build 'virtualbox-iso' errored: Error uploading VirtualBox version: Error restoring file from $env:TEMP\winrmcp-a6ac9db9-7493-4131-788d-23bfef94da3d.tmp to .vbox_version: unknown error Post http://127.0.0.1:3233/wsman: EOF

Same, restarting is usually enough. StefanScherer/packer-windows#21 It also sometimes stall on Waiting for WinRM to become available... ==> just stop it and restart

FAQ

Extra read

Thanks

Thanks to the many people who share books, tweets, scripts or other OSINT that contributed directly or not inside this role. Infosec community is GREAT!

License

BSD 2-clause

More Repositories

1

ansible-harden

harden system (linux, unix...)
Shell
50
star
2

ansible-MISP

ansible role to setup MISP, Malware Information Sharing Platform & Threat Sharing
Ruby
48
star
3

ansible-falco

Ansible role to setup Falco, behavioral security with sysdig
Jinja
35
star
4

ansible-ipv6

A simple ansible role to either harden, either disable ipv6 in linux systems
Ruby
28
star
5

ansible-lxd

Ansible role to setup LXD, its bridge, pre-copy images and eventually pre-configure some
Jinja
26
star
6

ansible-macos-apps-install

setup a list of mac applications be it dmg or pkg format.
Shell
21
star
7

ansible-auditd

setup and configure linux auditd
Jinja
19
star
8

ansible-cuckoo-sandbox

Cuckoo sandbox ansible role
Jinja
16
star
9

ansible-gpgkey_generate

simple ansible role to generate gpg keys automatically and with sane secure defaults
Ruby
16
star
10

ansible-zeek

setup zeek, previously Bro IDS
Jinja
15
star
11

ansible-mhn

Modern Honey Network deployment with ansible
Shell
12
star
12

ansible-harden-darwin

Ansible role to harden darwin/macos system
Jinja
10
star
13

ansible-firefox-config

Set up firefox configuration
Jinja
9
star
14

ansible-sysmon

Install and configure Sysmon for Linux
Jinja
8
star
15

ansible-adduser

simple ansible role to add a unix user with its ssh key
Shell
7
star
16

ansible-bind

ansible role to setup Bind/Named DNS server with sane secure default.
Ruby
7
star
17

ansible-squid

setup Squid proxy
Ruby
7
star
18

ansible-siftrem

SIFT & Remnux deployment with ansible
Ruby
7
star
19

ansible-win-atomic-red-team

Install, run Atomic Red Team with ansible
PowerShell
7
star
20

ansible-remnux

Remnux deployment with ansible
Shell
6
star
21

ansible-grr

Ansible role to setup GRR Rapid Response
Ruby
6
star
22

ansible-win-osquery

Windows osquery setup
Jinja
5
star
23

ansible-win-ad-monitor

Windows AD monitor ansible role
PowerShell
5
star
24

ansible-kolide

setup kolide, osquery central console
Ruby
5
star
25

ansible-harden-mailserver

Ansible role to harden mailserver system
Ruby
4
star
26

ansible-harden-apache

Ansible role to harden Apache2 webserver.
Jinja
4
star
27

ansible-dnscrypt-proxy

Allow to encrypt dns traffic to a central dns server in order to provide better privacy.
Shell
4
star
28

ansible-pandora

Setup pandora server, an analysis framework to discover if a file is suspicious and conveniently show the results.
Jinja
3
star
29

ansible-observium

setup observium community
Shell
3
star
30

ansible-chrome-config

Set up chrome configuration
Jinja
3
star
31

ansible-sift

SIFT deployment with ansible
Shell
3
star
32

ansible-golang

Ansible role to install go compiler from Google Archive
Shell
3
star
33

ansible-win-aptsimulator

Install, run NextronSystems APTSimulator with ansible
PowerShell
3
star
34

ansible-icinga2

setup Icinga2 server with optional plugins like pnp4nagios, graphite or nagvis
Jinja
3
star
35

ansible-win-applocker

Configure Windows AppLocker with ansible
Jinja
3
star
36

osquery-baseline

Osqueryd Baseline - InSpec Profile
Ruby
3
star
37

ansible-monclient

setup system as a monitored client including snmpd, nrpe+plugins
Perl
2
star
38

ansible-mde

Setup Microsoft Defender for Endpoint
Jinja
2
star
39

ansible-memcapture

simple ansible role to install and execute live memory capture tools
Ruby
2
star
40

ansible-gift

“Glorious Incident Feedback Tools” team ppa ansible role
Shell
2
star
41

ansible-snmpd

SNMPd ansible role
Jinja
2
star
42

ansible-xrdp

xrdp server, free and open-source implementation of Microsoft RDP server
Jinja
2
star
43

ansible-caldera

setup MITRE CALDERA automated adversary emulation system
Shell
2
star
44

ansible-mhnclient

Ansible role to setup a MHN client
Jinja
2
star
45

ansible-viewfinderjs

Install Remote Browser Isolation ViewFinderJS
Jinja
2
star
46

ansible-harden-systemd

Enforce stricter settings for services/daemons using various systemd security options.
Jinja
2
star
47

ansible-upgrade-pkgs

upgrade system with packaging system with relevant post-actions
Shell
2
star
48

ansible-brim

Brimsec Brim, an open source desktop application for security and network specialists
2
star
49

ansible-lxdconfigure

Ansible role to pre-copy images and eventually pre-configure some
Shell
2
star
50

ansible-macos-sleepwatcher

Ansible role to setup sleepwatcher on macOS
Shell
2
star
51

ansible-openvpnclient

setup openvpn as client
Jinja
2
star
52

ansible-timesketch

Ansible role to setup TimeSketch and Plaso for Disk images Forensics Timeline
Ruby
2
star
53

azure-policy-playground

play with azure-policy
2
star
54

ansible-mig

Ansible role to setup MIG aka Mozilla InvestiGator
Ruby
2
star
55

mde-baseline-ansible

Microsoft Defender for Endpoint (MDE) Ansible baseline
2
star
56

ansible-harden-nginx

Ansible role to harden nginx webserver.
Jinja
2
star
57

ansible-zentral

Zentral, framework to gather, process, and monitor system events and link them to an inventory
Ruby
2
star
58

ansible-win-sysmon

Configure Windows Sysmon with ansible
Jinja
2
star
59

ansible-win-firewall

Configure Windows Firewall with ansible
PowerShell
2
star
60

ansible-harden-sysctl

Ansible role to harden linux sysctl settings
Shell
2
star
61

ansible-fact

setup The Firmware Analysis and Comparison Tool
Jinja
1
star
62

ansible-jenkinsslave

Ansible role to setup Jenkins Slave (ssh)
Shell
1
star
63

ansible-tinyproxy

Setup tinyproxy
Jinja
1
star
64

macos-baseline

Macos hardening baseline for Inspec
Ruby
1
star
65

ansible-win-powershell

Configure Windows Powershell security with ansible
PowerShell
1
star
66

ansible-wef

DetectionLab Windows WEF
PowerShell
1
star
67

ansible-fileserver

build samba or nfs fileserver
Jinja
1
star
68

ansible-rekall

setup Rekall Memory Forensic Framework
Ruby
1
star
69

ansible-elk4dfir

setup ELK (v5.x) in Data Forensics Incident Response mode
Ruby
1
star
70

ansible-scumblr

Ansible role to setup Netflix scumblr
Ruby
1
star
71

ansible-ail-framework

CIRCL AIL framework ansible role
Jinja
1
star
72

ansible-vivisect

Ansible role to setup Vivisect, static analysis / emulation / symbolik analysis framework
Shell
1
star
73

ansible-win10

DetectionLab Windows Win10
PowerShell
1
star
74

ansible-logger

DetectionLab linux logger
HTML
1
star
75

syslog-baseline

Syslogd Baseline - InSpec Profile
Ruby
1
star
76

ansible-nrpeclient

NRPE ansible role
Jinja
1
star
77

ansible-sketchy

Ansible role to setup Netflix sketchy
Shell
1
star
78

ansible-jenkins

Ansible role to setup jenkins with java
Ruby
1
star
79

ansible-apt-cacher-ng-client

setup system as apt-cacher-ng client
Shell
1
star
80

ansible-hashlookupserver

Install hashlookup-server, minimal and fast open source server (ReST/API) to lookup quickly hash value from large datase t.
Jinja
1
star
81

ansible-loki

simple ansible role to execute loki, a Simple IOC and Incident Response Scanner
Ruby
1
star
82

ansible-caldera-agent

setup MITRE Caldera agent on windows
PowerShell
1
star
83

azure-testing

Azure testing with ansible
Jinja
1
star
84

auditd-baseline

Auditd Baseline - InSpec Profile
Ruby
1
star
85

ansible-harden-ima

Configure Linux kernel's Integrity Measurement Architecture (IMA)
Shell
1
star
86

ansible-w3af

w3af web scanner ansible role
Jinja
1
star
87

ansible-vector

Ansible role to setup Vector, on-host performance monitoring framework
Shell
1
star
88

ansible-dc

DetectionLab Windows DC
PowerShell
1
star
89

ansible-jira2

meta role to setup Jira in a sane and secure environment
Ruby
1
star
90

ansible-cartography

Setup cartography server, a Python tool that consolidates infrastructure assets and the relationships between them in an intuitive graph view powered by a Neo4j database.
Jinja
1
star
91

ansible-cribl

Setup cribl
Jinja
1
star