Class: Ronin::Payloads::RustPayload
- Inherits:
-
BinaryPayload
- Object
- Payload
- BinaryPayload
- Ronin::Payloads::RustPayload
- Defined in:
- lib/ronin/payloads/rust_payload.rb
Overview
A Payload class that represents all Rust payloads.
Instance Attribute Summary
Attributes inherited from Payload
Class Method Summary collapse
-
.payload_type ⇒ Symbol
private
Returns the type or kind of payload.
Instance Method Summary collapse
-
#compile_rust(*source_files, output: nil, target: nil, cfg: nil) ⇒ Object
(also: #compile)
Compiles one or more source files using the
go build
command.
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_type ⇒ Symbol
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.
This is used internally to map an payload class to a printable type.
Returns the type or kind of payload.
41 42 43 |
# File 'lib/ronin/payloads/rust_payload.rb', line 41 def self.payload_type :rust end |
Instance Method Details
#compile_rust(*source_files, output: nil, target: nil, cfg: nil) ⇒ Object Also known as: compile
Compiles one or more source files using the go build
command.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/ronin/payloads/rust_payload.rb', line 68 def compile_rust(*source_files, output: nil, target: nil, cfg: nil) args = ['rustc'] if output args << '-o' << output end if target args << '--target' << target end if cfg case cfg when Hash cfg.each do |key,value| args << '--cfg' << "#{key}=\"#{value}\"" end when Array cfg.each do |value| args << '--cfg' << value.to_s end else raise(ArgumentError,"cfg value must be either a Hash or an Array: #{cfg.inspect}") end end args.concat(source_files) case system(*args) when false raise(BuildFailed,"rustc command failed: #{args.join(' ')}") when nil raise(BuildFailed,"rustc command not installed") end end |