Parent

Class/Module Index [+]

Quicksearch

Rex::Post::Meterpreter::Extensions::Stdapi::Railgun::DLL

Represents a DLL, e.g. kernel32.dll

Public Class Methods

new(dll_path, win_consts) click to toggle source
# File lib/rex/post/meterpreter/extensions/stdapi/railgun/dll.rb, line 48
def initialize(dll_path, win_consts)
        @dll_path = dll_path

        # needed by DLLHelper
        @win_consts = win_consts

        self.functions = {}
end

Public Instance Methods

add_function(name, return_type, params, windows_name=nil) click to toggle source

Define a function for this DLL.

Every function argument is described by a tuple (type,name,direction)

Example:

add_function("MessageBoxW",   # name
  "DWORD",                    # return value
  [                           # params
      ["DWORD","hWnd","in"],
   ["PWCHAR","lpText","in"],
   ["PWCHAR","lpCaption","in"],
   ["DWORD","uType","in"],
  ])

Use windows_name when the actual windows name is different from the ruby variable. You might need to do this for example when the actual func name is myFunc@4 or when you want to create an alternative version of an existing function.

When the new function is called it will return a list containing the return value and all inout params. See call_function.

# File lib/rex/post/meterpreter/extensions/stdapi/railgun/dll.rb, line 109
def add_function(name, return_type, params, windows_name=nil)
        if windows_name == nil
                windows_name = name
        end
        @functions[name] = DLLFunction.new(return_type, params, windows_name)
end
call_function(func_symbol, args, client) click to toggle source

Perform a function call in this DLL on the remote system.

Returns a Hash containing the return value, the result of GetLastError(), and any inout parameters.

Raises an exception if func_symbol is not a known function in this DLL, i.e., it hasn't been defined in a Def.

# File lib/rex/post/meterpreter/extensions/stdapi/railgun/dll.rb, line 74
def call_function(func_symbol, args, client)
        func_name = func_symbol.to_s

        unless known_function_names.include? func_name
                raise "DLL-function #{func_name} not found. Known functions: #{PP.pp(known_function_names, '')}"
        end

        function = get_function(func_name)

        return process_function_call(function, args, client)
end
get_function(name) click to toggle source
# File lib/rex/post/meterpreter/extensions/stdapi/railgun/dll.rb, line 61
def get_function(name)
        return functions[name]
end
known_function_names() click to toggle source
# File lib/rex/post/meterpreter/extensions/stdapi/railgun/dll.rb, line 57
def known_function_names
        return functions.keys
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.