Home

Awesome

Goal of the project

Automated deployment of Windows and Active Directory test lab networks. Useful for red and blue teams.

During red teaming gigs we encounter many different setups at our clients. To test our payloads and to review our artefacts we need a lab that allows us to quickly deploy Windows OS version X with Office version Y, in a fully working AD and a network setup that has separate broadcast segments. Invoke-ADLabDeployer does the heavy lifting. From there on you can easily tune to your exact liking, e.g. create specific GPO’s, install extra software, and make any other final tuning for the setup that you need.

Invoke-ADLabDeployer relies heavily on techniques like Hyper-V, sysprep and (remote) Powershell for the deployment and configuration.

There are other projects out there that do similar things. But Invoke-ADLabDeployer has support for all Windows OS versions currently encountered at clients, specifically support for Win7 and Server2008R2, while keeping resource usage low by using smart Hyper-V tricks like differencing disks, dynamic memory, etc. More background info and reasoning why this script has added value over others as well as over Azure here

Running the script

There is no quick starting with this script. You really need to have parent images pre-created.

If you are sure you meet all the requirements and have done all the preparations, you can run it using:

Import: Import-Module .\Invoke-ADLabDeployer.ps1

Start deployment: Invoke-ADLabDeployer -LabConfigFile configs\labs_config.xml -Name demolab -Verbose

The -Verbose tag will give you handy status reports.

Example output can be found here.

Test the config file: Invoke-ADLabDeployer -LabConfigFile configs\labs_config.xml -Name demolab -CheckConfigOnly

Have the config returned into local hashtables: $return_net,$return_sys,$return_adds = Invoke-ADLabDeployer -LabConfigFile configs\labs_config.xml -Name demolab -CheckConfigOnly

Example output can be found here

Flow of script

On a generic level, the following tasks are performed:

Requirements

You need the following:

Creating the parent images

Lab config file

The script needs a config file to know what it needs to deploy. Ive included an example lab_config.xml file. It should be rather self explanatory, but you can find more detailed info below.

The config file can have multiple labs defined. The -Name parameter to Invoke-ADLabDeployer defines the actual lab to deploy. Also, the -CheckConfigOnly parameter can help you with, well, checking the config. Per lab name you define the other sections you can find below. But on a general level you can have a config like:

<Labs>
	<Lab LabName="TestLab">
	</Lab>
	<Lab LabName="OtherTestLab">
	</Lab>	
	<Lab LabName="FooBar">
	</Lab>	
</Labs> 

Config file parameters - Network

This defined the network sections. This is mandatory. You can have multiple sections of this. Example:

<Network NetName="net1">
	<Subnet>10.202.1.0/24</Subnet>
	<GW>10.202.1.1</GW>
</Network>

Config file parameters - Active Directory

This defines the Active Directory section. This is not mandatory. You can have multiple sections of this. Example:

<ADDS ADDSName="BreakMe.local">
	<ParentDomain>.</ParentDomain>
	<PDC>server1</PDC>
	<SafeModeAdminPass>Outflank123</SafeModeAdminPass>
</ADDS>

Config file parameters - System

This defines a system. This is mandatory. You can have multiple sections of this. Example:

<System Hostname="server1">
	<OS>windows2012R2x64</OS>
	<UnattendFile>unattend\unattend.win2012R2.xml</UnattendFile>
	<LocalCreds>outflank:Outflank123</LocalCreds>
	<ParentDisk>parent-en_windows_server_2012_r2_essentials_with_update_x64_dvd_6052824-updated201704</ParentDisk>
	<Net1_Name>net1</Net1_Name>
	<Net1_IP>10.202.1.11/24</Net1_IP>
</System>
<System Hostname="client3">
	<OS>windows7x64</OS>
	<UnattendFile>unattend\unattend.win7.xml</UnattendFile>
	<LocalCreds>ted:Outflank123</LocalCreds>
	<ParentDisk>parent-en_windows_7_enterprise_n_with_sp1_x64_dvd_u_677704-updated201801</ParentDisk>
	<Net1_Name>net2</Net1_Name>
	<Net1_IP>10.202.2.13/24</Net1_IP>
	<Mem>4GB</Mem>
	<Win_Update>True</Win_Update> 
	<Domain>BreakMe.local</Domain>
	<RDP_Allow>True</RDP_Allow>	
	<OfficeInstaller>Office16x64\setup.exe</OfficeInstaller>
	<OfficeConfig>Office16x64\config.xml</OfficeConfig>
	<SW_JustCopy>somefile.bin</SW_JustCopy>	
	<SW_Install>Chrome\googlechromestandaloneenterprise.msi</SW_Install>
	<SW_Install>7z\7z1801-x86.msi</SW_Install>
	<SW_Install>npp\npp.7.5.0.installer.x86.msi</SW_Install>			
</System>

Directory structure

This repo and script uses the following directory structure, which is recommended to adhere to as some paths may be hardcoded:

Known bugs and caveats

Features on todo-list

Author

This project is developed and maintained by Marc Smeets (@smeetsie on github, and @mramsmeets on Twitter).

License

This project is made available uner the BSD 3.0 license. This means: Copyright 2018 Outflank B.V.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.