Class: Ronin::Payloads::CLI::Commands::New Private

Inherits:
Ronin::Payloads::CLI::Command show all
Includes:
Core::CLI::Generator, Core::CLI::Generator::Options::Author, Core::CLI::Generator::Options::Description, Core::CLI::Generator::Options::Reference, Core::CLI::Generator::Options::Summary, Generator
Defined in:
lib/ronin/payloads/cli/commands/new.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.

Creates a new payload file.

Usage

ronin-payload new [options] FILE

Options

-t asm|shellcode|c|go|rust|command|shell|powershell|html|javascript|typescript|java|sql|php|python|ruby|nodejs,
    --type                       The type for the new payload
-a, --author NAME                The name of the author
-e, --author-email EMAIL         The email address of the author
-S, --summary TEXT               One sentence summary
-D, --description TEXT           Longer description
-R, --reference URL              Adds a reference URL
-h, --help                       Print help information

Arguments

FILE                             The path to the new payload file.

Constant Summary

Constants included from Generator

Generator::PAYLOAD_TYPES

Instance Method Summary collapse

Constructor Details

#initialize(**kwargs) ⇒ New

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.

Initializes the ronin-payloads new command.

Parameters:

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.



89
90
91
92
93
# File 'lib/ronin/payloads/cli/commands/new.rb', line 89

def initialize(**kwargs)
  super(**kwargs)

  @payload_type = PAYLOAD_TYPES.fetch(:payload)
end

Instance Method Details

#run(file) ⇒ 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 new command.

Parameters:

  • file (String)

    The path to the new payload file.



101
102
103
104
105
106
107
108
109
110
# File 'lib/ronin/payloads/cli/commands/new.rb', line 101

def run(file)
  @directory  = File.dirname(file)
  @file_name  = File.basename(file,File.extname(file))
  @class_name = CommandKit::Inflector.camelize(@file_name)

  mkdir @directory unless @directory == '.'

  erb "payload.rb.erb", file
  chmod '+x', file
end