├── LICENSE
├── Packer
├── ansible
│ └── roles
│ │ ├── Graphical
│ │ └── tasks
│ │ │ └── main.yml
│ │ └── apache
│ │ └── tasks
│ │ └── main.yml
├── floppy
│ ├── 10
│ │ ├── autounattend.xml
│ │ └── enable-winrm.bat
│ └── 2016
│ │ ├── autounattend.xml
│ │ └── enable-winrm.bat
└── http
│ ├── centos.cfg
│ ├── kali.cfg
│ └── ubuntu-preseed.cfg
├── README.md
├── VMs
└── placeholder
├── Vagrant
├── placeholder
└── scripts
│ ├── DeploymentConfigTemplate.xml
│ ├── Domain Controller.ps1
│ ├── Enable RDP.ps1
│ └── initialize-domain.ps1
└── lab-creator.py
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Brandon Rossi
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Packer/ansible/roles/Graphical/tasks/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: Install Desktop for Ubuntu
3 | become: yes
4 | apt:
5 | name: ubuntu-desktop
6 | state: latest
7 | when: ansible_distribution == "Ubuntu"
8 |
9 | - name: Install Desktop for Debian
10 | become: yes
11 | apt:
12 | name: task-gnome-desktop
13 | state: latest
14 | when: ansible_distribution == "Debian"
15 |
16 | - name: Install Desktop for CentOS
17 | become: yes
18 | yum:
19 | name:
20 | - "@development-tools"
21 | - "@^gnome-desktop-environment"
22 | - "@x11"
23 | state: latest
24 | when: ansible_distribution == "CentOS"
25 |
26 | - name: Set Gnome as Default
27 | become: yes
28 | shell:
29 | cmd: systemctl set-default graphical.target
--------------------------------------------------------------------------------
/Packer/ansible/roles/apache/tasks/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: ensure httpd is at the latest version
3 | become: yes
4 | yum:
5 | name: httpd
6 | state: latest
7 | when: ansible_distribution == "CentOS"
8 |
9 | - name: start httpd on boot
10 | become: yes
11 | systemd:
12 | name: httpd
13 | enabled: yes
14 | state: restarted
15 | when: ansible_distribution == "CentOS"
16 |
17 | - name: ensure apache is at the latest version
18 | become: yes
19 | apt:
20 | name: apache2
21 | state: latest
22 | when: ansible_distribution == "Ubuntu" or ansible_distribution == "Debian"
23 |
24 | - name: start apache on boot
25 | become: yes
26 | systemd:
27 | name: apache2
28 | enabled: yes
29 | state: restarted
30 | when: ansible_distribution == "Ubuntu" or ansible_distribution == "Debian"
--------------------------------------------------------------------------------
/Packer/floppy/10/autounattend.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | en-US
7 |
8 | en-US
9 | en-US
10 | en-US
11 | en-US
12 |
13 |
14 |
15 |
16 |
17 |
18 | 1
19 | 500
20 | Primary
21 |
22 |
23 | true
24 | 2
25 | Primary
26 |
27 |
28 |
29 |
30 | true
31 | NTFS
32 | 1
33 | 1
34 |
35 |
36 | NTFS
37 |
38 | C
39 | 2
40 | 2
41 |
42 |
43 | 0
44 | true
45 |
46 | OnError
47 |
48 |
49 |
50 |
51 | 0
52 | 2
53 |
54 |
55 |
56 |
57 |
58 | NPPR9-FWDCX-D2C8J-H872K-2YT43
59 |
60 | true
61 |
62 | Lab
63 |
64 |
65 |
66 |
67 |
68 | Win10
69 | true
70 | Lab
71 | Lab
72 | Eastern Standard Time
73 |
74 |
75 |
76 |
77 | en-US
78 | en-US
79 | en-US
80 | en-US
81 |
82 |
83 |
84 | true
85 | true
86 | true
87 | true
88 | 3
89 |
90 |
91 |
92 |
93 |
94 | conda
95 | true
96 |
97 | conda
98 | conda
99 | Administrators
100 | conda
101 |
102 |
103 |
104 |
105 |
106 | 1
107 | cmd.exe /c a:\enable-winrm.bat
108 | Set up winrm
109 | false
110 |
111 |
112 | 2
113 | powershell.exe Set-ExecutionPolicy RemoteSigned -Force
114 | Allow powershell scripts to run
115 | false
116 |
117 |
118 | 3
119 | powershell.exe /c a:\add-users.ps1
120 | Add user accounts
121 | false
122 |
123 |
124 | %SystemRoot%\System32\reg.exe ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AutoAdminLogon /t REG_SZ /d 0 /f
125 | 4
126 | Disable AutoLogon
127 | false
128 |
129 |
130 | %SystemRoot%\System32\reg.exe ADD "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f
131 | 5
132 | Enable RDP
133 | false
134 |
135 |
136 | %SystemRoot%\System32\reg.exe ADD HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ /v HideFileExt /t REG_DWORD /d 0 /f
137 | 6
138 | Show file extensions in Explorer
139 | false
140 |
141 |
142 | powershell.exe Disable-PSRemoting -Force
143 | 7
144 | Disable WinRM
145 | false
146 |
147 |
148 | cmd.exe /c "netsh advfirewall firewall add rule name="Open Port 3389" dir=in action=allow protocol=TCP localport=3389"
149 | 8
150 | Open Port 3389
151 | false
152 |
153 |
154 |
155 |
156 | conda
157 | true
158 |
159 | true
160 | 1
161 | conda
162 |
163 |
164 |
165 |
166 |
--------------------------------------------------------------------------------
/Packer/floppy/10/enable-winrm.bat:
--------------------------------------------------------------------------------
1 | rem basic config for winrm
2 | powershell.exe Set-NetConnectionProfile -Name "Network" -NetworkCategory Private
3 | cmd.exe /c winrm quickconfig -q
4 |
5 | rem allow unencrypted traffic, and configure auth to use basic username/password auth
6 | cmd.exe /c winrm set winrm/config/service @{AllowUnencrypted="true"}
7 | cmd.exe /c winrm set winrm/config/service/auth @{Basic="true"}
8 | cmd.exe /c winrm set winrm/config/client/auth '@{Basic="true"}'
9 |
10 | rem update firewall rules to open the right port and to allow remote administration
11 | cmd.exe /c netsh advfirewall firewall set rule group="remote administration" new enable=yes
12 |
13 | rem restart winrm
14 | cmd.exe /c net stop winrm
15 | cmd.exe /c net start winrm
--------------------------------------------------------------------------------
/Packer/floppy/2016/autounattend.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
8 |
9 | en-US
10 |
11 | 0c09:00000409
12 | en-US
13 | en-US
14 | en-US
15 | en-US
16 |
17 |
20 |
21 |
22 |
23 | 0
24 | 2
25 |
26 |
27 |
28 | /IMAGE/INDEX
29 | 2
30 |
31 |
32 |
33 |
34 |
35 | true
36 | conda
37 | Lab
38 |
39 |
40 |
41 | true
42 |
43 |
44 |
45 |
46 | 1
47 | 350
48 | Primary
49 |
50 |
51 | true
52 | 2
53 | Primary
54 |
55 |
56 |
57 |
58 | NTFS
59 |
60 | 1
61 | 1
62 | 0x27
63 |
64 |
65 | 2
66 | 2
67 | C
68 |
69 | NTFS
70 |
71 |
72 | 0
73 | true
74 |
75 |
76 |
77 |
78 |
79 |
82 | false
83 |
84 |
85 |
86 |
89 | 1
90 |
91 |
92 |
93 |
96 | 0409:00000409
97 | en-US
98 | en-US
99 | en-US
100 | en-US
101 |
102 |
105 | true
106 |
107 |
110 | 0
111 |
112 |
115 | Win2916
116 |
117 |
118 |
119 |
122 |
123 |
124 | Conda123!
125 | true
126 |
127 | true
128 | Administrator
129 |
130 |
131 | true
132 | true
133 | true
134 | true
135 | true
136 | Home
137 | 3
138 | true
139 | true
140 |
141 |
142 |
143 | Conda123!
144 | true
145 |
146 |
147 |
148 |
149 | 10
150 | cmd.exe /c a:\enable-winrm.bat
151 | Set up winrm
152 | false
153 |
154 |
155 | 1
156 | powershell.exe Set-ExecutionPolicy RemoteSigned -Force
157 | Allow powershell scripts to run
158 | false
159 |
160 |
161 | %SystemRoot%\System32\reg.exe ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AutoAdminLogon /t REG_SZ /d 0 /f
162 | 4
163 | Disable AutoLogon
164 | false
165 |
166 |
167 | %SystemRoot%\System32\reg.exe ADD "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f
168 | 5
169 | Enable RDP
170 | false
171 |
172 |
173 | %SystemRoot%\System32\reg.exe ADD HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ /v HideFileExt /t REG_DWORD /d 0 /f
174 | 6
175 | Show file extensions in Explorer
176 | false
177 |
178 |
179 | cmd.exe /c "netsh advfirewall firewall add rule name="Open Port 3389" dir=in action=allow protocol=TCP localport=3389"
180 | 8
181 | Open Port 3389
182 | false
183 |
184 |
185 |
186 | Administrator
187 | false
188 | Eastern Standard Time
189 |
190 |
191 |
--------------------------------------------------------------------------------
/Packer/floppy/2016/enable-winrm.bat:
--------------------------------------------------------------------------------
1 | rem basic config for winrm
2 | powershell.exe Set-NetConnectionProfile -Name "Network" -NetworkCategory Private
3 | cmd.exe /c winrm quickconfig -q
4 |
5 | rem allow unencrypted traffic, and configure auth to use basic username/password auth
6 | cmd.exe /c winrm set winrm/config/service @{AllowUnencrypted="true"}
7 | cmd.exe /c winrm set winrm/config/service/auth @{Basic="true"}
8 | cmd.exe /c winrm set winrm/config/client/auth '@{Basic="true"}'
9 |
10 | rem update firewall rules to open the right port and to allow remote administration
11 | cmd.exe /c netsh advfirewall firewall set rule group="remote administration" new enable=yes
12 |
13 | rem restart winrm
14 | cmd.exe /c net stop winrm
15 | cmd.exe /c net start winrm
--------------------------------------------------------------------------------
/Packer/http/centos.cfg:
--------------------------------------------------------------------------------
1 | #platform=x86, AMD64, or Intel EM64T
2 |
3 | # Install OS instead of upgrade
4 | install
5 |
6 | # Keyboard layouts
7 | keyboard --vckeymap=us --xlayouts='us'
8 |
9 | # Use network installation
10 | url --url="http://mirror.centos.org/centos/7/os/x86_64/"
11 |
12 | # System language
13 | lang en_US
14 |
15 | # Users
16 | user --groups=wheel --name=conda --password=conda --gecos="conda"
17 |
18 | # License agreement
19 | eula --agreed
20 |
21 | # Firewall configuration
22 | firewall --disabled
23 | repo --name="epel" --baseurl=http://download.fedoraproject.org/pub/epel/7/x86_64/
24 |
25 | # System authorization information
26 | auth --useshadow --passalgo=sha512
27 |
28 | # Use graphical install
29 | graphical
30 | firstboot --disable
31 |
32 | # SELinux configuration
33 | selinux --enforcing
34 |
35 | # System services
36 | services --enabled="network,sshd"
37 |
38 | # Network information
39 | network --bootproto=dhcp --hostname=centos7
40 |
41 | # Reboot after installation
42 | reboot
43 |
44 | # System timezone
45 | timezone America/New_York
46 |
47 | # System bootloader configuration
48 | autopart --type=lvm
49 | bootloader --append="crashkernel=auto" --location=mbr #--boot-drive=sda
50 | ignoredisk --only-use=sda
51 | clearpart --all --initlabel --drives=sda
52 | #%end
53 |
54 | %packages
55 | @core
56 | epel-release
57 | vim
58 | ansible
59 | %end
60 |
61 | %post
62 | # Update machine
63 | yum --nogpgcheck -y update
64 | echo "conda ALL=(ALL) NOPASSWD: ALL" | tee /etc/sudoers
65 | systemctl disable initial-setup-graphical.service # This is the only one neccessary to get rid of initial setup prompt
66 | systemctl disable initial-setup.service # These are just to make sure nothing else comes up either
67 | systemctl disable initial-setup-text.service
68 | systemctl disable initial-setup-reconfiguration.service
69 |
70 | %end
71 |
--------------------------------------------------------------------------------
/Packer/http/kali.cfg:
--------------------------------------------------------------------------------
1 | d-i debian-installer/locale string en_US.UTF-8
2 | d-i console-keymaps-at/keymap select us
3 | d-i mirror/country string enter information manually
4 | d-i mirror/http/hostname string http.kali.org
5 | d-i mirror/http/directory string /kali
6 | d-i keyboard-configuration/xkb-keymap select us
7 | d-i mirror/http/proxy string
8 | d-i mirror/suite string kali-rolling
9 | d-i mirror/codename string kali-rolling
10 | d-i clock-setup/utc boolean true
11 | d-i time/zone string US/Eastern
12 |
13 | # Disable security, volatile and backports
14 | d-i apt-setup/services-select multiselect
15 |
16 | # Enable contrib and non-free
17 | d-i apt-setup/non-free boolean true
18 | d-i apt-setup/contrib boolean true
19 |
20 | # Disable source repositories too
21 | d-i apt-setup/enable-source-repositories boolean false
22 |
23 | # Partitioning
24 | d-i partman-auto/method string regular
25 | d-i partman-lvm/device_remove_lvm boolean true
26 | d-i partman-md/device_remove_md boolean true
27 | d-i partman-lvm/confirm boolean true
28 | d-i partman-auto/choose_recipe select atomic
29 | d-i partman-auto/disk string /dev/sda
30 | d-i partman/confirm_write_new_label boolean true
31 | d-i partman/choose_partition select finish
32 | d-i partman/confirm boolean true
33 | d-i partman/confirm_nooverwrite boolean true
34 | d-i partman-partitioning/confirm_write_new_label boolean true
35 |
36 | # Disable CDROM entries after install
37 | d-i apt-setup/disable-cdrom-entries boolean true
38 |
39 | # Upgrade installed packages
40 | tasksel tasksel/desktop string xfce
41 | tasksel tasksel/first multiselect kali-desktop, standard
42 | d-i pkgsel/upgrade select full-upgrade
43 | d-i pkgsel/include string openssh-server kali-desktop-xfce kali-linux-large ansible
44 |
45 | # Change default hostname
46 | d-i netcfg/get_hostname string kali
47 | d-i netcfg/get_domain string unassigned-domain
48 | d-i netcfg/choose_interface select eth0
49 | d-i netcfg/dhcp_timeout string 60
50 | d-i hw-detect/load_firmware boolean false
51 |
52 | d-i passwd/root-password password toor
53 | d-i passwd/root-password-again password toor
54 | d-i passwd/root-login boolean true
55 | d-i passwd/make-user boolean false
56 | d-i user-setup/encrypt-home boolean false
57 | d-i apt-setup/use_mirror boolean true
58 | d-i grub-installer/only_debian boolean true
59 | d-i grub-installer/with_other_os boolean false
60 | d-i grub-installer/bootdev string /dev/sda
61 | d-i finish-install/reboot_in_progress note
62 |
63 | # Disable popularity-contest
64 | popularity-contest popularity-contest/participate boolean false
65 | kismet kismet/install-setuid boolean false
66 | kismet kismet/install-users string
67 | sslh sslh/inetd_or_standalone select standalone
68 | mysql-server-5.5 mysql-server/root_password_again password
69 | mysql-server-5.5 mysql-server/root_password password
70 | mysql-server-5.5 mysql-server/error_setting_password error
71 | mysql-server-5.5 mysql-server-5.5/postrm_remove_databases boolean false
72 | mysql-server-5.5 mysql-server-5.5/start_on_boot boolean true
73 | mysql-server-5.5 mysql-server-5.5/nis_warning note
74 | mysql-server-5.5 mysql-server-5.5/really_downgrade boolean false
75 | mysql-server-5.5 mysql-server/password_mismatch error
76 | mysql-server-5.5 mysql-server/no_upgrade_when_using_ndb error
77 |
78 | d-i preseed/late_command string \
79 | in-target systemctl enable ssh; \
80 | in-target systemctl start ssh; \
81 | echo "PermitRootLogin yes" >> /target/etc/ssh/sshd_config
--------------------------------------------------------------------------------
/Packer/http/ubuntu-preseed.cfg:
--------------------------------------------------------------------------------
1 | #### Contents of the preconfiguration file
2 | # Language
3 | d-i debian-installer/language string en
4 | d-i debian-installer/country string US
5 | d-i debian-installer/locale string en_US.UTF-8
6 | d-i console-setup/ask_detect boolean false
7 |
8 | # Keyboard
9 | d-i keyboard-configuration/variant select USA
10 | d-i keyboard-configuration/layout select USA
11 |
12 |
13 | ### Network configuration
14 | d-i netcfg/choose_interface select auto
15 | d-i netcfg/get_hostname string Home-Lab-VM
16 | d-i netcfg/get_domain string unassigned-domain
17 | # Disable that annoying WEP key dialog.
18 | d-i netcfg/wireless_wep string
19 | d-i mirror/http/proxy string
20 |
21 | ### Mirror settings
22 | d-i mirror/country string manual
23 | d-i mirror/http/hostname string archive.ubuntu.com
24 | d-i mirror/http/directory string /ubuntu
25 |
26 | ### Account setup
27 | d-i passwd/user-fullname string conda
28 | d-i passwd/username string conda
29 | d-i passwd/user-password password conda
30 | d-i passwd/user-password-again password conda
31 | d-i user-setup/allow-password-weak boolean true
32 | d-i user-setup/encrypt-home boolean false
33 |
34 | ### Time settings
35 | d-i clock-setup/utc boolean true
36 | d-i time/zone string US/Eastern
37 | d-i clock-setup/ntp boolean true
38 |
39 | ### Partitioning
40 | d-i partman-auto/disk string /dev/sda
41 | d-i partman-auto/method string regular
42 | d-i partman-lvm/device_remove_lvm boolean true
43 | d-i partman-md/device_remove_md boolean true
44 | d-i partman-lvm/confirm boolean true
45 | d-i partman-lvm/confirm_nooverwrite boolean true
46 | d-i partman-auto/choose_recipe select atomic
47 | d-i partman-partitioning/confirm_write_new_label boolean true
48 | d-i partman/choose_partition select finish
49 | d-i partman/confirm boolean true
50 | d-i partman/confirm_nooverwrite boolean true
51 | d-i partman-md/confirm boolean true
52 | d-i partman-partitioning/confirm_write_new_label boolean true
53 | d-i partman/choose_partition select finish
54 | d-i partman/confirm boolean true
55 | d-i partman/confirm_nooverwrite boolean true
56 |
57 | d-i grub-installer/only_debian boolean true
58 | d-i grub-installer/with_other_os boolean true
59 |
60 | ### Package selection
61 | d-i pkgsel/update-policy select none
62 | tasksel tasksel/first select openssh-server
63 | d-i pkgsel/include string build-essential ansible vim
64 |
65 | d-i preseed/late_command string \
66 | echo "conda ALL=(ALL) NOPASSWD: ALL" >> /target/etc/sudoers
67 |
68 | d-i finish-install/reboot_in_progress note
69 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Pentesting Playground
2 | This contains the contents needed to deploy a home lab of Vagrant boxes, all from a simple to use GUI. This is meant to be a community driven project. I encourage suggestions for things to set up.
3 |
4 | ## Getting Started
5 | Clone this repo by downloading the zip verision, or with `$ git clone https://github.com/C0nd4/pentesting-playground`
6 |
7 | Download Packer [here](https://www.packer.io/downloads.html).
8 |
9 | Place the Packer executable in your PATH.
10 |
11 | Download and install Vagrant [here](https://www.vagrantup.com/downloads.html).
12 |
13 | ### Using the Lab Creator Tool
14 | There is a graphical tool that will aide in creating multiple machines at the same time. This is a work in progress and an official stable version has not been released yet. You can use this tool by invoking `python3 lab-creator.py`. The tool will render a Vagrantfile and Vagrant boxes in the `Vagrant` folder after hitting the `Run` button. Be sure to press `Save` after each machine is configured before running. Building the lab machines can take a while due to the need to build each VM with Packer. To start the lab, simply change into the `Vagrant` folder and enter the command `vagrant up`.
15 |
16 | ### Requirements
17 |
18 | - Python 3
19 | - VirtualBox
20 | - Packer >= 1.6
21 | - Vagrant
22 |
23 | ## Roadmap
24 | There are several ideas for features I'd like to add.
25 |
26 | [ ] Add an Active Directory builder
27 |
28 | [ ] Add a config file
29 |
30 | [ ] Add support for VMware
31 |
32 | [ ] Allow users to add custom roles and operating systems
33 |
34 | [ ] Add more supported operating systems
35 |
36 | [ ] Add more ansible roles
37 |
38 |
--------------------------------------------------------------------------------
/VMs/placeholder:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/C0nd4/pentesting-playground/136af3ea3110356f9d3d93a04a81ec6af47bfadb/VMs/placeholder
--------------------------------------------------------------------------------
/Vagrant/placeholder:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/C0nd4/pentesting-playground/136af3ea3110356f9d3d93a04a81ec6af47bfadb/Vagrant/placeholder
--------------------------------------------------------------------------------
/Vagrant/scripts/DeploymentConfigTemplate.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | System.Collections.ObjectModel.Collection`1[[System.Management.Automation.PSObject, System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]
5 | System.Object
6 |
7 |
8 |
9 |
10 | Microsoft.Management.Infrastructure.CimInstance#ROOT/Microsoft/Windows/ServerManager/ServerComponent_RSAT_AD_PowerShell
11 | Microsoft.Management.Infrastructure.CimInstance#ROOT/Microsoft/Windows/ServerManager/MSFT_ServerManagerServerComponentDescriptor
12 | Microsoft.Management.Infrastructure.CimInstance#ServerComponent_RSAT_AD_PowerShell
13 | Microsoft.Management.Infrastructure.CimInstance#MSFT_ServerManagerServerComponentDescriptor
14 | Microsoft.Management.Infrastructure.CimInstance
15 | System.Object
16 |
17 | ServerComponent_RSAT_AD_PowerShell
18 |
19 | dc
20 |
21 |
22 | 331
23 |
24 |
25 | System.Collections.ArrayList
26 | System.Object
27 |
28 |
29 |
30 |
31 | MSFT_ServerManagerServerComponentDescriptor
32 | ROOT/Microsoft/Windows/ServerManager
33 | dc
34 | -426961640
35 | <CLASS NAME="MSFT_ServerManagerServerComponentDescriptor"><QUALIFIER NAME="dynamic" TYPE="boolean"><VALUE>true</VALUE></QUALIFIER><QUALIFIER NAME="locale" TYPE="sint32" TOSUBCLASS="false"><VALUE>1033</VALUE></QUALIFIER><QUALIFIER NAME="provider" TYPE="string"><VALUE>deploymentprovider</VALUE></QUALIFIER></CLASS>
36 |
37 |
38 |
39 |
40 | ServerComponent_RSAT_AD_PowerShell
41 | ROOT/Microsoft/Windows/ServerManager
42 | dc
43 | -426909640
44 | <CLASS NAME="ServerComponent_RSAT_AD_PowerShell" SUPERCLASS="MSFT_ServerManagerServerComponentDescriptor"><QUALIFIER NAME="dynamic" TYPE="boolean"><VALUE>true</VALUE></QUALIFIER><QUALIFIER NAME="provider" TYPE="string"><VALUE>deploymentprovider</VALUE></QUALIFIER><QUALIFIER NAME="ClassVersion" TYPE="string"><VALUE>0.0.0</VALUE></QUALIFIER><QUALIFIER NAME="DisplayName" TYPE="string" TRANSLATABLE="true"><VALUE>RSAT-AD-PowerShell</VALUE></QUALIFIER></CLASS>
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 | Microsoft.Management.Infrastructure.CimInstance#ROOT/Microsoft/Windows/ServerManager/ServerComponent_AD_Domain_Services
54 | Microsoft.Management.Infrastructure.CimInstance#ROOT/Microsoft/Windows/ServerManager/MSFT_ServerManagerServerComponentDescriptor
55 | Microsoft.Management.Infrastructure.CimInstance#ServerComponent_AD_Domain_Services
56 | Microsoft.Management.Infrastructure.CimInstance#MSFT_ServerManagerServerComponentDescriptor
57 | Microsoft.Management.Infrastructure.CimInstance
58 | System.Object
59 |
60 | ServerComponent_AD_Domain_Services
61 |
62 | dc
63 |
64 |
65 | 10
66 |
67 |
68 |
69 |
70 |
71 | MSFT_ServerManagerServerComponentDescriptor
72 | ROOT/Microsoft/Windows/ServerManager
73 | dc
74 | -426961640
75 |
76 |
77 |
78 |
79 | ServerComponent_AD_Domain_Services
80 | ROOT/Microsoft/Windows/ServerManager
81 | dc
82 | -426906520
83 | <CLASS NAME="ServerComponent_AD_Domain_Services" SUPERCLASS="MSFT_ServerManagerServerComponentDescriptor"><QUALIFIER NAME="dynamic" TYPE="boolean"><VALUE>true</VALUE></QUALIFIER><QUALIFIER NAME="provider" TYPE="string"><VALUE>deploymentprovider</VALUE></QUALIFIER><QUALIFIER NAME="ClassVersion" TYPE="string"><VALUE>8.0.0</VALUE></QUALIFIER><QUALIFIER NAME="DisplayName" TYPE="string" TRANSLATABLE="true"><VALUE>AD-Domain-Services</VALUE></QUALIFIER></CLASS>
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 | Microsoft.Management.Infrastructure.CimInstance#ROOT/Microsoft/Windows/ServerManager/ServerComponent_RSAT_AD_AdminCenter
93 | Microsoft.Management.Infrastructure.CimInstance#ROOT/Microsoft/Windows/ServerManager/MSFT_ServerManagerServerComponentDescriptor
94 | Microsoft.Management.Infrastructure.CimInstance#ServerComponent_RSAT_AD_AdminCenter
95 | Microsoft.Management.Infrastructure.CimInstance#MSFT_ServerManagerServerComponentDescriptor
96 | Microsoft.Management.Infrastructure.CimInstance
97 | System.Object
98 |
99 | ServerComponent_RSAT_AD_AdminCenter
100 |
101 | dc
102 |
103 |
104 | 330
105 |
106 |
107 |
108 |
109 |
110 | MSFT_ServerManagerServerComponentDescriptor
111 | ROOT/Microsoft/Windows/ServerManager
112 | dc
113 | -426961640
114 |
115 |
116 |
117 |
118 | ServerComponent_RSAT_AD_AdminCenter
119 | ROOT/Microsoft/Windows/ServerManager
120 | dc
121 | -427148840
122 | <CLASS NAME="ServerComponent_RSAT_AD_AdminCenter" SUPERCLASS="MSFT_ServerManagerServerComponentDescriptor"><QUALIFIER NAME="dynamic" TYPE="boolean"><VALUE>true</VALUE></QUALIFIER><QUALIFIER NAME="provider" TYPE="string"><VALUE>deploymentprovider</VALUE></QUALIFIER><QUALIFIER NAME="ClassVersion" TYPE="string"><VALUE>0.0.0</VALUE></QUALIFIER><QUALIFIER NAME="DisplayName" TYPE="string" TRANSLATABLE="true"><VALUE>RSAT-AD-AdminCenter</VALUE></QUALIFIER></CLASS>
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 | Microsoft.Management.Infrastructure.CimInstance#ROOT/Microsoft/Windows/ServerManager/ServerComponent_RSAT_AD_Tools
132 | Microsoft.Management.Infrastructure.CimInstance#ROOT/Microsoft/Windows/ServerManager/MSFT_ServerManagerServerComponentDescriptor
133 | Microsoft.Management.Infrastructure.CimInstance#ServerComponent_RSAT_AD_Tools
134 | Microsoft.Management.Infrastructure.CimInstance#MSFT_ServerManagerServerComponentDescriptor
135 | Microsoft.Management.Infrastructure.CimInstance
136 | System.Object
137 |
138 | ServerComponent_RSAT_AD_Tools
139 |
140 | dc
141 |
142 |
143 | 329
144 |
145 |
146 |
147 |
148 |
149 | MSFT_ServerManagerServerComponentDescriptor
150 | ROOT/Microsoft/Windows/ServerManager
151 | dc
152 | -426961640
153 |
154 |
155 |
156 |
157 | ServerComponent_RSAT_AD_Tools
158 | ROOT/Microsoft/Windows/ServerManager
159 | dc
160 | -431650312
161 | <CLASS NAME="ServerComponent_RSAT_AD_Tools" SUPERCLASS="MSFT_ServerManagerServerComponentDescriptor"><QUALIFIER NAME="dynamic" TYPE="boolean"><VALUE>true</VALUE></QUALIFIER><QUALIFIER NAME="provider" TYPE="string"><VALUE>deploymentprovider</VALUE></QUALIFIER><QUALIFIER NAME="ClassVersion" TYPE="string"><VALUE>0.0.0</VALUE></QUALIFIER><QUALIFIER NAME="DisplayName" TYPE="string" TRANSLATABLE="true"><VALUE>RSAT-AD-Tools</VALUE></QUALIFIER></CLASS>
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 | Microsoft.Management.Infrastructure.CimInstance#ROOT/Microsoft/Windows/ServerManager/ServerComponent_RSAT_ADDS
171 | Microsoft.Management.Infrastructure.CimInstance#ROOT/Microsoft/Windows/ServerManager/MSFT_ServerManagerServerComponentDescriptor
172 | Microsoft.Management.Infrastructure.CimInstance#ServerComponent_RSAT_ADDS
173 | Microsoft.Management.Infrastructure.CimInstance#MSFT_ServerManagerServerComponentDescriptor
174 | Microsoft.Management.Infrastructure.CimInstance
175 | System.Object
176 |
177 | ServerComponent_RSAT_ADDS
178 |
179 | dc
180 |
181 |
182 | 257
183 |
184 |
185 |
186 |
187 |
188 | MSFT_ServerManagerServerComponentDescriptor
189 | ROOT/Microsoft/Windows/ServerManager
190 | dc
191 | -426961640
192 |
193 |
194 |
195 |
196 | ServerComponent_RSAT_ADDS
197 | ROOT/Microsoft/Windows/ServerManager
198 | dc
199 | -431655512
200 | <CLASS NAME="ServerComponent_RSAT_ADDS" SUPERCLASS="MSFT_ServerManagerServerComponentDescriptor"><QUALIFIER NAME="dynamic" TYPE="boolean"><VALUE>true</VALUE></QUALIFIER><QUALIFIER NAME="provider" TYPE="string"><VALUE>deploymentprovider</VALUE></QUALIFIER><QUALIFIER NAME="ClassVersion" TYPE="string"><VALUE>0.0.0</VALUE></QUALIFIER><QUALIFIER NAME="DisplayName" TYPE="string" TRANSLATABLE="true"><VALUE>RSAT-ADDS</VALUE></QUALIFIER></CLASS>
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 | Microsoft.Management.Infrastructure.CimInstance#ROOT/Microsoft/Windows/ServerManager/ServerComponent_RSAT_ADDS_Tools
210 | Microsoft.Management.Infrastructure.CimInstance#ROOT/Microsoft/Windows/ServerManager/MSFT_ServerManagerServerComponentDescriptor
211 | Microsoft.Management.Infrastructure.CimInstance#ServerComponent_RSAT_ADDS_Tools
212 | Microsoft.Management.Infrastructure.CimInstance#MSFT_ServerManagerServerComponentDescriptor
213 | Microsoft.Management.Infrastructure.CimInstance
214 | System.Object
215 |
216 | ServerComponent_RSAT_ADDS_Tools
217 |
218 | dc
219 |
220 |
221 | 299
222 |
223 |
224 |
225 |
226 |
227 | MSFT_ServerManagerServerComponentDescriptor
228 | ROOT/Microsoft/Windows/ServerManager
229 | dc
230 | -426961640
231 |
232 |
233 |
234 |
235 | ServerComponent_RSAT_ADDS_Tools
236 | ROOT/Microsoft/Windows/ServerManager
237 | dc
238 | -431660712
239 | <CLASS NAME="ServerComponent_RSAT_ADDS_Tools" SUPERCLASS="MSFT_ServerManagerServerComponentDescriptor"><QUALIFIER NAME="dynamic" TYPE="boolean"><VALUE>true</VALUE></QUALIFIER><QUALIFIER NAME="provider" TYPE="string"><VALUE>deploymentprovider</VALUE></QUALIFIER><QUALIFIER NAME="ClassVersion" TYPE="string"><VALUE>0.0.0</VALUE></QUALIFIER><QUALIFIER NAME="DisplayName" TYPE="string" TRANSLATABLE="true"><VALUE>RSAT-ADDS-Tools</VALUE></QUALIFIER></CLASS>
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 | Microsoft.Management.Infrastructure.CimInstance#ROOT/Microsoft/Windows/ServerManager/ServerComponent_RSAT
249 | Microsoft.Management.Infrastructure.CimInstance#ROOT/Microsoft/Windows/ServerManager/MSFT_ServerManagerServerComponentDescriptor
250 | Microsoft.Management.Infrastructure.CimInstance#ServerComponent_RSAT
251 | Microsoft.Management.Infrastructure.CimInstance#MSFT_ServerManagerServerComponentDescriptor
252 | Microsoft.Management.Infrastructure.CimInstance
253 | System.Object
254 |
255 | ServerComponent_RSAT
256 |
257 | dc
258 |
259 |
260 | 67
261 |
262 |
263 |
264 |
265 |
266 | MSFT_ServerManagerServerComponentDescriptor
267 | ROOT/Microsoft/Windows/ServerManager
268 | dc
269 | -426961640
270 |
271 |
272 |
273 |
274 | ServerComponent_RSAT
275 | ROOT/Microsoft/Windows/ServerManager
276 | dc
277 | -431764712
278 | <CLASS NAME="ServerComponent_RSAT" SUPERCLASS="MSFT_ServerManagerServerComponentDescriptor"><QUALIFIER NAME="dynamic" TYPE="boolean"><VALUE>true</VALUE></QUALIFIER><QUALIFIER NAME="provider" TYPE="string"><VALUE>deploymentprovider</VALUE></QUALIFIER><QUALIFIER NAME="ClassVersion" TYPE="string"><VALUE>8.0.0</VALUE></QUALIFIER><QUALIFIER NAME="DisplayName" TYPE="string" TRANSLATABLE="true"><VALUE>RSAT</VALUE></QUALIFIER></CLASS>
279 |
280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 | Microsoft.Management.Infrastructure.CimInstance#ROOT/Microsoft/Windows/ServerManager/ServerComponent_RSAT_Role_Tools
288 | Microsoft.Management.Infrastructure.CimInstance#ROOT/Microsoft/Windows/ServerManager/MSFT_ServerManagerServerComponentDescriptor
289 | Microsoft.Management.Infrastructure.CimInstance#ServerComponent_RSAT_Role_Tools
290 | Microsoft.Management.Infrastructure.CimInstance#MSFT_ServerManagerServerComponentDescriptor
291 | Microsoft.Management.Infrastructure.CimInstance
292 | System.Object
293 |
294 | ServerComponent_RSAT_Role_Tools
295 |
296 | dc
297 |
298 |
299 | 256
300 |
301 |
302 |
303 |
304 |
305 | MSFT_ServerManagerServerComponentDescriptor
306 | ROOT/Microsoft/Windows/ServerManager
307 | dc
308 | -426961640
309 |
310 |
311 |
312 |
313 | ServerComponent_RSAT_Role_Tools
314 | ROOT/Microsoft/Windows/ServerManager
315 | dc
316 | -431770952
317 | <CLASS NAME="ServerComponent_RSAT_Role_Tools" SUPERCLASS="MSFT_ServerManagerServerComponentDescriptor"><QUALIFIER NAME="dynamic" TYPE="boolean"><VALUE>true</VALUE></QUALIFIER><QUALIFIER NAME="provider" TYPE="string"><VALUE>deploymentprovider</VALUE></QUALIFIER><QUALIFIER NAME="ClassVersion" TYPE="string"><VALUE>8.0.0</VALUE></QUALIFIER><QUALIFIER NAME="DisplayName" TYPE="string" TRANSLATABLE="true"><VALUE>RSAT-Role-Tools</VALUE></QUALIFIER></CLASS>
318 |
319 |
320 |
321 |
322 |
323 |
324 |
325 |
326 | Microsoft.Management.Infrastructure.CimInstance#ROOT/Microsoft/Windows/ServerManager/ServerComponent_GPMC
327 | Microsoft.Management.Infrastructure.CimInstance#ROOT/Microsoft/Windows/ServerManager/MSFT_ServerManagerServerComponentDescriptor
328 | Microsoft.Management.Infrastructure.CimInstance#ServerComponent_GPMC
329 | Microsoft.Management.Infrastructure.CimInstance#MSFT_ServerManagerServerComponentDescriptor
330 | Microsoft.Management.Infrastructure.CimInstance
331 | System.Object
332 |
333 | ServerComponent_GPMC
334 |
335 | dc
336 |
337 |
338 | 69
339 |
340 |
341 |
342 |
343 |
344 | MSFT_ServerManagerServerComponentDescriptor
345 | ROOT/Microsoft/Windows/ServerManager
346 | dc
347 | -426961640
348 |
349 |
350 |
351 |
352 | ServerComponent_GPMC
353 | ROOT/Microsoft/Windows/ServerManager
354 | dc
355 | -431793832
356 | <CLASS NAME="ServerComponent_GPMC" SUPERCLASS="MSFT_ServerManagerServerComponentDescriptor"><QUALIFIER NAME="dynamic" TYPE="boolean"><VALUE>true</VALUE></QUALIFIER><QUALIFIER NAME="provider" TYPE="string"><VALUE>deploymentprovider</VALUE></QUALIFIER><QUALIFIER NAME="ClassVersion" TYPE="string"><VALUE>10.0.0</VALUE></QUALIFIER><QUALIFIER NAME="DisplayName" TYPE="string" TRANSLATABLE="true"><VALUE>GPMC</VALUE></QUALIFIER></CLASS>
357 |
358 |
359 |
360 |
361 |
362 |
363 |
364 |
365 |
--------------------------------------------------------------------------------
/Vagrant/scripts/Domain Controller.ps1:
--------------------------------------------------------------------------------
1 | Install-WindowsFeature AD-domain-services
2 | Import-Module ADDSDeployment
3 | Install-ADDSForest `
4 | -CreateDnsDelegation:$false `
5 | -DatabasePath "C:\Windows\NTDS" `
6 | -DomainMode "WinThreshold" `
7 | -DomainName "lab.local" `
8 | -DomainNetbiosName "LAB" `
9 | -ForestMode "WinThreshold" `
10 | -InstallDns:$true `
11 | -LogPath "C:\Windows\NTDS" `
12 | -NoRebootOnCompletion:$true `
13 | -SysvolPath "C:\Windows\SYSVOL" `
14 | -Force:$true `
15 | -SafeModeAdministratorPassword (ConvertTo-SecureString "Conda123!" -AsPlainText -Force)
16 |
17 | Install-WindowsFeature -ConfigurationFilePath C:\Temp\DeploymentConfigTemplate.xml
--------------------------------------------------------------------------------
/Vagrant/scripts/Enable RDP.ps1:
--------------------------------------------------------------------------------
1 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 #Use TLS 1.2, needed for Install-PackageProvider
2 | Install-PackageProvider -Name NuGet -Force
3 | Install-Module -Name Carbon -Force
4 | Import-Module Carbon
5 |
6 | net localgroup "Remote Desktop Users" "Administrator" /add
7 | Grant-Privilege -Identity Administrator -Privilege SeRemoteInteractiveLogonRight
8 | Grant-Privilege -Identity Administrator -Privilege SeInteractiveLogonRight
--------------------------------------------------------------------------------
/Vagrant/scripts/initialize-domain.ps1:
--------------------------------------------------------------------------------
1 | Import-Module ADDSDeployment
2 | Install-ADDSForest `
3 | -CreateDnsDelegation:$false `
4 | -DatabasePath "C:\Windows\NTDS" `
5 | -DomainMode "WinThreshold" `
6 | -DomainName "lab.local" `
7 | -DomainNetbiosName "LAB" `
8 | -ForestMode "WinThreshold" `
9 | -InstallDns:$true `
10 | -LogPath "C:\Windows\NTDS" `
11 | -NoRebootOnCompletion:$true `
12 | -SysvolPath "C:\Windows\SYSVOL" `
13 | -Force:$true `
14 | -SafeModeAdministratorPassword (ConvertTo-SecureString "Conda123!" -AsPlainText -Force)
15 |
16 | Install-WindowsFeature -ConfigurationFilePath C:\Temp\DeploymentConfigTemplate.xml
--------------------------------------------------------------------------------
/lab-creator.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 |
3 | import os
4 | import subprocess
5 | import threading
6 | import queue
7 | from tkinter import *
8 |
9 | def switch_frame(self, frame_class):
10 | new_frame = frame_class(self.master)
11 | new_frame.setQueue(self.queue)
12 | if self is not None:
13 | self.destroy()
14 | self = new_frame
15 | self.pack(fill=BOTH, expand=1)
16 |
17 | class LabCreatorApp(Frame):
18 | def __init__(self, master=None):
19 | Frame.__init__(self, master)
20 | self.master = master
21 | self._frame = None
22 | self.queue = queue.Queue()
23 | switch_frame(self, MainPage)
24 |
25 |
26 | class MainPage(Frame):
27 |
28 | def __init__(self, master=None):
29 | Frame.__init__(self, master)
30 | self.master = master
31 | self.creation_window()
32 | self.currentOS = osList[0]
33 | self.currentRoles = osList[0].roleList
34 | self.currentMachine = machineList[0]
35 |
36 | def creation_window(self):
37 |
38 | self.master.title("Lab Creator")
39 | self.pack(fill=BOTH, expand=1)
40 |
41 | self.selectedOS = StringVar(self)
42 | self.selectedOS.set(osList[0])
43 | self.selectedOS.trace('w', self.set_current_os)
44 | self.osOpt = OptionMenu(self, self.selectedOS, *osList, command=self.set_current_os)
45 | self.osOpt.config(width=12, font=('Helvetica', 12))
46 | self.osOpt.pack()
47 | self.osOpt.place(x=235, y=15)
48 |
49 | self.selectedMachine = StringVar(self)
50 | self.selectedMachine.set(machineList[0])
51 | self.selectedMachine.trace('w', self.set_current_machine)
52 | self.machineOpt = OptionMenu(self, self.selectedMachine, *machineList, command=self.set_current_machine)
53 | self.machineOpt.config(width=12, font=('Helvetica', 12))
54 | self.machineOpt.pack()
55 | self.machineOpt.place(x=15, y=15)
56 |
57 | self.roleLabel = Label(self, text="Roles:", font=('Helvetica', 12))
58 | self.roleLabel.pack()
59 | self.roleLabel.place(x=15, y=80)
60 |
61 | self.saveButton = Button(self, text="Save", font=('Helvetica', 12), command=self.save)
62 | self.saveButton.place(x=315, y=250)
63 |
64 | self.runButton = Button(self, text="Run", font=('Helvetica', 12), command=self.run_packer)
65 | self.runButton.place(x=200, y=250)
66 |
67 | self.addMachineButton = Button(self, text="Add Machine", font=('Helvetica', 12), command=self.add_machine)
68 | self.addMachineButton.place(x=15, y=250)
69 |
70 | self.roleList = Listbox(self, selectmode="multiple", width=25, exportselection=0)
71 | self.roleList.pack()
72 | self.roleList.place(x=75, y=75)
73 |
74 | self.cpuEntry = Entry(self, width=7)
75 | self.cpuEntry.pack()
76 | self.cpuEntry.place(x=350, y=75)
77 |
78 | self.cpuLabel = Label(self, text="CPU Cores:", font=('Helvetica', 12))
79 | self.cpuLabel.pack()
80 | self.cpuLabel.place(x=230, y=72)
81 |
82 | self.ramEntry = Entry(self, width=7)
83 | self.ramEntry.pack()
84 | self.ramEntry.place(x=350, y=100)
85 |
86 | self.ramLabel = Label(self, text="RAM (MBs):", font=('Helvetica', 12))
87 | self.ramLabel.pack()
88 | self.ramLabel.place(x=230, y=97)
89 |
90 | self.hdEntry = Entry(self, width=7)
91 | self.hdEntry.pack()
92 | self.hdEntry.place(x=350, y=125)
93 |
94 | self.hdLabel = Label(self, text="HD Size (MBs):", font=('Helvetica', 12))
95 | self.hdLabel.pack()
96 | self.hdLabel.place(x=230, y=122)
97 |
98 | self.currentOS = self.set_current_os()
99 | self.currentRoles = self.get_roles()
100 | self.currentMachine = self.set_current_machine()
101 |
102 | def add_machine(self):
103 | global numberOfMachines
104 | numberOfMachines = numberOfMachines + 1
105 | newMachine = Machine(numberOfMachines)
106 | machineList.append(newMachine)
107 | m = self.machineOpt.children['menu']
108 | m.delete(0, "end")
109 | for mach in machineList:
110 | m.add_command(label=mach, command=lambda value=mach: self.selectedMachine.set(value))
111 |
112 | def set_current_machine(self, *args):
113 | for m in machineList:
114 | if str(m) == self.selectedMachine.get():
115 | self.currentMachine = m
116 | self.roleList.selection_clear(0, END)
117 | self.populate_machine()
118 |
119 | def set_current_os(self, *args):
120 | for o in osList:
121 | if str(o) == str(self.selectedOS.get()):
122 | self.currentOS = o
123 | self.get_roles()
124 | self.show_roles()
125 |
126 | def get_roles(self):
127 | if(self.currentOS):
128 | self.currentRoles = self.currentOS.roleList
129 |
130 | def show_roles(self):
131 | self.roleList.delete(0, END)
132 | if self.currentRoles != None:
133 | for r in self.currentRoles:
134 | self.roleList.insert(END, r)
135 | for s in self.currentOS.scriptList:
136 | self.roleList.insert(END, s)
137 |
138 | def save(self):
139 | selected = self.roleList.curselection()
140 | selected = [self.roleList.get(i) for i in selected]
141 | self.currentMachine.operatingSystem = self.currentOS
142 | for s in selected:
143 | if s in self.currentMachine.operatingSystem.roleList:
144 | self.currentMachine.roles.append(s)
145 | print(s + " added to roles")
146 | else:
147 | self.currentMachine.scripts.append(s)
148 | print(s + " added to scripts")
149 | self.currentMachine.roleSet = self.currentRoles
150 | self.currentMachine.cpus = self.cpuEntry.get()
151 | self.currentMachine.hdSize = self.hdEntry.get()
152 | self.currentMachine.ram = self.ramEntry.get()
153 |
154 | def populate_machine(self):
155 | if self.currentMachine.operatingSystem != "":
156 | self.selectedOS.set(self.currentMachine.operatingSystem)
157 | else:
158 | self.selectedOS.set("Select an OS")
159 | self.currentRoles = None
160 | self.show_roles()
161 | for a in self.currentMachine.roles:
162 | self.roleList.select_set(a)
163 | self.ramEntry.delete(0, END)
164 | self.cpuEntry.delete(0, END)
165 | self.hdEntry.delete(0, END)
166 | self.ramEntry.insert(0, self.currentMachine.ram)
167 | self.cpuEntry.insert(0, self.currentMachine.cpus)
168 | self.hdEntry.insert(0, self.currentMachine.hdSize)
169 |
170 | def run_packer(self):
171 | ThreadedTask(self.queue).start()
172 | switch_frame(self, ProgressPage)
173 |
174 | def setQueue(self, queue):
175 | self.queue = queue
176 |
177 |
178 | class ProgressPage(Frame):
179 | def __init__(self, master):
180 | Frame.__init__(self, master)
181 | self.master = master
182 | self.numberOfFinished = -1
183 | self.status = self.update()
184 | self.l = Label(self, text="Progress", font=('Helvetica', 18, "bold")).pack()
185 | for i in range (len(machineList)):
186 | newLabel = Label(self, text="Machine " + str(i+1) + ":", font=('Helvetica', 12))
187 | newLabel.pack()
188 | newLabel.place(x=60, y=22 * (i + 1) + 30)
189 | self.statusList = []
190 | for i in range (len(machineList)):
191 | self.statusList.append(Label(self, text="In Progress", font=('Helvetica', 12)))
192 | self.statusList[i].pack()
193 | self.statusList[i].place(x=150, y=22 * (i + 1) + 30)
194 |
195 | def setQueue(self, queue):
196 | self.queue = queue
197 |
198 | def update(self):
199 | self.after(10000, self.update)
200 | try:
201 | if not self.queue.empty():
202 | buildStatus = str(self.queue.get())
203 | self.numberOfFinished = self.numberOfFinished + 1
204 | self.statusList[self.numberOfFinished].destroy()
205 | self.statusList[self.numberOfFinished] = Label(self, text=buildStatus, font=('Helvetica', 12))
206 | self.statusList[self.numberOfFinished].pack()
207 | self.statusList[self.numberOfFinished].place(x=150, y=22 * (self.numberOfFinished + 1) + 30)
208 | except:
209 | pass
210 |
211 |
212 | class ThreadedTask(threading.Thread):
213 |
214 | def __init__(self, queue):
215 | threading.Thread.__init__(self)
216 | self.queue = queue
217 |
218 | def cleanup(self):
219 | for m in machineList:
220 | os.remove("Packer/machine" + str(m.number) + ".json")
221 | if len(m.roles) != 0:
222 | os.remove("Packer/ansible/machine" + str(m.number) + ".yml")
223 |
224 | def writeVagrantFiles(self):
225 | machineListTemp = machineList
226 | for m in machineListTemp:
227 | if len(m.scripts) != 0:
228 | for s in m.scripts:
229 | if s == "Domain Controller":
230 | machineList.insert(0, machineList.pop(machineList.index(m)))
231 | with open("Vagrant/Vagrantfile", "w") as vagrantFile:
232 | vagrantFile.write('# -*- mode: ruby -*-\n')
233 | vagrantFile.write('# vi: set ft=ruby :\n')
234 | vagrantFile.write('Vagrant.configure("2") do |config|\n')
235 | vagrantFile.write(' config.ssh.username = "conda"\n')
236 | vagrantFile.write(' config.ssh.password = "conda"\n')
237 | vagrantFile.write(' config.winrm.username = "Administrator"\n')
238 | vagrantFile.write(' config.winrm.password = "Conda123!"\n')
239 | vagrantFile.write(' config.winrm.transport = :plaintext\n')
240 | vagrantFile.write(' config.winrm.basic_auth_only = true\n')
241 | for m in machineList:
242 | vagrantFile.write(' config.vm.define "machine' + str(m.number) + '" do |machine' + str(m.number) + '|\n')
243 | if "Windows" in str(m.operatingSystem):
244 | vagrantFile.write(' machine' + str(m.number) + '.vm.network "forwarded_port", guest: 3389, host: ' + str(33389 + m.number) + '\n')
245 | vagrantFile.write(' machine' + str(m.number) + '.vm.communicator = "winrm"\n')
246 | vagrantFile.write(' machine' + str(m.number) + '.vm.provision "shell", inline: "New-Item -Path C:\\ -Name Temp -ItemType directory"\n')
247 | vagrantFile.write(' machine' + str(m.number) + '.vm.box = "../VMs/Machine' + str(m.number) + '.box"\n')
248 | vagrantFile.write(' machine' + str(m.number) + '.vm.network "private_network", ip: "192.168.13.' + str(100 + m.number) + '"\n')
249 | if len(m.scripts) != 0:
250 | for s in m.scripts:
251 | if s == "Domain Controller":
252 | vagrantFile.write(' machine' + str(m.number) + '.vm.provision "file", source: "scripts/DeploymentConfigTemplate.xml", destination: "C:\\\\Temp\\\\DeploymentConfigTemplate.xml"\n')
253 | vagrantFile.write(' machine' + str(m.number) + '.vm.provision "shell", path: "scripts/' + str(s) + '.ps1"\n')
254 | vagrantFile.write(' machine' + str(m.number) + '.vm.provision "reload"\n')
255 | vagrantFile.write(' machine' + str(m.number) + '.vm.provision "shell", reboot: true\n')
256 | else:
257 | vagrantFile.write(' machine' + str(m.number) + '.vm.provision "shell", path: "scripts/' + str(s) + '.ps1"\n')
258 | vagrantFile.write(' end\n')
259 | vagrantFile.write("end")
260 |
261 |
262 | def run(self):
263 | self.writeVagrantFiles()
264 | for m in machineList:
265 | with open("Packer/machine" + str(m.number) + ".json", "w") as packerFile:
266 | packerFile.write("{")
267 | if len(m.roles) != 0 and m.operatingSystem.usesAnsible:
268 | packerFile.write("\"provisioners\": [{\"type\": \"ansible-local\",\"playbook_dir\": \"Packer/ansible\",\"playbook_file\": \"Packer/ansible/machine" + str(m.number) + ".yml\"}],")
269 | with open("Packer/ansible/machine" + str(m.number) + ".yml", "w") as ansibleFile:
270 | ansibleFile.write("---\n- name: \"Provision Machine " + str(m.number) + "\"\n hosts: all\n roles:")
271 | for r in m.roles:
272 | ansibleFile.write("\n - " + r.lower())
273 | ansibleFile.close()
274 | if "Ubuntu" in str(m.operatingSystem):
275 | packerFile.write("\"builders\":[{\"name\":\"Machine"+str(m.number)+"\",\"vm_name\":\"Machine"+str(m.number)+"\",\"output_directory\":\"VMs/machine"+str(m.number)+"\",\"guest_os_type\":\"Ubuntu_64\",\"type\":\"virtualbox-iso\",\"cpus\":\""+str(m.cpus)+"\",\"memory\":\""+str(m.ram)+"\",\"disk_size\":\""+str(m.hdSize)+"\",\"iso_checksum\":\"sha256:b4667b8f6d863271a014855d0f55b365f956bcdf8c691c8a3741b60d905e9647\",\"iso_urls\":[\"Packer/http/ubuntu18.iso\",\"http://archive.ubuntu.com/ubuntu/dists/bionic-updates/main/installer-amd64/current/images/netboot/mini.iso\"],\"ssh_username\":\"conda\",\"ssh_password\":\"conda\",\"ssh_wait_timeout\":\"60m\",\"headless\":\"false\",\"shutdown_command\":\"sudo shutdown -P now\",\"http_directory\":\"Packer/http\",\"boot_wait\":\"5s\",\"boot_command\":[\"\",\"url=http://{{.HTTPIP}}:{{.HTTPPort}}/ubuntu-preseed.cfg \",\"auto=true \",\"initrd=initrd.gz \",\"hostname=ubuntu \",\"\"]}],\"post-processors\": [{\"type\": \"vagrant\",\"output\": \"VMs/" + "Machine" + str(m.number) + ".box\"}]}")
276 | elif "Kali" in str(m.operatingSystem):
277 | packerFile.write("\"builders\":[{\"name\":\"Machine"+str(m.number)+"\",\"vm_name\":\"Machine"+str(m.number)+"\",\"output_directory\":\"VMs/machine"+str(m.number)+"\",\"guest_os_type\":\"Debian_64\",\"type\":\"virtualbox-iso\",\"cpus\":\""+str(m.cpus)+"\",\"memory\":\""+str(m.ram)+"\",\"disk_size\":\""+str(m.hdSize)+"\",\"iso_checksum\":\"sha256:4143128bd9cb1fb736b0171adc503aa026ed92ad3a0a9bc6dea8f559a83c36b1\",\"iso_urls\":[\"Packer/http/kali.iso\",\"https://archive.kali.org/kali-images/kali-2020.1b/kali-linux-2020.1b-installer-amd64.iso\"],\"ssh_username\":\"root\",\"ssh_password\":\"toor\",\"ssh_wait_timeout\":\"60m\",\"headless\":\"false\",\"shutdown_command\":\"shutdown -P now\",\"http_directory\":\"Packer/http\",\"boot_wait\":\"5s\",\"boot_command\":[\"\",\"install \",\"preseed/url=http://{{.HTTPIP}}:{{.HTTPPort}}/kali.cfg \",\"debian-installer=en_US auto locale=en_US kbd-chooser/method=us \",\"netcfg/get_hostname=kali \",\"netcfg/get_domain=unassigned-domain \",\"fb=falsedebconf/frontend=noninteractive \",\"console-setup/ask_detect=false \",\"console-keymaps-at/keymap=us \",\"keyboard-configuration/xkb-keymap=us \",\"\",\"\"]}],\"post-processors\": [{\"type\": \"vagrant\",\"output\": \"VMs/" + "Machine" + str(m.number) + ".box\"}]}")
278 | elif "CentOS" in str(m.operatingSystem):
279 | packerFile.write("\"builders\":[{\"name\":\"Machine"+str(m.number)+"\",\"vm_name\":\"Machine"+str(m.number)+"\",\"output_directory\":\"VMs/machine"+str(m.number)+"\",\"guest_os_type\":\"RedHat_64\",\"type\":\"virtualbox-iso\",\"cpus\":\""+str(m.cpus)+"\",\"memory\":\""+str(m.ram)+"\",\"disk_size\":\""+str(m.hdSize)+"\",\"iso_checksum\":\"sha256:9a2c47d97b9975452f7d582264e9fc16d108ed8252ac6816239a3b58cef5c53d\",\"iso_urls\":[\"Packer/http/centos7.iso\",\"http://mirrors.usc.edu/pub/linux/distributions/centos/7.7.1908/isos/x86_64/CentOS-7-x86_64-Minimal-1908.iso\"],\"ssh_username\":\"conda\",\"ssh_password\":\"conda\",\"ssh_wait_timeout\":\"60m\",\"headless\":\"false\",\"shutdown_command\":\"sudo /usr/sbin/shutdown -P now\",\"http_directory\":\"Packer/http\",\"boot_wait\":\"5s\",\"boot_command\":[\"\",\" text ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/centos.cfg \",\"auto=true \",\"initrd=initrd.img \",\"hostname=centos \",\"\"]}],\"post-processors\": [{\"type\": \"vagrant\",\"output\": \"VMs/" + "Machine" + str(m.number) + ".box\"}]}")
280 | elif "Windows 10" in str(m.operatingSystem):
281 | packerFile.write("\"builders\":[{\"name\":\"Machine"+str(m.number)+"\",\"vm_name\":\"Machine"+str(m.number)+"\",\"output_directory\":\"VMs/machine"+str(m.number)+"\",\"guest_os_type\": \"Windows10_64\",\"type\": \"virtualbox-iso\",\"cpus\": \""+str(m.cpus)+"\",\"memory\": \""+str(m.ram)+"\",\"communicator\": \"winrm\",\"iso_checksum\": \"sha256:9ef81b6a101afd57b2dbfa44d5c8f7bc94ff45b51b82c5a1f9267ce2e63e9f53\",\"iso_urls\": [\"Packer/http/win-10.iso\",\"https://software-download.microsoft.com/download/pr/18363.418.191007-0143.19h2_release_svc_refresh_CLIENTENTERPRISEEVAL_OEMRET_x64FRE_en-us.iso\"],\"winrm_username\": \"conda\",\"winrm_password\": \"Conda123!\",\"winrm_timeout\": \"2h\",\"headless\": \"false\",\"shutdown_command\": \"shutdown /s\",\"disk_size\":\""+str(m.hdSize)+"\",\"format\": \"ova\",\"http_directory\": \"Packer/http\",\"floppy_files\": [\"Packer/floppy/10/autounattend.xml\",\"Packer/floppy/10/enable-winrm.bat\"]}],\"post-processors\": [{\"type\": \"vagrant\",\"output\": \"VMs/" + "Machine" + str(m.number) + ".box\"}]}")
282 | elif "Windows 2016" in str(m.operatingSystem):
283 | packerFile.write("\"builders\":[{\"name\":\"Machine"+str(m.number)+"\",\"vm_name\":\"Machine"+str(m.number)+"\",\"output_directory\":\"VMs/machine"+str(m.number)+"\",\"guest_os_type\": \"Windows2016_64\",\"type\": \"virtualbox-iso\",\"cpus\": \""+str(m.cpus)+"\",\"memory\": \""+str(m.ram)+"\",\"communicator\": \"winrm\",\"iso_checksum\": \"md5:70721288bbcdfe3239d8f8c0fae55f1f\",\"iso_urls\": [\"Packer/http/win-2016.iso\",\"https://software-download.microsoft.com/download/pr/Windows_Server_2016_Datacenter_EVAL_en-us_14393_refresh.ISO\"],\"winrm_username\": \"Administrator\",\"winrm_password\": \"Conda123!\",\"winrm_timeout\": \"2h\",\"headless\": \"false\",\"shutdown_command\": \"shutdown /s\",\"disk_size\":\""+str(m.hdSize)+"\",\"format\": \"ova\",\"http_directory\": \"Packer/http\",\"floppy_files\": [\"Packer/floppy/2016/autounattend.xml\",\"Packer/floppy/2016/enable-winrm.bat\"]}],\"post-processors\": [{\"type\": \"vagrant\",\"output\": \"VMs/" + "Machine" + str(m.number) + ".box\"}]}")
284 | packerFile.close()
285 | # os.system("packer build Packer/machine" + str(m.number) + ".json")
286 | child = subprocess.Popen("packer build Packer/machine" + str(m.number) + ".json", shell=True, stdout = subprocess.PIPE)
287 | childData = child.communicate()[0].strip()
288 | if child.returncode == 0:
289 | self.queue.put("Completed")
290 | else:
291 | self.queue.put("Failed")
292 | self.cleanup()
293 |
294 | class Machine():
295 |
296 | def __init__(self, num):
297 | self.number = num
298 | self.name = ""
299 | self.roles = []
300 | self.scripts = []
301 | self.operatingSystem = ""
302 | self.ram = 0
303 | self.cpus = 0
304 | self.roleSet = None
305 | self.hdSize = 0
306 | self.status = False
307 |
308 | def __str__(self):
309 | return "Machine " + str(self.number)
310 |
311 | class OperatingSystem():
312 |
313 | def __init__(self, name, roleList, scriptList, usesAnsible):
314 | self.name = name
315 | self.roleList = roleList
316 | self.usesAnsible = usesAnsible
317 | self.scriptList = scriptList
318 |
319 | def __str__(self):
320 | return self.name
321 |
322 |
323 | def main():
324 | root = Tk()
325 | root.geometry("400x300")
326 | app = LabCreatorApp(root)
327 | app.mainloop()
328 |
329 |
330 | if __name__ == '__main__':
331 | osList = []
332 | osList.append(OperatingSystem("Ubuntu 18.04", ["Graphical", "Apache"], [], True))
333 | osList.append(OperatingSystem("Kali", ["Apache"], [], True))
334 | osList.append(OperatingSystem("CentOS 7", ["Graphical", "Apache"], [], True))
335 | osList.append(OperatingSystem("Windows 10", [], ["Enable RDP"], False))
336 | osList.append(OperatingSystem("Windows 2016", [], ["Domain Controller","Enable RDP"], False))
337 | machineList = []
338 | machineList.append(Machine(1))
339 | numberOfMachines = 1
340 | main()
341 |
342 |
--------------------------------------------------------------------------------