Coder Social home page Coder Social logo

juju4 / ansible-harden-windows Goto Github PK

View Code? Open in Web Editor NEW
162.0 14.0 47.0 1.02 MB

Ansible role to harden windows system

License: BSD 2-Clause "Simplified" License

PowerShell 7.69% Batchfile 2.32% Ruby 4.97% Python 6.00% Shell 1.11% Jinja 77.91%

ansible-harden-windows's Introduction

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

ansible-harden-windows's People

Contributors

dependabot[bot] avatar juju4 avatar maravedi avatar stefandeveloper avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ansible-harden-windows's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.