Module: Msf::Exploit::Remote::SMB::Server

Includes:
LogAdapter, Msf::Exploit::Remote::SocketServer
Included in:
Share
Defined in:
lib/msf/core/exploit/remote/smb/server.rb,
lib/msf/core/exploit/remote/smb/server/share.rb

Overview

This mixin provides a minimal SMB server

Defined Under Namespace

Modules: HashCapture, Share

Instance Attribute Summary

Attributes included from Msf::Exploit::Remote::SocketServer

#service

Instance Method Summary collapse

Methods included from Msf::Exploit::Remote::SocketServer

#_determine_server_comm, #bindhost, #bindport, #cleanup, #cleanup_service, #exploit, #on_client_data, #primer, #regenerate_payload, #srvhost, #srvport, #via_string

Instance Method Details

#initialize(info = {}) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/msf/core/exploit/remote/smb/server.rb', line 10

def initialize(info = {})
  super

  register_options(
    [
      OptPort.new('SRVPORT', [ true, 'The local port to listen on.', 445 ])
    ], self.class)
end

#on_client_connect(client) ⇒ Object



45
46
47
# File 'lib/msf/core/exploit/remote/smb/server.rb', line 45

def on_client_connect(client)
  vprint_status("Received SMB connection from #{client.peerhost}")
end

#start_service(opts = {}) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/msf/core/exploit/remote/smb/server.rb', line 19

def start_service(opts = {})
  unless opts[:logger]
    log_device = LogAdapter::LogDevice::Framework.new(framework)
    opts[:logger] = LogAdapter::Logger.new(self, log_device)
  end

  self.service = Rex::ServiceManager.start(
    Rex::Proto::SMB::Server,
    (opts['ServerPort'] || bindport).to_i,
    opts['ServerHost'] || bindhost,
    {
      'Msf'        => framework,
      'MsfExploit' => self,
    },
    opts['Comm'] || _determine_server_comm(opts['ServerHost'] || bindhost),
    gss_provider: opts[:gss_provider],
    logger: opts[:logger]
  )

  service.on_client_connect_proc = Proc.new { |client|
    on_client_connect(client)
  }

  print_status("Server is running. Listening on #{bindhost}:#{bindport}")
end