Module: Msf::Auxiliary::RServices

Defined in:
lib/msf/core/auxiliary/rservices.rb

Instance Method Summary collapse

Instance Method Details

#cleanup_filesObject



72
73
74
75
76
77
78
79
# File 'lib/msf/core/auxiliary/rservices.rb', line 72

def cleanup_files
  super

  path = datastore['FROMUSER_FILE']
  if path and datastore['REMOVE_FROMUSER_FILE']
    ::File.unlink(path) rescue nil
  end
end

#connect_from_privileged_port(start_port = 1023) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/msf/core/auxiliary/rservices.rb', line 29

def connect_from_privileged_port(start_port = 1023)
  cport = start_port
  sd = nil
  while cport > 512
    #vprint_status("Trying to connect from port #{cport} ...")
    sd = nil
    begin
      sd = connect(true, { 'CPORT' => cport })

    rescue Rex::BindFailed
      # Ignore and try again
      #vprint_error("Unable to connect: #{$!}")

    rescue Rex::ConnectionError => e
      vprint_error("Unable to connect: #{$!}")
      return :refused if e.class == Rex::ConnectionRefused
      return :connection_error

    end

    break if sd
    cport -= 1
  end

  if not sd
    print_error("#{target_host}:#{rport} - Unable to bind to privileged port")
    return :bind_error
  end

  #vprint_status("Connected from #{cport}")
  return :connected
end

#initialize(info = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/msf/core/auxiliary/rservices.rb', line 12

def initialize(info = {})
  super

  register_options(
    [
      OptString.new('FROMUSER',      [ false, 'The username to login from' ]),
      OptPath.new(  'FROMUSER_FILE', [ false, 'File containing from usernames, one per line',
        File.join(Msf::Config.data_directory, "wordlists", "rservices_from_users.txt") ])
    ], Msf::Auxiliary::RServices)

  register_advanced_options(
    [
        OptBool.new('REMOVE_FROMUSER_FILE', [ true, "Automatically delete the FROMUSER_FILE on module completion", false])
    ], Msf::Auxiliary::RServices)
end

#load_fromuser_varsObject



63
64
65
66
67
68
69
# File 'lib/msf/core/auxiliary/rservices.rb', line 63

def load_fromuser_vars
  fromusers = extract_words(datastore['FROMUSER_FILE'])
  if datastore['FROMUSER']
    fromusers.unshift datastore['FROMUSER']
  end
  fromusers
end