Class: Msf::Exploit::Remote::SMB::RelayServer::SMBRelayServer

Inherits:
Object
  • Object
show all
Includes:
Rex::Proto
Defined in:
lib/msf/core/exploit/remote/smb/relay_server.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ SMBRelayServer

Returns a new instance of SMBRelayServer.



36
37
38
# File 'lib/msf/core/exploit/remote/smb/relay_server.rb', line 36

def initialize(options)
  @options = options
end

Instance Attribute Details

#listener_sockObject

Returns the value of attribute listener_sock.



86
87
88
# File 'lib/msf/core/exploit/remote/smb/relay_server.rb', line 86

def listener_sock
  @listener_sock
end

#listener_threadObject

Returns the value of attribute listener_thread.



86
87
88
# File 'lib/msf/core/exploit/remote/smb/relay_server.rb', line 86

def listener_thread
  @listener_thread
end

Class Method Details

.hardcore_alias(*args) ⇒ Object

Returns the hardcore alias for the SMB service



47
48
49
50
# File 'lib/msf/core/exploit/remote/smb/relay_server.rb', line 47

def self.hardcore_alias(*args)
  sock_options = sock_options_for(*args)
  "#{sock_options['LocalHost']}#{sock_options['LocalPort']}"
end

.sock_options_for(options) ⇒ Object



88
89
90
91
92
93
# File 'lib/msf/core/exploit/remote/smb/relay_server.rb', line 88

def self.sock_options_for(options)
  {
    'LocalHost' => '0.0.0.0',
    'LocalPort' => 445
  }.merge(options[:socket])
end

Instance Method Details

#aliasObject



40
41
42
# File 'lib/msf/core/exploit/remote/smb/relay_server.rb', line 40

def alias
  super || 'SMB Relay Server'
end

#startObject



52
53
54
55
56
57
58
59
60
# File 'lib/msf/core/exploit/remote/smb/relay_server.rb', line 52

def start
  @listener_sock = Rex::Socket::TcpServer.create(sock_options)
  @listener_server = Msf::Exploit::Remote::SMB::Relay::NTLM::Server.new(**smb_server_options(@listener_sock))
  @listener_thread = Rex::ThreadFactory.spawn('SMBRelayServerListener', false) do
    @listener_server.run
  rescue StandardError => e
    elog(e)
  end
end

#stopObject



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/msf/core/exploit/remote/smb/relay_server.rb', line 62

def stop
  begin
    @listener_server.close if @server && !@server.closed?
    @listener_thread.kill if @listener_thread
  rescue StandardError => e
    print_error('Failed closing SMB server')
    elog('Failed closing SMB server', error: e)
  end

  begin
    @listener_sock.close if @listener_sock && !@listener_sock.closed?
  rescue StandardError => e
    print_error('Failed closing SMB server socket')
    elog('Failed closing SMB server socket', error: e)
  end
end

#waitObject

This method waits on the server listener thread



82
83
84
# File 'lib/msf/core/exploit/remote/smb/relay_server.rb', line 82

def wait
  @listener_thread.join if listener_thread
end