Class: Ronin::Exploits::CLI::Commands::New Private

Inherits:
Ronin::Exploits::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, Payloads::CLI::Generator
Defined in:
lib/ronin/exploits/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 exploit file.

Usage

ronin-exploit new [options] FILE

Options

-t exploit|heap_overflow|stack_overflow|web|open_redirect|lfi|rfi|sqli|ssti|xss,
    --type                       The type for the new exploit
-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           A longer description
-I CVE-YYYY-NNNN|GHSA-XXXXX|..., Add the advisory ID to the exploit
    --advisory-id
-R, --reference URL              Adds a reference URL
-P payload|asm|shellcode|c|command|shell|powershell|html|javascript|typpescript|java|sql|php|nodejs,
    --has-payload                The payload type the exploit uses
-N remote_tcp|remote_udp|http,   The networking mixin to use
    --networking
-A x86|x86-64|amd64|ia64|ppc|ppc64|arm|armbe|arm64|arm64be|mips|mipsle|mips64|mips64le,
    --arch                       The architecture to target
-O linux|macos|windows|freebsd|openbsd|netbsd,
    --os                         The Operating System (OS) to target
    --os-version VERSION         The OS version to target
-S, --software NAME              The software to target
-V, --software-version ARCH      The software version to target
-L, --loot                       Adds the loot mixin
-h, --help                       Print help information

Arguments

FILE                             The path to the new exploit file.

Constant Summary collapse

EXPLOIT_TYPES =

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

Mapping of exploit types and their file/class names.

{
  exploit: {
    file:  'exploit',
    class: 'Exploit'
  },

  heap_overflow: {
    file:  'heap_overflow',
    class: 'HeapOverflow'
  },

  stack_overflow: {
    file:  'stack_overflow',
    class: 'StackOverflow'
  },

  seh_overflow: {
    file:  'seh_overflow',
    class: 'SEHOverflow'
  },

  user_after_free: {
    file:  'use_after_free',
    class: 'UseAfterFree'
  },

  web: {
    file:  'web',
    class: 'Web'
  },

  lfi: {
    file:  'lfi',
    class: 'LFI'
  },

  rfi: {
    file:  'rfi',
    class: 'RFI'
  },

  sqli: {
    file:  'sqli',
    class: 'SQLI'
  },

  ssti: {
    file:  'ssti',
    class: 'SSTI'
  },

  xss: {
    file:  'xss',
    class: 'XSS'
  }
}
NETWORKING_TYPES =

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

Mapping of network mixins and their file/module names.

{
  remote_tcp: {
    file:   'remote_tcp',
    module: 'RemoteTCP'
  },

  remote_udp: {
    file:   'remote_udp',
    module: 'RemoteUDP'
  },

  http: {
    file:   'http',
    module: 'HTTP'
  }
}
WEB_VULN_EXPLOITS =

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

Web exploit class names.

%w[LFI RFI SQLI]

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-exploits new command.

Parameters:

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments.



272
273
274
275
276
277
# File 'lib/ronin/exploits/cli/commands/new.rb', line 272

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

  @exploit_type = EXPLOIT_TYPES.fetch(:exploit)
  @advisories   = []
end

Instance Method Details

#format_kwargs(kwargs) ⇒ 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.

Formats a Hash into Ruby keyword arguments.

Parameters:

  • kwargs (Hash{Symbol => Object})

Returns:

  • (String)


300
301
302
303
304
305
306
307
308
# File 'lib/ronin/exploits/cli/commands/new.rb', line 300

def format_kwargs(kwargs)
  args = []

  kwargs.each do |key,value|
    args << "#{key}: #{value.inspect}"
  end

  return args.join(', ')
end

#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-exploits new command.

Parameters:

  • file (String)

    The path to the new exploit file.



285
286
287
288
289
290
291
# File 'lib/ronin/exploits/cli/commands/new.rb', line 285

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

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

#seh_overflow_exploit?Boolean

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.

Determines if the exploit type is seh_overflow.

Returns:

  • (Boolean)


327
328
329
# File 'lib/ronin/exploits/cli/commands/new.rb', line 327

def seh_overflow_exploit?
  @exploit_type[:class] == 'SEHOverflow'
end

#stack_overflow_exploit?Boolean

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.

Determines if the exploit type is stack_overflow.

Returns:

  • (Boolean)


318
319
320
# File 'lib/ronin/exploits/cli/commands/new.rb', line 318

def stack_overflow_exploit?
  @exploit_type[:class] == 'StackOverflow'
end

#web_vuln_exploit?Boolean

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.

Determines if the exploit type is a web vuln exploit.

Returns:

  • (Boolean)


336
337
338
# File 'lib/ronin/exploits/cli/commands/new.rb', line 336

def web_vuln_exploit?
  WEB_VULN_EXPLOITS.include?(@exploit_type[:class])
end