class Rex::Exploitation::HeapLib
Encapsulates the generation of the Alexander Sotirov's HeapLib
javascript stub
Constants
- JavascriptFile
The source file to load the javascript from
- SymbolNames
The list of symbols found in the file. This is used to dynamically replace contents.
Public Class Methods
new(custom_js = '', opts = {})
click to toggle source
Initializes the heap library javascript
# File lib/rex/exploitation/heaplib.rb, line 59 def initialize(custom_js = '', opts = {}) load_js(custom_js, opts) end
Public Instance Methods
to_s()
click to toggle source
Return the replaced version of the javascript
# File lib/rex/exploitation/heaplib.rb, line 66 def to_s @js end
Protected Instance Methods
load_js(custom_js, opts = {})
click to toggle source
Loads the raw javascript from the source file and strips out comments
# File lib/rex/exploitation/heaplib.rb, line 75 def load_js(custom_js, opts = {}) # Grab the complete javascript File.open(JavascriptFile) do |f| @js = f.read end # Decode the text @js = Rex::Text.decode_base64(@js) # Append the real code @js += "\n" + custom_js if opts[:newobfu] # Obfuscate the javascript using the new lexer method js_obfu = JSObfu.new(@js) js_obfu.obfuscate @js = js_obfu.to_s return @js elsif opts[:noobfu] # Do not obfuscate, let the exploit do the work (useful to avoid double obfuscation) return @js end # Default to the old method # Obfuscate the javascript using the old method @js = ObfuscateJS.obfuscate(@js, 'Symbols' => SymbolNames) end