Sha256: 9a656e529696a3b2d1cac6228f19068212e612b43cf6ff7eed2e06ba86212caf

Contents?: true

Size: 1.67 KB

Versions: 9

Compression:

Stored size: 1.67 KB

Contents

# -*- coding: binary -*-

require 'rex/exploitation/powershell/output'
require 'rex/exploitation/powershell/parser'
require 'rex/exploitation/powershell/obfu'
require 'rex/exploitation/powershell/param'
require 'rex/exploitation/powershell/function'
require 'rex/exploitation/powershell/script'
require 'rex/exploitation/powershell/psh_methods'

module Rex
  module Exploitation
    module Powershell
      #
      # Reads script into a PowershellScript
      #
      # @param script_path [String] Path to the Script File
      #
      # @return [Script] Powershell Script object
      def self.read_script(script_path)
        Rex::Exploitation::Powershell::Script.new(script_path)
      end

      #
      # Insert substitutions into the powershell script
      # If script is a path to a file then read the file
      # otherwise treat it as the contents of a file
      #
      # @param script [String] Script file or path to script
      # @param subs [Array] Substitutions to insert
      #
      # @return [String] Modified script file
      def self.make_subs(script, subs)
        if ::File.file?(script)
          script = ::File.read(script)
        end

        subs.each do |set|
          script.gsub!(set[0], set[1])
        end

        script
      end

      #
      # Return an array of substitutions for use in make_subs
      #
      # @param subs [String] A ; seperated list of substitutions
      #
      # @return [Array] An array of substitutions
      def self.process_subs(subs)
        return [] if subs.nil? or subs.empty?
        new_subs = []
        subs.split(';').each do |set|
          new_subs << set.split(',', 2)
        end

        new_subs
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 3 rubygems

Version Path
rex-2.0.8 lib/rex/exploitation/powershell.rb
rex-2.0.7 lib/rex/exploitation/powershell.rb
rex-2.0.5 lib/rex/exploitation/powershell.rb
rex-2.0.4 lib/rex/exploitation/powershell.rb
dstruct-0.0.1 lib/rex/exploitation/powershell.rb
rex-2.0.3 lib/rex/exploitation/powershell.rb
librex-0.0.999 lib/rex/exploitation/powershell.rb
rex-2.0.2 lib/rex/exploitation/powershell.rb
librex-0.0.71 lib/rex/exploitation/powershell.rb