Skip to content

Fix/updating packer images and other fixes #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,9 @@ private.yml
playbook.retry
.vagrant
roles/*.*/**/*
vagrant.log
vagrant.log
.vs/
*.cer
*.key
*.pem
*.ovpn.*
51 changes: 20 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,21 @@ CTF environment provisioned by vagrant
* vagrant
* packer

# My ctf environment
This sets up a ctf environment i've been using ad-hoc for a little while. Its not perfect but enough to get you up and running.

Some things I do are:
* Always use private internet access for a vpn. (Other vpn services are available)
* Use Dropbox to share ctf files between VMs. This is my persistant storage with all my previous ctf problems and solutions.
* Do most of my work in the ubuntu VM. Kali for pen testing tools, and windows for when its required
* For socat binaries I use the ctfrun script in the tools directory - obsolute, now i use pwntools gdb.

# setup
# Building
Build the required vagrant box file with packer

(linux)./setup.sh

or if windows host:
(windows) .\setup.bat
```bash
(linux)./setup.sh

# configuration
or if windows host:
(windows) .\setup.bat
```

# Runing
```bash
vagrant up [ctf-ubuntu, ctf-win, ctf-kali]
```
## Configuration
Modify `group_vars\private.yml` to include the following optional variables for ansible in ctf-ubuntu. Note this file does not exist and is set in .gitignore so it isn't accidentaly commited to the repo.

---
Expand All @@ -34,7 +31,7 @@ Modify `group_vars\private.yml` to include the following optional variables for
git_username: '<username_here>'
git_email: '<email_here>'

# Conditional Installs
## Conditional Installs

* Binaryninja Linux
1. Requires BinaryNinja.zip in host-share directory
Expand All @@ -48,32 +45,24 @@ Modify `group_vars\private.yml` to include the following optional variables for
1. Requires idaprocw*.exe in host-share directory
1. Requires ida-password.txt in host-share directory

# run
# My ctf environment
This sets up a ctf environment i've been using ad-hoc for a little while. Its not perfect but enough to get you up and running.

vagrant up [ctf-ubuntu, ctf-win, ctf-kali]
Some things I do are:
* Always use private internet access for a vpn. (Other vpn services are available)
* Use Dropbox to share ctf files between VMs. This is my persistant storage with all my previous ctf problems and solutions.
* Do most of my work in the ubuntu VM. Kali for pen testing tools, and windows for when its required

# notes / issues

Main issue is lack of support in mainline vagrant for enhanced session mode in Hyper-V. I have submitted a pull request but it has not been actioned yet. You can get this experience by checkout out that vagrant branch. https://github.com/hashicorp/vagrant/pull/11014

Make sure you have ruby 2.6 or later installed. Tested with 2.6.6

You also need bsdtar. For this i installed Vagrant via the installer then copied the included bsdtar to `C:\Windows\System32`. The default location is `C:\HashiCorp\Vagrant\embedded\mingw64\bin\bsdtar.exe`

```
this_dir> pushd ..
parent_dir> git clone --single-branch --branch hyper-v-enhanced-session-transport-type [email protected]:camjjack/vagrant.git
parent_dir> cd vagrant
vagrant_dir> bundle install
vagrant_dir> bundle --binstubs exec
parent_dir> popd
this_dir>ruby ..\vagrant\exec\vagrant up ctf-ubuntu
```

* Kali box file does not exist for hyper-v and i haven't created one yet. so `vagrant up` or `vagrant up ctf-kali` will not work on windows.

# ctf-ubuntu
1. Default user is vagrant
1. Default password is vagrant
1. Tools located in ~/tools/
1. i3 wm is available
1. i3 wm is available
95 changes: 66 additions & 29 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
require 'socket'
host_address = IPAddr.new(Socket.ip_address_list.find { |ai| ai.ipv4? && !ai.ipv4_loopback? }.ip_address)
range = host_address.mask(20)
dhcp_start = range | "0.0.1.10"
dhcp_end = dhcp_start | "0.0.0.100"
gateway = range | "0.0.0.1"

Vagrant.configure("2") do |config|
config.vm.define "ctf-ubuntu" do |ubuntu|

ubuntu.vm.box = "ubuntu-20.04"

config.vm.define "ctf-ubuntu" do |ubuntu|
ubuntu.vm.box = "ubuntu-enhanced"
ubuntu.vm.hostname = "invalid-ctf"
ubuntu.ssh.username = 'vagrant'
ubuntu.ssh.password = 'vagrant'
Expand All @@ -16,6 +22,7 @@ Vagrant.configure("2") do |config|

ubuntu.vm.synced_folder "host-share", "/media/host-share"

ubuntu.vm.network "public_network", bridge: "Default Switch"
ubuntu.vm.provider "virtualbox" do |vb|
vb.cpus = 2
vb.memory = 4096
Expand All @@ -30,46 +37,24 @@ Vagrant.configure("2") do |config|
vb.customize ["modifyvm", :id, "--usb", "on"]
vb.gui = true
end
ubuntu.vm.network "public_network", bridge: "Default Switch"
ubuntu.vm.provider "hyperv" do |hv|
hv.linked_clone = true
hv.vm_integration_services = {
guest_service_interface: true
}
hv.enable_enhanced_session_mode = true
end
end

config.vm.define "hackmanite" do |ubuntu|

ubuntu.vm.box = "ubuntu-20.04"
ubuntu.vm.hostname = "hackmanite-pc"
ubuntu.ssh.username = 'vagrant'
ubuntu.ssh.password = 'vagrant'
ubuntu.ssh.forward_agent = true
ubuntu.vm.provision "ansible_local" do |ansible|
ansible.playbook = "playbook.yml"
end

ubuntu.vm.synced_folder "host-share", "/media/host-share"

ubuntu.vm.network "public_network", bridge: "Default Switch"
ubuntu.vm.provider "hyperv" do |hv|
hv.linked_clone = true
hv.vm_integration_services = {
guest_service_interface: true
}
hv.enable_virtualization_extensions = true
hv.enable_enhanced_session_mode = true
end
end

config.vm.define "ctf-win" do |win|
win.vm.box = "windows-10"
win.vm.box = "windows"
win.vm.hostname = "invalid-ctf-win"
win.vm.communicator = "winrm"
win.vm.provision "shell", path: "windows/installChocolatey.ps1"
win.vm.provision "shell", path: "windows/installBoxStarter.bat"
win.vm.provision "shell", inline: "Install-BoxStarterPackage -PackageName c:\\vagrant\\windows\\BoxstarterGist.txt -DisableReboots"
win.vm.provision "shell", inline: "Install-BoxStarterPackage -PackageName c:\\vagrant\\windows\\BoxstarterGistCustom.txt -DisableReboots"

win.vm.provider "virtualbox" do |vb|
vb.cpus = 4
Expand All @@ -96,7 +81,7 @@ Vagrant.configure("2") do |config|
end
end
config.vm.define "ctf-kali" do |kali|
kali.vm.box = "unisec/kali-linux-2017.1-amd64"
kali.vm.box = "kalilinux/rolling"
kali.vm.hostname = "invalid-ctf-kali"
kali.vm.provision "ansible_local" do |ansible|
ansible.playbook = "kali-playbook.yml"
Expand All @@ -122,4 +107,56 @@ Vagrant.configure("2") do |config|
hv.linked_clone = true
end
end
config.vm.define "arch" do |arch|
arch.vm.box = "arch-desktop"
arch.vm.hostname = "arch-dev"
arch.ssh.username = 'vagrant'
arch.ssh.password = 'vagrant'
arch.ssh.forward_agent = true
arch.vm.provision "shell" do |update|
update.inline = "pacman -Syu --noconfirm"
update.reboot = true
end
arch.vm.provision "ansible_local" do |ansible|
ansible.install_mode = "pip3"
ansible.playbook = "playbook.yml"
ansible.galaxy_role_file = "requirements.yml"
end

arch.vm.synced_folder ".", "/vagrant", type: "rsync", rsync__exclude: [".git/", "packer-templates/"]

arch.vm.network "public_network", bridge: "WSL"
arch.vm.provider "hyperv" do |hv|
hv.vm_integration_services = {
guest_service_interface: true
}
hv.enable_virtualization_extensions = true
hv.enable_enhanced_session_mode = true
# dynamic memory causes systemd-journal to use 99% cpu
# on the fix: https://github.com/torvalds/linux/commit/96d9d1fa5cd505078534113308ced0aa56d8da58#diff-69ad06175a1bd732f670c8a14108b9bc7aaee781daae61c4d65c6146933a3de4
# lands in a downstream kernel we can remove this
hv.memory = 4096
end
end
config.vm.define "vyos" do |vyos|
vyos.vm.box = "vyos"
vyos.vm.hostname = "vyos"
vyos.ssh.username = 'vyos'
vyos.ssh.password = 'vagrant'
vyos.ssh.forward_agent = true
vyos.vm.provision "shell" do |s|
s.path = "scripts/vyos-dhcp.sh"
s.env = {:RANGE => range.to_s() + "/20",
:DEFAULT_ROUTER => gateway.to_s(),
:DHCP_START => dhcp_start.to_s(),
:DHCP_END => dhcp_end.to_s(),
:NAMESERVER => gateway.to_s(),
:DOMAIN_NAME => "vyos.net"
}
end

vyos.vm.synced_folder ".", "/vagrant", type: "rsync", rsync__exclude: [".git/", "packer-templates/"]

vyos.vm.network "public_network", bridge: "WSL"
end
end
15 changes: 2 additions & 13 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,5 @@ jobs:

- powershell: |
Import-Module C:\ProgramData\Boxstarter\Boxstarter.Chocolatey
#Install-BoxStarterPackage -PackageName "c:\vagrant\windows\BoxstarterGist.txt" -DisableReboots
displayName: 'Run BoxStarter'

- powershell: choco install -y c:\vagrant\windows\chocolatey\wsl2\wsl2.nuspec
displayName: 'Install wsl2'

- powershell: |
choco pack c:\vagrant\windows\chocolatey\ghidra\ghidra.nuspec -out c:\vagrant\windows\chocolatey\ghidra\
choco install -y --source="c:\vagrant\windows\chocolatey\;https://chocolatey.org/api/v2" ghidra --version=9.1.2
displayName: 'Install Ghidra'

- powershell: choco install -y c:\vagrant\windows\chocolatey\metasploit-framework\metasploit-framework.nuspec
displayName: 'Install metasploit-framework'
Install-BoxStarterPackage -PackageName "c:\vagrant\windows\BoxstarterGistCustom.txt" -DisableReboots -StopOnPackageFailure
displayName: 'Run BoxStarter'
7 changes: 6 additions & 1 deletion group_vars/all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ home_dir: '/home/{{ vagrant_user }}/'
tool_dir: '{{ home_dir }}tools/'
tool_bin_dir: '{{ tool_dir }}bin/'
bash_rc: '{{ home_dir }}.bashrc'
zsh_rc: '{{ home_dir }}.zshrc'

#vagrant host hare directory
# relative to VagrantFile
local_share_dir: host-share
vagrant_share_dir: '/media/{{ local_share_dir }}/'
vagrant_share_dir: '/vagrant/{{ local_share_dir }}/'

i3_config_dir: '{{ home_dir }}.config/i3/'
i3_config_location: '{{ i3_config_dir }}config'
zshrc: '{{ home_dir }}.zshrc'
2 changes: 1 addition & 1 deletion packer-templates
Submodule packer-templates updated 64 files
+39 −7 README.md
+32 −0 arch-desktop.pkr.hcl
+29 −0 arch-variables.pkr.hcl
+71 −0 arch.pkr.hcl
+6 −13 azure-pipelines.yml
+134 −130 build-windows.ps1
+5 −6 build-windows.sh
+257 −196 build.ps1
+7 −9 build.sh
+0 −177 hyperv-windows-10.json
+1 −1 install-latest-packer.sh
+0 −3 preseed/README.md
+0 −11 preseed/preseed-overwrites.cfg
+0 −481 preseed/preseed.cfg
+0 −2 preseed/server.cfg
+3 −0 scripts/arch/ansible.sh
+9 −0 scripts/arch/aur.sh
+14 −0 scripts/arch/cleanup.sh
+12 −0 scripts/arch/desktop.sh
+49 −0 scripts/arch/enhanced-session-mode.sh
+10 −0 scripts/arch/hyperv.sh
+6 −0 scripts/arch/update.sh
+14 −0 scripts/arch/zsh.sh
+0 −9 scripts/fix-locale.sh
+1 −1 scripts/ubuntu/ansible.sh
+0 −0 scripts/ubuntu/cleanup.sh
+0 −0 scripts/ubuntu/desktop.sh
+1 −1 scripts/ubuntu/disable-daily-update.sh
+1 −1 scripts/ubuntu/hyperv-enhanced-after-reboot.sh
+0 −0 scripts/ubuntu/hyperv-enhanced.sh
+0 −0 scripts/ubuntu/update.sh
+0 −0 scripts/ubuntu/vagrant.sh
+0 −1 scripts/ubuntu/virtualbox.sh
+9 −0 scripts/vyos/cleanup.sh
+13 −0 scripts/vyos/dhcp.sh
+11 −0 scripts/vyos/vagrant.sh
+64 −61 setup-enhanced-transport-type.ps1
+10 −0 templates/enable-ssh.sh.pkrtpl.hcl
+68 −0 templates/install-chroot.sh.pkrtpl.hcl
+42 −0 templates/install.sh.pkrtpl.hcl
+23 −0 templates/user-data.pkrtpl.hcl
+0 −63 ubuntu-desktop.json
+38 −0 ubuntu-desktop.pkr.hcl
+0 −63 ubuntu-enhanced.json
+33 −0 ubuntu-enhanced.pkr.hcl
+0 −204 ubuntu.json
+118 −0 ubuntu.pkr.hcl
+108 −0 variables.pkr.hcl
+64 −0 vyos-variables.pkr.hcl
+97 −0 vyos.pkr.hcl
+28 −0 windows-variables.pkr.hcl
+76 −0 windows.pkr.hcl
+170 −170 windows/answer_files/autounattend.xml
+1 −1 windows/answer_files/virtualbox/autounattend.xml
+10 −10 windows/floppy/fixnetwork.ps1
+11 −11 windows/floppy/powerUserSettings.ps1
+9 −9 windows/floppy/winrm.ps1
+37 −37 windows/scripts/compile-dotnet-assemblies.ps1
+3 −3 windows/scripts/defrag.ps1
+1 −1 windows/scripts/enable-hyperv.ps1
+27 −27 windows/scripts/install-chocolatey.ps1
+1 −1 windows/scripts/install-virtualbox-guest-additions.ps1
+66 −66 windows/scripts/mkiso.ps1
+29 −30 windows/scripts/scrub.ps1
Loading