-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsuasploitable-cloud.pkr.hcl
121 lines (109 loc) · 4.03 KB
/
suasploitable-cloud.pkr.hcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
variable "ssh_password" {
type = string
default = "vagrant"
}
variable "output_directory" {
type = string
default = "build-suasploitable-cloud"
}
# Some sources:
# https://github.com/multani/packer-qemu-debian/tree/master
source "qemu" "suasploitable-cloud" {
iso_url = "https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-12.8.0-amd64-netinst.iso"
iso_checksum = "04396d12b0f377958a070c38a923c227832fa3b3e18ddc013936ecf492e9fbb3"
output_directory = "${var.output_directory}"
shutdown_command = "echo '${var.ssh_password}' | sudo -S /sbin/shutdown -hP now"
disk_size = "40G"
format = "qcow2"
cpus = "4"
memory = "4096"
accelerator = "kvm"
http_directory = "http"
http_port_min = "9000"
http_port_max = "9010"
ssh_username = "vagrant"
ssh_password = "${var.ssh_password}"
ssh_timeout = "20m"
host_port_min = "2000"
host_port_max = "2010"
vm_name = "suasploitable_cloud.qcow2"
net_device = "virtio-net"
disk_interface = "virtio"
boot_wait = "5s"
headless = "true"
boot_command = [
"<down><tab>",
"preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/suasploitable-basic-preseed.cfg ",
"language=en locale=de_DE.UTF-8 ",
"country=DE keymap=de ",
"hostname=debian domain=example.com ",
"<enter><wait>"]
}
# Necessary:
# https://askubuntu.com/questions/1309029/qemu-display-gtk-and-display-sdl-not-available-ubuntu-20-04-1-lts
build {
sources = ["source.qemu.suasploitable-cloud"]
# Installation scripts
provisioner "file" {
sources = [
"scripts/programs/docker.sh",
"scripts/programs/suasploitable/certs.sh",
"scripts/programs/suasploitable/cloud/seafile.sh",
"scripts/programs/suasploitable/cloud/nextcloud.sh",
"scripts/programs/suasploitable/web/lamp.sh",
"scripts/programs/suasploitable/web/lemp.sh",
"scripts/programs/suasploitable/web/db/db_install.sh",
"scripts/programs/suasploitable/web/db/db_secure.sh",
"scripts/programs/suasploitable/web/db/mariadb.sh",
"scripts/programs/suasploitable/web/db/mysql.sh",
"scripts/programs/suasploitable/web/php/php-apache.sh",
"scripts/programs/suasploitable/web/php/php-composer.sh",
"scripts/programs/suasploitable/web/php/php-nginx.sh",
"scripts/programs/suasploitable/web/webserver/apache.sh",
"scripts/programs/suasploitable/web/webserver/apache-tls.sh",
"scripts/programs/suasploitable/web/webserver/nginx.sh",
"files/nextcloud/nextcloud_apache.conf",
"files/nextcloud/nextcloud_apache_tls.conf",
"files/nextcloud/nextcloud_nginx.conf",
"files/nextcloud/nextcloud_nginx_tls.conf",
"files/seafile_compose.yml",
"files/ca/suaseclab.de.2048.crt",
"files/ca/suaseclab.de.2048.key",
"files/ca/suaseclab.de.4096.crt",
"files/ca/suaseclab.de.4096.key"
]
destination = "/tmp/"
}
# Set hostname
provisioner "shell" {
execute_command = "echo 'packer' | sudo -S env {{ .Vars }} {{ .Path }}"
inline = ["hostnamectl set-hostname cloud.suaseclab.de"]
}
# Install and set up programs
provisioner "shell" {
environment_vars = ["DEBIAN_FRONTEND=noninteractive"]
execute_command = "echo 'packer' | sudo -S env {{ .Vars }} {{ .Path }}"
scripts = [
# Install programs first
"scripts/programs/suasploitable/environment.sh",
"scripts/programs/suasploitable/unattended-upgrades.sh",
# Set up main system
"scripts/autostart.sh",
"scripts/programs/suasploitable/ssh.sh",
# Install cloud: Either SeaFile or Nextcloud. NC with either LAMP or LEMP stack
"scripts/programs/suasploitable/cloud/install.sh",
# Fix permissions (must be called last)
"scripts/permissions.sh",
]
}
# Save configuration and flags
provisioner "file" {
sources = [
"/tmp/apps.txt",
"/tmp/configuration.txt",
"/tmp/flags.txt"
]
destination = "${var.output_directory}/"
direction = "download"
}
}