From 18bdcddae4aa0d568573e3758bfaed8c4d59c65d Mon Sep 17 00:00:00 2001 From: Steve Clement Date: Mon, 19 Nov 2018 09:14:10 +0900 Subject: [PATCH] new: [core] Initial split up of some of the scripts. new: [core] Added issue file. new: [eth0] Added script to rename weird Network name to ethX --- conffiles/issue | 28 ++++++++++++++++++++++++++++ misp.json | 23 ++++++++++++++++++++++- scripts/bootstrap.sh | 11 ----------- scripts/clean.sh | 14 ++++++++++++++ scripts/interfaces.sh | 22 ++++++++++++++++++++++ scripts/users.sh | 12 ++++++++++++ 6 files changed, 98 insertions(+), 12 deletions(-) create mode 100644 conffiles/issue create mode 100644 scripts/clean.sh create mode 100644 scripts/interfaces.sh create mode 100644 scripts/users.sh diff --git a/conffiles/issue b/conffiles/issue new file mode 100644 index 0000000..c8a69ec --- /dev/null +++ b/conffiles/issue @@ -0,0 +1,28 @@ +Ubuntu 18.04.1 LTS \n \l + +Welcome to the MISP Threat Sharing VM. +--- + +IP address: \4{eth0} + +--- + +MISP http://\4{eth0} admin@admin.test / admin + https://\4{eth0} +MISP-modules (API) http://\4{eth0}:6666 (no credentials) +MISP-dashboard http://\4{eth0}:8001 (no credentials) +Viper-web http://\4{eth0}:8888 admin / Password1234 +jupyter-notebook http://\4{eth0}:8889 + +The default system credentials are: misp / Password1234 + +On VirtualBox port-forwarding from your host to the guest is in place. +Below are the forwards as we need to use ports >1024 for some. + +MISP -> 8080 and :8443 +ssh -> 2222 +misp-modules -> 1666 + +If this fails, make sure the host machine is not occupying one of the forwarded ports or a firewall is active. + +---- diff --git a/misp.json b/misp.json index 2780af2..8b8eb65 100644 --- a/misp.json +++ b/misp.json @@ -147,12 +147,33 @@ "echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers" ] }, + { + "type": "shell", + "execute_command" : "echo '{{user `ssh_pass`}}' | {{ .Vars }} sudo -E -S sh '{{ .Path }}'", + "script": "scripts/users.sh" + }, + { + "type": "shell", + "execute_command" : "echo '{{user `ssh_pass`}}' | {{ .Vars }} sudo -E -S sh '{{ .Path }}'", + "script": "scripts/interfaces.sh" + }, { "type": "shell", "execute_command" : "echo '{{user `ssh_pass`}}' | {{ .Vars }} sudo -E -S sh '{{ .Path }}'", "script": "scripts/bootstrap.sh", "pause_before": "10s" - }], + }, + { + "type": "file", + "source" : "conffiles/issue", + "destination": "/tmp/issue" + }, + { + "type": "shell", + "execute_command" : "echo '{{user `ssh_pass`}}' | {{ .Vars }} sudo -E -S sh '{{ .Path }}'", + "script": "scripts/clean.sh" + } + ], "post-processors":[{ "keep_input_artifact": "false", diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh index cccd8a1..d14a6cb 100644 --- a/scripts/bootstrap.sh +++ b/scripts/bootstrap.sh @@ -94,14 +94,6 @@ PHP_INI='/etc/php/7.2/apache2/php.ini' echo "--- Installing MISP… ---" -# echo "--- Configuring GRUB ---" -# -# for key in GRUB_CMDLINE_LINUX -# do -# sudo sed -i "s/^\($key\)=.*/\1=\"$(eval echo \${$key})\"/" $DEFAULT_GRUB -# done -# sudo grub-mkconfig -o /boot/grub/grub.cfg - echo "--- Updating packages list ---" sudo apt-get -qq update > /dev/null 2>&1 @@ -790,9 +782,6 @@ echo "--- Ignoring filemode on all submodules ---" cd $PATH_TO_MISP sudo -u www-data git submodule foreach --recursive git config core.filemode false > /dev/null 2>&1 -echo "--- autoremove for apt ---" -apt-get autoremove > /dev/null 2>&1 - echo "--- Setting Baseurl and making sure Sessions do NOT auto regenerate ---" $CAKE Baseurl "" > /dev/null 2>&1 $CAKE Admin setSetting "Session.autoRegenerate" 0 > /dev/null 2>&1 diff --git a/scripts/clean.sh b/scripts/clean.sh new file mode 100644 index 0000000..7b3f5cf --- /dev/null +++ b/scripts/clean.sh @@ -0,0 +1,14 @@ +#! /usr/bin/env bash + +cp /tmp/issue /etc/issue + +# package +echo "--- autoremove for apt ---" +apt-get -y autoremove > /dev/null 2>&1 + +echo "--- Cleaning packages" +apt-get -y clean > /dev/null 2>&1 + +# End Cleaning +echo "VM cleaned" + diff --git a/scripts/interfaces.sh b/scripts/interfaces.sh new file mode 100644 index 0000000..682371c --- /dev/null +++ b/scripts/interfaces.sh @@ -0,0 +1,22 @@ +#! /usr/bin/env bash + +echo "--- Using old style name (ethX) for interfaces" +sed -r 's/^(GRUB_CMDLINE_LINUX=).*/\1\"net\.ifnames=0\ biosdevname=0\"/' /etc/default/grub | sudo tee /etc/default/grub > /dev/null + + +# install ifupdown since ubuntu 18.04 +sudo apt-get update +sudo apt-get install -y ifupdown + + +# enable eth0 +echo "--- Configuring eth0" + +cat >> /etc/network/interfaces << EOF +# The primary network interface +auto eth0 +iface eth0 inet dhcp +EOF + + +update-grub > /dev/null 2>&1 diff --git a/scripts/users.sh b/scripts/users.sh new file mode 100644 index 0000000..0700aba --- /dev/null +++ b/scripts/users.sh @@ -0,0 +1,12 @@ +#! /usr/bin/env bash + +##echo "--- Creating thehive user" +##useradd -U -G sudo -m -s /bin/bash thehive +##echo -e "thehive1234\nthehive1234" | passwd thehive + +echo "--- Configuring sudo " +##echo %thehive ALL=NOPASSWD:ALL > /etc/sudoers.d/thehive +echo %misp ALL=NOPASSWD:ALL > /etc/sudoers.d/misp +##chmod 0440 /etc/sudoers.d/thehive +chmod 0440 /etc/sudoers.d/misp +