Class: Rex::Post::Meterpreter::Extensions::Stdapi::Stdapi

Inherits:
Rex::Post::Meterpreter::Extension show all
Defined in:
lib/rex/post/meterpreter/extensions/stdapi/stdapi.rb

Overview

Standard ruby interface to remote entities for meterpreter. It provides basic access to files, network, system, and other properties of the remote machine that are fairly universal.

Instance Attribute Summary

Attributes inherited from Rex::Post::Meterpreter::Extension

#client, #name

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Stdapi

Initializes an instance of the standard API extension.



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/rex/post/meterpreter/extensions/stdapi/stdapi.rb', line 48

def initialize(client)
  super(client, 'stdapi')

  # Alias the following things on the client object so that they
  # can be directly referenced
  client.register_extension_aliases(
    [
      {
        'name' => 'fs',
        'ext'  => ObjectAliases.new(
          {
            'dir'      => self.dir,
            'file'     => self.file,
            'filestat' => self.filestat,
            'mount'    => Fs::Mount.new(client)
          })
      },
      {
        'name' => 'sys',
        'ext'  => ObjectAliases.new(
          {
            'config'   => Sys::Config.new(client),
            'process'  => self.process,
            'registry' => self.registry,
            'eventlog' => self.eventlog,
            'power'    => self.power
          })
      },
      {
        'name' => 'net',
        'ext'  => ObjectAliases.new(
          {
            'config'   => Rex::Post::Meterpreter::Extensions::Stdapi::Net::Config.new(client),
            'socket'   => Rex::Post::Meterpreter::Extensions::Stdapi::Net::Socket.new(client),
            'resolve'  => Rex::Post::Meterpreter::Extensions::Stdapi::Net::Resolve.new(client)
          })
      },
      {
        'name' => 'railgun',
        'ext'  => Rex::Post::Meterpreter::Extensions::Stdapi::Railgun::Railgun.new(client)
      },
      {
        'name' => 'webcam',
        'ext'  => Rex::Post::Meterpreter::Extensions::Stdapi::Webcam::Webcam.new(client)
      },
      {
        'name' => 'mic',
        'ext'  => Rex::Post::Meterpreter::Extensions::Stdapi::Mic::Mic.new(client)
      },
      {
        'name' => 'audio_output',
        'ext'  => Rex::Post::Meterpreter::Extensions::Stdapi::AudioOutput::AudioOutput.new(client)
      },
      {
        'name' => 'ui',
        'ext'  => UI.new(client)
      }

    ])
end

Class Method Details

.extension_idObject



41
42
43
# File 'lib/rex/post/meterpreter/extensions/stdapi/stdapi.rb', line 41

def self.extension_id
  EXTENSION_ID_STDAPI
end

Instance Method Details

#brand(klass) ⇒ Object

Sets the client instance on a duplicated copy of the supplied class.



112
113
114
115
116
# File 'lib/rex/post/meterpreter/extensions/stdapi/stdapi.rb', line 112

def brand(klass)
  klass = klass.dup
  klass.client = self.client
  return klass
end

#dirObject

Returns a copy of the Dir class.



121
122
123
# File 'lib/rex/post/meterpreter/extensions/stdapi/stdapi.rb', line 121

def dir
  brand(Rex::Post::Meterpreter::Extensions::Stdapi::Fs::Dir)
end

#eventlogObject

Returns a copy of the EventLog class.



156
157
158
# File 'lib/rex/post/meterpreter/extensions/stdapi/stdapi.rb', line 156

def eventlog
  brand(Rex::Post::Meterpreter::Extensions::Stdapi::Sys::EventLog)
end

#fileObject

Returns a copy of the File class.



128
129
130
# File 'lib/rex/post/meterpreter/extensions/stdapi/stdapi.rb', line 128

def file
  brand(Rex::Post::Meterpreter::Extensions::Stdapi::Fs::File)
end

#filestatObject

Returns a copy of the FileStat class.



135
136
137
# File 'lib/rex/post/meterpreter/extensions/stdapi/stdapi.rb', line 135

def filestat
  brand(Rex::Post::Meterpreter::Extensions::Stdapi::Fs::FileStat)
end

#powerObject

Returns a copy of the Power class.



163
164
165
# File 'lib/rex/post/meterpreter/extensions/stdapi/stdapi.rb', line 163

def power
  brand(Rex::Post::Meterpreter::Extensions::Stdapi::Sys::Power)
end

#processObject

Returns a copy of the Process class.



142
143
144
# File 'lib/rex/post/meterpreter/extensions/stdapi/stdapi.rb', line 142

def process
  brand(Rex::Post::Meterpreter::Extensions::Stdapi::Sys::Process)
end

#registryObject

Returns a copy of the Registry class.



149
150
151
# File 'lib/rex/post/meterpreter/extensions/stdapi/stdapi.rb', line 149

def registry
  brand(Rex::Post::Meterpreter::Extensions::Stdapi::Sys::Registry)
end