From f54a2c931aee1122f4e86bd5d7b96c713953b7cc Mon Sep 17 00:00:00 2001 From: Carla Kirk-Cohen Date: Thu, 11 Apr 2024 14:43:19 -0400 Subject: [PATCH] templates: add script to copy and run golang program --- templates/README.md | 12 ++++++++++++ templates/copy_and_run_golang.sh | 17 +++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 templates/README.md create mode 100755 templates/copy_and_run_golang.sh diff --git a/templates/README.md b/templates/README.md new file mode 100644 index 0000000..28932c9 --- /dev/null +++ b/templates/README.md @@ -0,0 +1,12 @@ +# Attack Templates + +This directory contains template code that can be used for your attack. +Feel free to change it however you like, or not use it at all! + +We currently have support for: +- [Golang](/golang) + +A "copy and run" script is provided for each template, which will: +* Copy the code in your working directory into the `flagship` container +* Update `run.sh` with execution commands (if not already present) +* Run `./run.sh` inside of the container diff --git a/templates/copy_and_run_golang.sh b/templates/copy_and_run_golang.sh new file mode 100755 index 0000000..9b9ed20 --- /dev/null +++ b/templates/copy_and_run_golang.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +echo "Removing old golang code in container" +kubectl exec -it warnet-armada/flagship -- rm -rf /golang + +echo "Copying code in /golang into container" +kubectl cp golang warnet-armada/flagship:/ + +if ! kubectl exec -it flagship -n warnet-armada -- bash -c 'cat run.sh | grep -q "go install"'; then + echo "Adding instructions to run script" + kubectl exec -it flagship -n warnet-armada -- bash -c 'echo "cd /golang" >> /run.sh' + kubectl exec -it flagship -n warnet-armada -- bash -c 'echo "go install" >> /run.sh' + kubectl exec -it flagship -n warnet-armada -- bash -c 'echo "/root/go/bin/attackathon" >> /run.sh' +fi + +echo "Running script 😈" +kubectl exec -it flagship -n warnet-armada -- ./run.sh