Class: Ronin::Payloads::GoPayload

Inherits:
BinaryPayload show all
Defined in:
lib/ronin/payloads/go_payload.rb

Overview

A Payload class that represents all Go payloads.

Instance Attribute Summary

Attributes inherited from Payload

#encoders, #payload

Class Method Summary collapse

Instance Method Summary collapse

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

.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)


41
42
43
# File 'lib/ronin/payloads/go_payload.rb', line 41

def self.payload_type
  :go
end

Instance Method Details

#compile(*source_files, output: nil) ⇒ Object

Compiles one or more source files using the go build command.

Parameters:

  • source_files (Array<String>)

    The source file(s) to compile.

  • output (String, nil) (defaults to: nil)

    The output file path.

Raises:

  • (BuildFailed)

    The go build command failed or is not installed.



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/ronin/payloads/go_payload.rb', line 57

def compile(*source_files, output: nil)
  args = ['go', 'build']

  if output
    args << '-o' << output
  end

  args.concat(source_files)

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