Skip to content
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ Packer an automation and provisioning tool. This repositories aims to provide us

Wiki: https://github.com/InfamousSYN/packer/wiki/

Running: `packer build -only=hyperv-iso -on-error=ask -var-file ./uservars-hyperv.json ./templates/kali-hyperv.json`
76 changes: 76 additions & 0 deletions include/preseed/kali-preseed-hyperv.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# By default the installer requires that repositories be authenticated
# using a known gpg key. This setting can be used to disable that
# authentication. Warning: Insecure, not recommended.
# d-i debian-installer/allow_unauthenticated boolean true

d-i debian-installer/locale string en_US.UTF-8
d-i console-keymaps-at/keymap select us
d-i mirror/country string enter information manually
d-i mirror/http/hostname string http.kali.org
d-i mirror/http/directory string /kali
d-i keyboard-configuration/xkb-keymap select us
d-i mirror/http/proxy string
d-i mirror/suite string kali-rolling
d-i mirror/codename string kali-rolling

d-i clock-setup/utc boolean true
d-i time/zone string UTC

# Enable contrib and non-free
d-i apt-setup/non-free boolean true
d-i apt-setup/contrib boolean true

# Disable source repositories too
d-i apt-setup/enable-source-repositories boolean false

# Partitioning
d-i partman-auto/method string regular
d-i partman-lvm/device_remove_lvm boolean true
d-i partman-md/device_remove_md boolean true
d-i partman-lvm/confirm boolean true
d-i partman-auto/choose_recipe select atomic
d-i partman-auto/disk string /dev/sda
d-i partman/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
d-i partman-partitioning/confirm_write_new_label boolean true

# Disable CDROM entries after install
d-i apt-setup/disable-cdrom-entries boolean true

# Upgrade installed packages
tasksel tasksel/first multiselect standard
d-i pkgsel/upgrade select full-upgrade

# Change default hostname
d-i netcfg/get_hostname string unassigned-hostname
d-i netcfg/get_domain string unassigned-domain
d-i netcfg/hostname string kali
d-i netcfg/choose_interface select eth0
d-i netcfg/disable_autoconfig boolean true
#d-i netcfg/dhcp_timeout string 60
d-i netcfg/get_ipaddress string 192.168.137.3
d-i netcfg/get_netmask string 255.255.255.0
d-i netcfg/get_gateway string 192.168.137.1
d-i netcfg/get_nameservers string 192.168.137.1
d-i netcfg/confirm_static boolean true

d-i hw-detect/load_firmware boolean false

# Do not create a normal user account
d-i passwd/make-user boolean false
d-i passwd/root-password password toor
d-i passwd/root-password-again password toor

d-i apt-setup/use_mirror boolean true
d-i grub-installer/only_debian boolean true
d-i grub-installer/with_other_os boolean false
d-i grub-installer/bootdev string /dev/sda

d-i finish-install/reboot_in_progress note
d-i preseed/late_command string sed -i 's/#PermitRootLogin.*/PermitRootLogin yes/g' /target/etc/ssh/sshd_config ; \
in-target update-rc.d ssh enable

# Disable popularity-contest
popularity-contest popularity-contest/participate boolean false
1 change: 1 addition & 0 deletions packer
Submodule packer added at e7a006
14 changes: 14 additions & 0 deletions scripts/common/linux/apt-hyperv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash -eux

export DEBIAN_FRONTEND=noninteractive

echo "==> Update Package Lists For Available Upgrades"
apt --assume-yes update
#fix plymouth error by not updating automatically
#echo plymouth hold | dpkg --set-selections
#echo plymouth-label hold | dpkg --set-selections
echo "==> Performing Full Distribution Upgrade"
yes "N" | apt --assume-yes full-upgrade
#echo plymouth install | dpkg --set-selections
#echo plymouth-label install | dpkg --set-selections

14 changes: 14 additions & 0 deletions scripts/common/linux/apt_reboot-hyperv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash -eux

export DEBIAN_FRONTEND=noninteractive

echo "==> Update Package Lists For Available Upgrades"
apt --assume-yes update
#fix plymouth error by not updating automatically
#echo plymouth hold | dpkg --set-selections
#echo plymouth-label hold | dpkg --set-selections
echo "==> Performing Full Distribution Upgrade"
yes "N" | apt --assume-yes full-upgrade
#echo plymouth install | dpkg --set-selections
#echo plymouth-label install | dpkg --set-selections

148 changes: 148 additions & 0 deletions templates/kali-hyperv.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
{
"variables": {
"box_name" : "vagrant-kali-rolling-amd64",
"box_desc" : "Kali Rolling x64 Desktop",
"disk_size": "40960",
"num_cpus": "2",
"memory_size": "4096",
"root_username": "root",
"root_password": "toor"
},
"description": "{{user `box_desc`}}",
"builders":[{
"type": "vmware-iso",
"iso_url": "{{user `iso_url`}}",
"iso_checksum": "{{user `iso_checksum`}}",
"iso_checksum_type": "{{user `iso_checksum_type`}}",
"vm_name": "{{user `box_name`}}",
"vmx_data": {
"memsize": 2048,
"numvcpus": 2,
"usb.present": "True",
"usb.pcislotnumber": "34"
},
"ssh_username": "{{user `root_username`}}",
"ssh_password": "{{user `root_password`}}",
"ssh_timeout": "1000000s",
"http_directory": "include/preseed",
"boot_command": [
"<esc><wait5>",
"install",
" auto",
" url=http://{{ .HTTPIP}}:{{ .HTTPPort }}/kali-preseed-hyperv.cfg",
" debian-installer=en_US",
" locale=en_US",
" keymap=us",
" hostname={{user `box_name`}}",
" domain=",
"<enter>"
],
"shutdown_command": "shutdown -P now"
},{
"type": "hyperv-iso",
"iso_url": "{{user `iso_url`}}",
"iso_checksum": "{{user `iso_checksum`}}",
"iso_checksum_type": "{{user `iso_checksum_type`}}",
"memory": "{{user `memory_size`}}",
"cpus": "{{user `num_cpus`}}",
"vm_name": "{{user `box_name`}}",
"switch_name": "{{user `network_name`}}",
"ssh_username": "{{user `root_username`}}",
"ssh_password": "{{user `root_password`}}",
"ssh_timeout": "1000000s",
"http_directory": "include/preseed",
"boot_command": [
"<esc><wait5>",
"install",
" auto",
" url=http://{{ .HTTPIP}}:{{ .HTTPPort }}/kali-preseed.cfg",
" debian-installer=en_US",
" locale=en_AU",
" keymap=us",
" hostname={{user `box_name`}}",
" domain=",
"<enter>"
],
"shutdown_command": "shutdown -P now"
},{
"type": "virtualbox-iso",
"iso_url": "{{user `iso_url`}}",
"iso_checksum": "{{user `iso_checksum`}}",
"iso_checksum_type": "{{user `iso_checksum_type`}}",
"vm_name": "{{user `box_name`}}",
"cpus": "2",
"disk_block_size": "1 MiB",
"enable_dynamic_memory": "false",
"ssh_username": "{{user `root_username`}}",
"ssh_password": "{{user `root_password`}}",
"ssh_timeout": "1000000s",
"guest_os_type": "Debian_64",
"http_directory": "include/preseed",
"boot_command": [
"<esc><wait5>",
"install",
" auto",
" url=http://{{ .HTTPIP}}:{{ .HTTPPort }}/kali-preseed.cfg",
" debian-installer=en_US",
" locale=en_US",
" keymap=us",
" hostname={{user `box_name`}}",
" domain=",
"<enter>"
],
"shutdown_command": "shutdown -P now"
}],
"provisioners": [{
"type": "shell",
"valid_exit_codes": [0, 100],
"scripts": [
"scripts/common/linux/apt_reboot-hyperv.sh"
],
"expect_disconnect": true,
"execute_command": "echo 'vagrant' | {{.Vars}} sudo -S -E sh -eux '{{.Path}}'"
},
{
"type": "shell",
"valid_exit_codes": [0, 100],
"scripts": [
"scripts/common/linux/apt-hyperv.sh",
"scripts/common/linux/vagrant.sh"
],
"pause_before": "3m",
"expect_disconnect": true,
"execute_command": "echo 'vagrant' | {{.Vars}} sudo -S -E sh -eux '{{.Path}}'"
},
{
"type": "shell",
"valid_exit_codes": [0, 100],
"only": ["vmware-iso"],
"scripts": [
"scripts/common/linux/vmtools.sh"
],
"execute_command": "echo 'vagrant' | {{.Vars}} sudo -S -E sh -eux '{{.Path}}'"
},
{
"type": "shell",
"only": ["virtualbox-iso"],
"scripts": [
"scripts/common/linux/vbguest.sh"
],
"execute_command": "echo 'vagrant' | {{.Vars}} sudo -S -E sh -eux '{{.Path}}'"
},
{
"type": "shell",
"valid_exit_codes": [0, 100],
"scripts": [
"scripts/common/linux/cleanup.sh"
],
"execute_command": "echo 'vagrant' | {{.Vars}} sudo -S -E sh -eux '{{.Path}}'"
}],
"post-processors": [{
"type": "vagrant",
"keep_input_artifact": false,
"output": "build/{{user `box_name`}}.box",
"compression_level": 6,
"include": "{{user `metadata`}}",
"vagrantfile_template": "{{user `vagrantfile`}}"
}]
}
6 changes: 6 additions & 0 deletions uservars-hyperv.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"iso_url": "d:\\Downloaded_VMs\\kali-linux-2019.2-amd64.iso",
"iso_checksum":"0f89b6225d7ea9c18682f7cc541c1179",
"iso_checksum_type":"md5",
"network_name": "Wireless"
}