Class: Ronin::UI::CLI::Commands::Exploit

Inherits:
ScriptCommand
  • Object
show all
Defined in:
lib/ronin/ui/cli/commands/exploit.rb

Instance Method Summary collapse

Instance Method Details

#executeObject

Builds and deploys the loaded exploit.


61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/ronin/ui/cli/commands/exploit.rb', line 61

def execute
  begin
    @exploit.exploit!(dry_run: dry_run?)
  rescue Behaviors::Exception,
         Exploits::Exception,
         Payloads::Exception => e
    print_exception(e)
    exit -1
  end

  if shell?      then @exploit.shell.console
  elsif fs?      then @exploit.fs.console
  elsif console? then UI::Console.start(@exploit)
  end

  @exploit.evaucate!
end

#load!Object (protected)

Loads the Exploit, selects the desired Target, and loads the additional Payload.


85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/ronin/ui/cli/commands/exploit.rb', line 85

def load!
  @exploit = super

  @exploit.use_target!(
    arch:     @target_arch,
    os:       @target_os,
    software: [@target_software, @target_version]
  )

  if raw_payload?
    @exploit.raw_payload = @raw_payload
  elsif payload_file?
    @exploit.use_payload_from!(@payload_file)
  elsif payload_name?
    @exploit.use_payload(name: @payload)
  end

  unless @exploit.payload
    print_error "Could not find a compatible payload for the exploit!"
    exit -1
  end

  return @exploit
end

#param_option_parserObject (protected)

Parses additional options for the loaded Exploit and Payload.


113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/ronin/ui/cli/commands/exploit.rb', line 113

def param_option_parser
  super do |opts|
    if @exploit.payload
      opts.separator ''
      opts.separator 'Payload Options:'

      @exploit.payload.each_param do |param|
        Parameters::Options.define(opts,param)
      end
    end
  end
end