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.



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

def initialize(options)
  @options = options
end

Instance Attribute Details

#listener_sockObject

Returns the value of attribute listener_sock.



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

def listener_sock
  @listener_sock
end

#listener_threadObject

Returns the value of attribute listener_thread.



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

def listener_thread
  @listener_thread
end

Class Method Details

.hardcore_alias(*args) ⇒ Object

Returns the hardcore alias for the SMB service



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

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

.sock_options_for(options) ⇒ Object



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

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

Instance Method Details

#aliasObject



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

def alias
  super || 'SMB Relay Server'
end

#startObject



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

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



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

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



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

def wait
  @listener_thread.join if listener_thread
end