templates: add script to copy and run golang program

This commit is contained in:
Carla Kirk-Cohen 2024-04-11 14:43:19 -04:00
parent 2b313e2eab
commit f54a2c931a
No known key found for this signature in database
GPG Key ID: 4CA7FE54A6213C91
2 changed files with 29 additions and 0 deletions

12
templates/README.md Normal file
View File

@ -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

View File

@ -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