Sha256: 3cf1e99f9236186e18bc4ed84aecf13fbac7e6317f48ecd220d72853711ac40f

Contents?: true

Size: 1.95 KB

Versions: 3

Compression:

Stored size: 1.95 KB

Contents

#
# Ronin - A Ruby platform for exploit development and security research.
#
# Copyright (c) 2009-2010 Hal Brodigan (postmodern.mod3 at gmail.com)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
#

require 'ronin/campaign'
require 'ronin/address'
require 'ronin/remote_file'
require 'ronin/model'

require 'fileutils'

module Ronin
  class Target

    include Model

    # Primary key of the target
    property :id, Serial

    # The campaign the target belongs to
    belongs_to :campaign, :unique => :campaign_address

    # The host being targeted
    belongs_to :address, :unique => :campaign_address

    # The organization that is being targeted
    has 1, :organization, :through => :address

    # The remote files recovered from the target
    has 0..n, :remote_files

    #
    # The directory to store files related to the target.
    #
    # @return [String]
    #   The path to the directory.
    #
    # @since 1.0.0
    #
    def directory
      if self.campaign
        path = File.join(self.campaign.directory,self.address.address)

        FileUtils.mkdir(path) unless File.directory?(path)
        return path
      end
    end

    #
    # Converts the target to a String.
    #
    # @return [String]
    #   The address of the target.
    #
    # @since 1.0.0
    #
    def to_s
      self.address.to_s
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ronin-1.0.0.pre3 lib/ronin/target.rb
ronin-1.0.0.pre2 lib/ronin/target.rb
ronin-1.0.0.pre1 lib/ronin/target.rb