Class: Msf::RPC::RPC_Job

Inherits:
RPC_Base show all
Defined in:
lib/msf/core/rpc/v10/rpc_job.rb

Instance Attribute Summary

Attributes inherited from RPC_Base

#framework, #job_status_tracker, #service, #tokens, #users

Instance Method Summary collapse

Methods inherited from RPC_Base

#error, #initialize

Constructor Details

This class inherits a constructor from Msf::RPC::RPC_Base

Instance Method Details

#rpc_info(jid) ⇒ Hash

Returns information about a job.

Examples:

Here's how you would use this from the client:

rpc.call('job.info', 0)

Parameters:

  • jid (Integer)

    Job ID.

Returns:

  • (Hash)

    A hash that contains information about the job, such as the following (and maybe more):

    • 'jid' [Integer] The Job ID.

    • 'name' [String] The name of the job.

    • 'start_time' [Integer] The start time.

    • 'datastore' [Hash] Datastore options for the module.

Raises:



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/msf/core/rpc/v10/rpc_job.rb', line 49

def rpc_info(jid)
  obj = self.framework.jobs[jid.to_s]
  error(500, "Invalid Job") if not obj

  info = {
    :jid => obj.jid,
    :name => obj.name,
    :start_time => obj.start_time.to_i
  }

  if obj.ctx && obj.ctx[0]
    if obj.ctx[0].respond_to?(:get_resource)
      info[:uripath] = obj.ctx[0].get_resource
    end
    if obj.ctx[0].respond_to?(:datastore)
      info[:datastore] = obj.ctx[0].datastore.to_h
    end
  end

  info
end

#rpc_listHash

Returns a list of jobs.

Examples:

Here's how you would use this from the client:

# This will return ('0' is the job ID):
# {"0"=>"Exploit: windows/browser/ms14_064_ole_code_execution"
rpc.call('job.list')

Returns:

  • (Hash)

    A list of jobs (IDs and names). Each key is the job ID, and each value is the job name.



14
15
16
17
18
19
20
# File 'lib/msf/core/rpc/v10/rpc_job.rb', line 14

def rpc_list
  res = {}
  self.framework.jobs.each do |j|
    res[j[0]] = j[1].name
  end
  res
end

#rpc_stop(jid) ⇒ Hash

Stops a job.

Examples:

Here's how you would use this from the client:

rpc.call('job.stop', 0)

Parameters:

  • jid (Integer)

    Job ID.

Returns:

  • (Hash)

    A hash indicating the action was successful. It contains the following key:

    • 'result' [String] A successful message: 'success'

Raises:



30
31
32
33
34
35
36
# File 'lib/msf/core/rpc/v10/rpc_job.rb', line 30

def rpc_stop(jid)
  jid = jid.to_s
  obj = self.framework.jobs[jid]
  error(500, "Invalid Job") if not obj
  self.framework.jobs.stop_job(jid)
  { "result" => "success" }
end