Class: Ronin::Payloads::CLI::Commands::Encoder Private

Inherits:
Ronin::Payloads::CLI::Command show all
Includes:
CommandKit::Printing::Fields, Core::CLI::Printing::Arch, Core::CLI::Printing::Metadata, Core::CLI::Printing::OS, Core::CLI::Printing::Params, EncoderMethods
Defined in:
lib/ronin/payloads/cli/commands/encoder.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 an encoder.

Instance Method Summary collapse

Methods included from EncoderMethods

#encoder_type, #initialize_encoder, #load_encoder, #load_encoder_from, #validate_encoder

Instance Method Details

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 metadata for an encoder class.

Parameters:



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
116
117
118
119
120
121
122
123
124
# File 'lib/ronin/payloads/cli/commands/encoder.rb', line 91

def print_encoder(encoder_class)
  puts "[ #{encoder_class.id} ]"
  puts

  indent do
    fields = {}

    if (type = encoder_type(encoder_class))
      fields['Type'] = type
    end

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

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

    if (summary = encoder_class.summary)
      fields['Summary'] = summary
    end

    print_fields fields
    print_authors(encoder_class)
    print_description(encoder_class)
    print_references(encoder_class)
    print_params(encoder_class)
  end
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 encoder command.

Parameters:

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

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



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

def run(name=nil)
  encoder_class = if name
                    load_encoder(name)
                  elsif options[:file]
                    load_encoder_from(options[:file])
                  else
                    print_error "must specify --file or a NAME"
                    exit(-1)
                  end

  print_encoder(encoder_class)
end