Files
metasploit-gs/lib/msf/core/model/workspace.rb
T
Tod Beardsley 1db9d8eb01 Fixes #2444. Adds an ExploitedHost table, adds the db_exploited command, adds the report_exploit() function.
Tested with meterpreter, shell, and clientside exploit sessions. 


git-svn-id: file:///home/svn/framework3/trunk@10130 4d416f70-5f16-0410-b530-b9f4589650da
2010-08-24 21:57:04 +00:00

59 lines
1.1 KiB
Ruby

module Msf
class DBManager
class Workspace < ActiveRecord::Base
include DBSave
DEFAULT = "default"
has_many :hosts, :dependent => :destroy
has_many :notes, :dependent => :destroy
has_many :loots, :dependent => :destroy
has_many :events,:dependent => :destroy
has_many :reports, :dependent => :destroy
has_many :tasks, :dependent => :destroy
has_many :services, :through => :hosts
has_many :clients, :through => :hosts
has_many :vulns, :through => :hosts
has_many :creds, :dependent => :destroy
has_many :exploited_hosts, :through => :hosts
#has_many :notes, :through => :hosts
validates_uniqueness_of :name
validates_presence_of :name
def self.default
Workspace.find_or_create_by_name(DEFAULT)
end
def default?
name == DEFAULT
end
def creds
Cred.find(
:all,
:include => {:service => :host}, # That's some magic right there.
:conditions => ["hosts.workspace_id = ?", self.id]
)
end
#
# This method iterates the creds table calling the supplied block with the
# cred instance of each entry.
#
def each_cred(&block)
creds.each do |cred|
block.call(cred)
end
end
end
end
end