Merge pull request #65 from clong/detectionlab_network

Clean up scripts and migrate to detectionlab.network
This commit is contained in:
Chris Long
2018-02-15 12:15:07 -08:00
committed by GitHub
6 changed files with 34 additions and 30 deletions

View File

@@ -28,6 +28,11 @@ jobs:
curl -X GET --header 'Accept: application/json' --header 'X-Auth-Token: '"$PACKET_API_TOKEN" "https://api.packet.net/devices/$DEVICE_ID/ips" > /tmp/ip_info; curl -X GET --header 'Accept: application/json' --header 'X-Auth-Token: '"$PACKET_API_TOKEN" "https://api.packet.net/devices/$DEVICE_ID/ips" > /tmp/ip_info;
- run: cat /tmp/ip_info | jq ."ip_addresses[0].address" | tr -d '"' > /tmp/ip_address - run: cat /tmp/ip_info | jq ."ip_addresses[0].address" | tr -d '"' > /tmp/ip_address
- run: cd ~/repo - run: cd ~/repo
- run:
name: Copying DetectionLab repo to Packet server
command: |
export IP_ADDRESS=$(cat /tmp/ip_address);
scp -i ~/.ssh/id_rsa -r ~/repo root@"$IP_ADDRESS":/opt/DetectionLab
- run: - run:
name: Copying install script to Packet server name: Copying install script to Packet server
command: | command: |

View File

@@ -60,10 +60,10 @@ There are two build scripts:
Provider | Box | URL | MD5 | Size Provider | Box | URL | MD5 | Size
------------|-----|-----|----|---- ------------|-----|-----|----|----
Virtualbox |Windows 2016 | https://www.dropbox.com/s/u2hbtv0ynf1pei8/windows_2016_virtualbox.box?dl=1 | 614f984c82b51471b5bb753940b59d38 | 6.4GB Virtualbox |Windows 2016 | https://www.detectionlab.network/windows_2016_virtualbox.box | 614f984c82b51471b5bb753940b59d38 | 6.4GB
Virtualbox | Windows 10 | https://www.dropbox.com/s/zt30zod4e0etug7/windows_10_virtualbox.box?dl=1 | 30b06e30b36b02ccf1dc5c04017654aa | 5.8GB Virtualbox | Windows 10 | https://www.detectionlab.network/windows_10_virtualbox.box | 30b06e30b36b02ccf1dc5c04017654aa | 5.8GB
VMware | Windows 2016 | https://www.dropbox.com/s/tvtl2r71amngnjs/windows_2016_vmware.box?dl=1 | 1511b9dc942c69c2cc5a8dc471fa8865 | 6.7GB VMware | Windows 2016 | https://www.detectionlab.network/windows_2016_vmware.box | 1511b9dc942c69c2cc5a8dc471fa8865 | 6.7GB
VMware | Windows 10 | https://www.dropbox.com/s/9zqxn6lrryzow4v/windows_10_vmware.box?dl=1 | 174ad0f0fd2089ff74a880c6dadac74c | 6.0GB VMware | Windows 10 | https://www.detectionlab.network/windows_10_vmware.box | 174ad0f0fd2089ff74a880c6dadac74c | 6.0GB
If you choose to download the boxes, you may skip steps 2 and 3. If you don't trust pre-built boxes, I recommend following steps 2 and 3 to build them on your machine. If you choose to download the boxes, you may skip steps 2 and 3. If you don't trust pre-built boxes, I recommend following steps 2 and 3 to build them on your machine.

View File

@@ -15,18 +15,23 @@ print_usage() {
} }
check_packer_and_vagrant() { check_packer_and_vagrant() {
# Check for existence of Vagrant and Packer in PATH # Check for existence of Vagrant in PATH
which vagrant > /dev/null which vagrant > /dev/null
if [ "$?" -ne 0 ]; then if [ "$?" -ne 0 ]; then
echo "Vagrant was not found in your PATH." (>&2 echo "Vagrant was not found in your PATH.")
echo "Please correct this before continuing. Quitting." (>&2 echo "Please correct this before continuing. Quitting.")
exit 1 exit 1
fi fi
# Ensure Vagrant >= 2.0.0
if [ "$(vagrant --version | grep -o "[0-9]" | head -1)" -lt 2 ]; then
(>&2 echo "WARNING: It is highly recommended to use Vagrant 2.0.0 or above before continuing")
fi
# Check for existence of Packer in PATH
which packer > /dev/null which packer > /dev/null
if [ "$?" -ne 0 ]; then if [ "$?" -ne 0 ]; then
echo "Packer was not found in your PATH." (>&2 echo "Packer was not found in your PATH.")
echo "Please correct this before continuing. Quitting." (>&2 echo "Please correct this before continuing. Quitting.")
echo "Hint: sudo cp ./packer /usr/local/bin/packer; sudo chmod +x /usr/local/bin/packer" (>&2 echo "Hint: sudo cp ./packer /usr/local/bin/packer; sudo chmod +x /usr/local/bin/packer")
exit 1 exit 1
fi fi
} }
@@ -129,7 +134,7 @@ preflight_checks() {
(>&2 echo "") (>&2 echo "")
fi fi
# Check Packer version against known bad # Check Packer version against known bad
if [ $(packer --version) == '1.1.2' ]; then if [ "$(packer --version)" == '1.1.2' ]; then
(>&2 echo "Packer 1.1.2 is not supported. Please upgrade to a newer version and see https://github.com/hashicorp/packer/issues/5622 for more information.") (>&2 echo "Packer 1.1.2 is not supported. Please upgrade to a newer version and see https://github.com/hashicorp/packer/issues/5622 for more information.")
exit 1 exit 1
fi fi

View File

@@ -15,13 +15,17 @@ print_usage() {
} }
check_vagrant() { check_vagrant() {
# Check for existence of Vagrant and Packer in PATH # Check for existence of Vagrant in PATH
which vagrant > /dev/null which vagrant > /dev/null
if [ "$?" -ne 0 ]; then if [ "$?" -ne 0 ]; then
echo "Vagrant was not found in your PATH." (>&2 echo "Vagrant was not found in your PATH.")
echo "Please correct this before continuing. Quitting." (>&2 echo "Please correct this before continuing. Quitting.")
exit 1 exit 1
fi fi
# Ensure Vagrant >= 2.0.0
if [ "$(vagrant --version | grep -o "[0-9]" | head -1)" -lt 2 ]; then
(>&2 echo "WARNING: It is highly recommended to use Vagrant 2.0.0 or above before continuing")
fi
} }
# Returns 0 if not installed or 1 if installed # Returns 0 if not installed or 1 if installed
@@ -110,8 +114,7 @@ preflight_checks() {
# Check to see if boxes exist already # Check to see if boxes exist already
BOXES_BUILT=$(ls -al "$DL_DIR"/Boxes/*.box 2> /dev/null | wc -l) BOXES_BUILT=$(ls -al "$DL_DIR"/Boxes/*.box 2> /dev/null | wc -l)
if [ $BOXES_BUILT -gt 0 ]; then if [ $BOXES_BUILT -gt 0 ]; then
(>&2 echo "You appear to have already built at least one box using Packer. This script automatically downloads them for you. Please either delete the existing boxes or follow the build steps in the README to continue.") (>&2 echo "WARNING: You seem to have boxes present in the Boxes/ directory already. If you would like fresh boxes downloaded, please remove all files from the Boxes/ directory and re-run this script.")
exit 1
fi fi
# Check to see if any Vagrant instances exist already # Check to see if any Vagrant instances exist already
cd "$DL_DIR"/Vagrant/ cd "$DL_DIR"/Vagrant/
@@ -139,17 +142,17 @@ preflight_checks() {
fi fi
} }
# Downloads pre-build Packer boxes from S3 to save time during CI builds # Downloads pre-built Packer boxes from detectionlab.network to save time during CI builds
download_boxes() { download_boxes() {
DL_DIR="$1" DL_DIR="$1"
PROVIDER="$2" PROVIDER="$2"
if [ "$PROVIDER" == "virtualbox" ]; then if [ "$PROVIDER" == "virtualbox" ]; then
wget "https://www.dropbox.com/s/u2hbtv0ynf1pei8/windows_2016_virtualbox.box?dl=1" -O "$DL_DIR"/Boxes/windows_2016_virtualbox.box wget "https://www.detectionlab.network/windows_2016_virtualbox.box" -O "$DL_DIR"/Boxes/windows_2016_virtualbox.box
wget "https://www.dropbox.com/s/zt30zod4e0etug7/windows_10_virtualbox.box?dl=1" -O "$DL_DIR"/Boxes/windows_10_virtualbox.box wget "https://www.detectionlab.network/windows_10_virtualbox.box" -O "$DL_DIR"/Boxes/windows_10_virtualbox.box
elif [ "$PROVIDER" == "vmware_fusion" ]; then elif [ "$PROVIDER" == "vmware_fusion" ]; then
wget "https://www.dropbox.com/s/tvtl2r71amngnjs/windows_2016_vmware.box?dl=1" -O "$DL_DIR"/Boxes/windows_2016_vmware.box wget "https://www.detectionlab.network/windows_2016_vmware.box" -O "$DL_DIR"/Boxes/windows_2016_vmware.box
wget "https://www.dropbox.com/s/9zqxn6lrryzow4v/windows_10_vmware.box?dl=1" -O "$DL_DIR"/Boxes/windows_10_vmware.box wget "https://www.detectionlab.network/windows_10_vmware.box" -O "$DL_DIR"/Boxes/windows_10_vmware.box
fi fi
# Hacky workaround # Hacky workaround

View File

@@ -35,11 +35,6 @@ wget https://releases.hashicorp.com/packer/1.1.3/packer_1.1.3_linux_amd64.zip
unzip packer_1.1.3_linux_amd64.zip unzip packer_1.1.3_linux_amd64.zip
cp packer /usr/local/bin/packer cp packer /usr/local/bin/packer
# Clone DetectionLab
cd /opt
git clone https://github.com/clong/DetectionLab.git
cd /opt/DetectionLab/Packer
# Make the packer images headless # Make the packer images headless
for file in $(ls *.json); do for file in $(ls *.json); do
sed -i 's/"headless": false,/"headless": true,/g' "$file"; sed -i 's/"headless": false,/"headless": true,/g' "$file";

View File

@@ -28,10 +28,6 @@ wget https://releases.hashicorp.com/vagrant/2.0.1/vagrant_2.0.1_x86_64.deb
dpkg -i vagrant_2.0.1_x86_64.deb dpkg -i vagrant_2.0.1_x86_64.deb
vagrant plugin install vagrant-reload vagrant plugin install vagrant-reload
# Clone DetectionLab
cd /opt
git clone https://github.com/clong/DetectionLab.git
# Make the Vagrant instances headless # Make the Vagrant instances headless
cd /opt/DetectionLab/Vagrant cd /opt/DetectionLab/Vagrant
sed -i 's/vb.gui = true/vb.gui = false/g' Vagrantfile sed -i 's/vb.gui = true/vb.gui = false/g' Vagrantfile