Class: Ronin::Payloads::CLI::Commands::Show Private

Inherits:
PayloadCommand show all
Includes:
CommandKit::Printing::Fields, Core::CLI::Printing::Arch, Core::CLI::Printing::Metadata, Core::CLI::Printing::OS, Core::CLI::Printing::Params, Printing
Defined in:
lib/ronin/payloads/cli/commands/show.rb

Overview

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

Prints information about a payload.

Usage

ronin-payloads show [options] {--file FILE | NAME}

Options

-f, --file FILE                  The optional file to load the payload from
-v, --verbose                    Enables verbose output
-h, --help                       Print help information

Arguments

NAME                             The name of the payload to load

Constant Summary

Constants included from Printing

Printing::PAYLOAD_TYPES

Instance Attribute Summary

Attributes inherited from PayloadCommand

#payload, #payload_class

Instance Method Summary collapse

Methods included from Printing

#payload_type

Methods inherited from PayloadCommand

#initialize_payload, #load_payload, #load_payload_from, #validate_payload

Methods included from PayloadMethods

#initialize_payload, #load_payload, #load_payload_from, #validate_payload

Instance Method Details

#example_build_command(payload) ⇒ String

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.

Builds an example ronin-payloads build command for the payload.

Parameters:

Returns:

  • (String)

    The example ronin-payloads build command.

Since:

  • 0.2.0



141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# File 'lib/ronin/payloads/cli/commands/show.rb', line 141

def example_build_command(payload)
  command = ['ronin-payloads', 'build']

  if options[:file]
    command << '-f' << options[:file]
  else
    command << payload.id
  end

  payload.params.each_value do |param|
    if param.required? && !param.default
      command << '-p' << "#{param.name}=#{param_usage(param)}"
    end
  end

  return command.join(' ')
end

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.

Prints the metadata for a payload class.

Parameters:



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/ronin/payloads/cli/commands/show.rb', line 84

def print_payload(payload)
  puts "[ #{payload.id} ]"
  puts

  indent do
    fields = {}

    fields['Type']    = payload_type(payload)
    fields['Summary'] = payload.summary if payload.summary

    if payload.include?(Metadata::Arch)
      if (arch = payload.arch)
        fields['Arch'] = arch_name(arch)
      end
    end

    if payload.include?(Metadata::OS)
      if (os = payload.os)
        fields['OS'] = os_name(os)
      end
    end

    print_fields(fields)
    puts

    print_authors(payload)
    print_description(payload)
    print_references(payload)
    print_params(payload)
    print_payload_usage(payload)
  end
end

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.

Prints an example ronin-payloads build command for the payload.

Parameters:

Since:

  • 0.2.0



124
125
126
127
128
129
# File 'lib/ronin/payloads/cli/commands/show.rb', line 124

def print_payload_usage(payload)
  puts "Usage:"
  puts
  puts "  $ #{example_build_command(payload)}"
  puts
end

#run(name = nil) ⇒ Object

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.

Runs the ronin-payloads show command.

Parameters:

  • name (String) (defaults to: nil)

    The optional name of the payload to load and print metadata about.



73
74
75
76
77
# File 'lib/ronin/payloads/cli/commands/show.rb', line 73

def run(name=nil)
  super(name)

  print_payload(payload_class)
end