|
| 1 | +# -*- coding: binary -*- |
| 2 | + |
| 3 | +require 'rex/exploitation/vbsobfuscate' |
| 4 | + |
| 5 | +module Msf |
| 6 | + # VBS obfuscation library wrapper for Rex::Exploitation::VBSObfuscate |
| 7 | + module Exploit::VBSObfuscate |
| 8 | + def initialize(info = {}) |
| 9 | + super |
| 10 | + register_advanced_options([ |
| 11 | + OptInt.new('VbsObfuscate', [false, 'Number of times to obfuscate VBS', 1]), |
| 12 | + ]) |
| 13 | + end |
| 14 | + |
| 15 | + # |
| 16 | + # Returns an VBSObfuscate object. A wrapper of ::Rex::Exploitation::VBSObfuscate.new(vbs).obfuscate! |
| 17 | + # |
| 18 | + # @param vbs [String] VBS code |
| 19 | + # @param opts [Hash] obfuscation options |
| 20 | + # * :iterations [FixNum] Number of times to obfuscate |
| 21 | + # * :normalize_whitespace [Boolean] normalize line endings and strip leading/trailing whitespace from each line (true) |
| 22 | + # * :dynamic_execution [Boolean] dynamically execute obfuscated code with Execute (true) |
| 23 | + # @return [::Rex::Exploitation::VBSObfuscate] |
| 24 | + # |
| 25 | + def vbs_obfuscate(vbs, opts = {}) |
| 26 | + iterations = (opts[:iterations] || datastore['VbsObfuscate']).to_i |
| 27 | + normalize_whitespace = opts[:normalize_whitespace].blank? || opts[:normalize_whitespace] |
| 28 | + dynamic_execution = opts[:dynamic_execution].blank? || opts[:dynamic_execution] |
| 29 | + |
| 30 | + vbs_obfuscate = ::Rex::Exploitation::VBSObfuscate.new(vbs) |
| 31 | + vbs_obfuscate.obfuscate!( |
| 32 | + iterations: iterations, |
| 33 | + normalize_whitespace: normalize_whitespace, |
| 34 | + dynamic_execution: dynamic_execution |
| 35 | + ) |
| 36 | + vbs_obfuscate |
| 37 | + end |
| 38 | + end |
| 39 | +end |
0 commit comments