2005-04-10 09:20:47 +00:00
|
|
|
#!/usr/bin/ruby
|
|
|
|
|
|
|
|
require 'Rex/Post/Meterpreter/Extension'
|
2005-04-11 01:59:45 +00:00
|
|
|
require 'Rex/Post/Meterpreter/Extensions/Stdapi/Dir'
|
2005-04-11 03:37:02 +00:00
|
|
|
require 'Rex/Post/Meterpreter/Extensions/Stdapi/File'
|
2005-04-11 03:06:56 +00:00
|
|
|
require 'Rex/Post/Meterpreter/Extensions/Stdapi/FileStat'
|
2005-04-10 09:20:47 +00:00
|
|
|
require 'Rex/Post/Meterpreter/Extensions/Stdapi/Process'
|
2005-04-10 10:31:38 +00:00
|
|
|
require 'Rex/Post/Meterpreter/Extensions/Stdapi/Registry'
|
2005-04-10 09:20:47 +00:00
|
|
|
|
|
|
|
module Rex
|
|
|
|
module Post
|
|
|
|
module Meterpreter
|
|
|
|
module Extensions
|
|
|
|
module Stdapi
|
|
|
|
|
2005-04-11 04:56:24 +00:00
|
|
|
# Process
|
|
|
|
TLV_TYPE_PID = TLV_META_TYPE_UINT | 0
|
|
|
|
|
|
|
|
# Registry
|
|
|
|
TLV_TYPE_HKEY = TLV_META_TYPE_UINT | 1000
|
|
|
|
TLV_TYPE_ROOT_KEY = TLV_TYPE_HKEY
|
|
|
|
TLV_TYPE_BASE_KEY = TLV_META_TYPE_STRING | 1001
|
|
|
|
TLV_TYPE_PERMISSION = TLV_META_TYPE_UINT | 1002
|
|
|
|
TLV_TYPE_KEY_NAME = TLV_META_TYPE_STRING | 1003
|
|
|
|
TLV_TYPE_VALUE_NAME = TLV_META_TYPE_STRING | 1010
|
|
|
|
TLV_TYPE_VALUE_TYPE = TLV_META_TYPE_UINT | 1011
|
|
|
|
TLV_TYPE_VALUE_DATA = TLV_META_TYPE_RAW | 1012
|
|
|
|
|
|
|
|
# Fs
|
|
|
|
TLV_TYPE_DIRECTORY_PATH = TLV_META_TYPE_STRING | 1200
|
|
|
|
TLV_TYPE_FILE_NAME = TLV_META_TYPE_STRING | 1201
|
|
|
|
TLV_TYPE_FILE_PATH = TLV_META_TYPE_STRING | 1202
|
|
|
|
TLV_TYPE_FILE_MODE = TLV_META_TYPE_STRING | 1203
|
|
|
|
TLV_TYPE_STAT_BUF = TLV_META_TYPE_COMPLEX | 1220
|
|
|
|
|
|
|
|
DELETE_KEY_FLAG_RECURSIVE = (1 << 0)
|
|
|
|
|
2005-04-10 09:20:47 +00:00
|
|
|
###
|
|
|
|
#
|
|
|
|
# Stdapi
|
|
|
|
# ------
|
|
|
|
#
|
|
|
|
# Standard ruby interface to remote entities
|
|
|
|
#
|
|
|
|
###
|
|
|
|
class Stdapi < Extension
|
|
|
|
def initialize(client)
|
|
|
|
super(client, 'stdapi')
|
2005-04-10 17:08:27 +00:00
|
|
|
|
|
|
|
# Alias the following things on the client object so that they
|
|
|
|
# can be directly referenced
|
2005-04-11 01:59:45 +00:00
|
|
|
client.register_extension_alias('dir', self.dir)
|
2005-04-11 03:37:02 +00:00
|
|
|
client.register_extension_alias('file', self.file)
|
2005-04-11 03:06:56 +00:00
|
|
|
client.register_extension_alias('filestat', self.filestat)
|
2005-04-10 17:08:27 +00:00
|
|
|
client.register_extension_alias('process', self.process)
|
|
|
|
client.register_extension_alias('registry', self.registry)
|
2005-04-10 09:20:47 +00:00
|
|
|
end
|
|
|
|
|
2005-04-12 05:53:29 +00:00
|
|
|
# Sets the client instance on a duplicated copy of the supplied class
|
2005-04-10 09:20:47 +00:00
|
|
|
def brand(klass)
|
|
|
|
klass = klass.dup
|
|
|
|
klass.client = self.client
|
|
|
|
return klass
|
|
|
|
end
|
|
|
|
|
2005-04-12 05:53:29 +00:00
|
|
|
# Returns a copy of the Dir class
|
2005-04-11 01:59:45 +00:00
|
|
|
def dir
|
|
|
|
brand(Rex::Post::Meterpreter::Extensions::Stdapi::Dir)
|
|
|
|
end
|
|
|
|
|
2005-04-12 05:53:29 +00:00
|
|
|
# Returns a copy of the File class
|
2005-04-11 03:37:02 +00:00
|
|
|
def file
|
|
|
|
brand(Rex::Post::Meterpreter::Extensions::Stdapi::File)
|
|
|
|
end
|
|
|
|
|
2005-04-12 05:53:29 +00:00
|
|
|
# Returns a copy of the FileStat class
|
2005-04-11 03:06:56 +00:00
|
|
|
def filestat
|
|
|
|
brand(Rex::Post::Meterpreter::Extensions::Stdapi::FileStat)
|
|
|
|
end
|
|
|
|
|
2005-04-12 05:53:29 +00:00
|
|
|
# Returns a copy of the Process class
|
2005-04-10 09:20:47 +00:00
|
|
|
def process
|
|
|
|
brand(Rex::Post::Meterpreter::Extensions::Stdapi::Process)
|
|
|
|
end
|
2005-04-12 05:53:29 +00:00
|
|
|
|
|
|
|
# Returns a copy of the Registry class
|
2005-04-10 10:31:38 +00:00
|
|
|
def registry
|
|
|
|
brand(Rex::Post::Meterpreter::Extensions::Stdapi::Registry)
|
|
|
|
end
|
2005-04-10 09:20:47 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end; end; end; end; end
|