Class: Ronin::Payloads::ASMPayload

Inherits:
BinaryPayload show all
Includes:
Metadata::Arch, Metadata::OS
Defined in:
lib/ronin/payloads/asm_payload.rb

Overview

A Payload class that represents payloads written in Assembly (ASM).

Direct Known Subclasses

ShellcodePayload

Instance Attribute Summary

Attributes inherited from Payload

#encoders, #payload

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Metadata::OS

included, #os, #os_version

Methods included from Metadata::Arch

#arch, included

Methods inherited from Payload

#build, #built?, #built_payload, #bytesize, #cleanup, #encode_payload, #encoded_payload, encoder_class, #initialize, #length, #perform_build, #perform_cleanup, #perform_postlaunch, #perform_prelaunch, #perform_validate, #postlaunch, #prelaunch, #rebuild_payload, #reencode_payload, register, #to_s, #validate

Constructor Details

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

Class Method Details

.assemblerString

The default assembler.

Returns:

  • (String)


59
60
61
# File 'lib/ronin/payloads/asm_payload.rb', line 59

def self.assembler
  ENV['AS'] || 'as'
end

.payload_typeSymbol

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Note:

This is used internally to map an payload class to a printable type.

Returns the type or kind of payload.

Returns:

  • (Symbol)


50
51
52
# File 'lib/ronin/payloads/asm_payload.rb', line 50

def self.payload_type
  :asm
end

Instance Method Details

#assemble(*source_files, output:, defs: {}) ⇒ Boolean?

Assembles one or more source files using as.

Parameters:

  • source_files (Array<String>)

    The source file(s) to assemble.

  • output (String)

    The output file path.

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

    Additional symbols to define in the program.

Returns:

  • (Boolean, nil)

    Indicates whether the assembler command succeeded or failed.



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/ronin/payloads/asm_payload.rb', line 82

def assemble(*source_files, output: , defs: {})
  args = [params[:assembler], '-o', output]

  defs.each do |name,value|
    args << "--defsym" << "#{name}=#{value}"
  end

  args.concat(source_files)

  case system(*args)
  when false
    raise(BuildFailed,"assembler command failed: #{args.join(' ')}")
  when nil
    raise(BuildFailed,"assembler command not installed")
  end
end