Class: Ronin::Payloads::JavaPayload

Inherits:
Payload
  • Object
show all
Defined in:
lib/ronin/payloads/java_payload.rb

Overview

A Payload class that represents Java payloads.

Direct Known Subclasses

Ronin::Payloads::Java::ReverseShell

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

.javacString

The default Java compiler.

Returns:

  • (String)


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

def self.javac
  ENV['JAVAC'] || 'javac'
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)


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

def self.payload_type
  :java
end

Instance Method Details

#compile_java(*source_files, dest_dir: nil) ⇒ Object Also known as: compile

Compiles one or more source files using javac.

Parameters:

  • source_files (Array<String>)

    The source files for the javac command.

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

    The destination directory that class files will be written to.

Raises:

  • (BuildFailed)

    The javac command failed or is not installed.

Since:

  • 0.2.0



72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/ronin/payloads/java_payload.rb', line 72

def compile_java(*source_files, dest_dir: nil)
  args = [params[:javac]]
  args << '-d' << dest_dir if dest_dir
  args.concat(source_files)

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