Sha256: 73f1eb2c683bf5e42c3e6649a1fa08f2966667034b6f7633d3040a3b205c1b42

Contents?: true

Size: 1.67 KB

Versions: 1

Compression:

Stored size: 1.67 KB

Contents

# frozen_string_literal: true
#
# ronin-exploits - A Ruby library for ronin-rb that provides exploitation and
# payload crafting functionality.
#
# Copyright (c) 2007-2022 Hal Brodigan (postmodern.mod3 at gmail.com)
#
# ronin-exploits is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ronin-exploits 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 Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with ronin-exploits.  If not, see <https://www.gnu.org/licenses/>.
#

require 'tmpdir'
require 'fileutils'

module Ronin
  module Exploits
    module Mixins
      #
      # Sets up a temporary build directory for the exploit.
      #
      # @api public
      #
      module BuildDir
        # The build directory for the exploit.
        #
        # @return [String, nil]
        attr_reader :build_dir

        #
        # Sets {#build_dir} and then builds the exploit.
        #
        def perform_build
          exploit_name = self.class.id.tr('/','-')
          @build_dir   = Dir.mktmpdir("ronin-exploit-#{exploit_name}-")

          super
        end

        #
        # Cleans up the exploit and deletes the {#build_dir}.
        #
        def perform_cleanup
          super

          FileUtils.rm_r(@build_dir)
          @build_dir = nil
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ronin-exploits-1.0.0.beta1 lib/ronin/exploits/mixins/build_dir.rb