Class: Rex::Post::Meterpreter::Extensions::Stdapi::Railgun::DLL
- Inherits:
-
Object
- Object
- Rex::Post::Meterpreter::Extensions::Stdapi::Railgun::DLL
- Includes:
- DLLHelper
- Defined in:
- lib/rex/post/meterpreter/extensions/stdapi/railgun/dll.rb
Overview
represents a DLL, e.g. kernel32.dll
Defined Under Namespace
Classes: UnitTest
Instance Attribute Summary collapse
-
#functions ⇒ Object
Returns the value of attribute functions.
Instance Method Summary collapse
-
#add_function(name, return_type, params, windows_name = nil) ⇒ Object
adds a function to the DLL syntax for params: add_function(“MessageBoxW”, # name “DWORD”, # return value [[“DWORD”,“hWnd”,“in”], # params [“PWCHAR”,“lpText”,“in”], [“PWCHAR”,“lpCaption”,“in”], [“DWORD”,“uType”,“in”], ]).
-
#initialize(dll_path, client, win_consts) ⇒ DLL
constructor
A new instance of DLL.
Methods included from DLLHelper
#asciiz_to_str, #assemble_buffer, #param_to_number, #str_to_ascii_z, #str_to_uni_z, #uniz_to_str
Constructor Details
#initialize(dll_path, client, win_consts) ⇒ DLL
Returns a new instance of DLL.
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/rex/post/meterpreter/extensions/stdapi/railgun/dll.rb', line 47 def initialize(dll_path, client, win_consts) # @dll_path = dll_path @client = client @win_consts = win_consts if( @client.platform =~ /x64/i ) @native = 'Q' else @native = 'V' end self.functions = {} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(func_symbol, *args) ⇒ Object (private)
we fake having methods like “MessageBoxW” by intercepting “method-not-found”-exceptions
340 341 342 343 344 345 |
# File 'lib/rex/post/meterpreter/extensions/stdapi/railgun/dll.rb', line 340 def method_missing(func_symbol, *args) func_name = func_symbol.to_s raise "DLL-function #{func_name} not found. Known functions: #{PP.pp(@functions.keys, "")}" unless @functions.has_key? func_name function = @functions[func_name] return process_function_call(function, args) end |
Instance Attribute Details
#functions ⇒ Object
Returns the value of attribute functions.
45 46 47 |
# File 'lib/rex/post/meterpreter/extensions/stdapi/railgun/dll.rb', line 45 def functions @functions end |
Instance Method Details
#add_function(name, return_type, params, windows_name = nil) ⇒ Object
adds a function to the DLL syntax for params: add_function(“MessageBoxW”, # name “DWORD”, # return value [[“DWORD”,“hWnd”,“in”], # params [“PWCHAR”,“lpText”,“in”], [“PWCHAR”,“lpCaption”,“in”], [“DWORD”,“uType”,“in”], ])
Every function argument is described by a tuple (type,name,direction)
windows_name: Use it when the actual windows name is different from the ruby variable
for example when the actual func name is myFunc@4
or when you want to create an alternative version of an existing function
When new function is called it will return a list containing the return value and all inout params
76 77 78 79 80 81 |
# File 'lib/rex/post/meterpreter/extensions/stdapi/railgun/dll.rb', line 76 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 |