Class: Ronin::UI::CLI::Commands::Payload

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

Instance Method Summary collapse

Instance Method Details

#deploy_payloadObject (protected)

Deploys the built payload.


121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/ronin/ui/cli/commands/payload.rb', line 121

def deploy_payload
  begin
    @payload.deploy!
  rescue Behaviors::TestFailed, Payloads::Exception => e
    print_exception(e)
    exit -1
  end

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

  @payload.evacuate!
end

#executeObject

Builds and optionally deploys the loaded payload.


81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/ronin/ui/cli/commands/payload.rb', line 81

def execute
  begin
    # Build the payload
    @payload.build!
  rescue Behaviors::Exception,
         Payloads::Exception => error
    print_error error.message
    exit -1
  end

  if deploy?
    deploy_payload!
  elsif print?
    print_payload!
  end
end

Prints the built payload.


103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/ronin/ui/cli/commands/payload.rb', line 103

def print_payload
  raw_payload = @payload.raw_payload

  if raw?
    # Write the raw payload
    write raw_payload
  elsif hex?
    # Prints the raw payload as a hex String
    puts raw_payload.hex_escape
  else
    # Prints the raw payload as a String
    puts raw_payload.dump
  end
end

#setupObject

Sets up the Payload command.


71
72
73
74
75
76
# File 'lib/ronin/ui/cli/commands/payload.rb', line 71

def setup
  super

  # silence all output, if we are to print the built payload
  UI::Output.silent! if raw?
end