Module: Ronin::PostExploitation::Mixin

Included in:
Exploits::Exploit, Ronin::Payloads::Payload
Defined in:
lib/ronin/post_exploitation/mixin.rb

Overview

Classes or objects can include Mixin and define a POSIX-style API to control exploited Resources. Resources contains classes that provide convience methods for controlling resources. In turn, these convience methods call methods defined in the object which controls said Resource.

For example, the Resources::FS#mkdir method relies on the fs_mkdir method to handle the making of the directory:

  #
  # Injects a `mkdir` command.
  #
  def fs_mkdir(path)
    inject_command("; mkdir #{path}; ")
  end

# ...
obj.fs.mkdir('.temp')

Since:

  • 1.0.0

Instance Method Summary collapse

Instance Method Details

#fsResources::FS

The File-System resource.

Returns:

Since:

  • 1.0.0


74
75
76
# File 'lib/ronin/post_exploitation/mixin.rb', line 74

def fs
  resources[:fs]
end

#post_exploitation { ... } ⇒ Object

Used to define post-exploitation methods.

Examples:

post_exploitation do
  def fs_read(path,pos)
    # ...
  end
end

Yields:

  • [] The given block will be evaluated within the object.

Since:

  • 1.0.0


115
116
117
# File 'lib/ronin/post_exploitation/mixin.rb', line 115

def post_exploitation(&block)
  instance_eval(&block)
end

#processResources::Process

The Process resource.

Returns:

Since:

  • 1.0.0


86
87
88
# File 'lib/ronin/post_exploitation/mixin.rb', line 86

def process
  resources[:process]
end

#resourcesHash{Symbol => Resource}

The controlled resources.

Returns:

  • (Hash{Symbol => Resource})

    The controlled resources.

Since:

  • 1.0.0


58
59
60
61
62
63
64
# File 'lib/ronin/post_exploitation/mixin.rb', line 58

def resources
  @resources ||= Hash.new do |hash,key| 
    if (resource = Resources.require_const(key))
      hash[key] = resource.new(self)
    end
  end
end

#shellResources::Shell

The Shell resource.

Returns:

Since:

  • 1.0.0


98
99
100
# File 'lib/ronin/post_exploitation/mixin.rb', line 98

def shell
  resources[:shell]
end