Sha256: f13a02c00f07fc8ee81bcb683837c843e1f9ca7cc84f1f2d4c1459bf299596d7

Contents?: true

Size: 1.47 KB

Versions: 37

Compression:

Stored size: 1.47 KB

Contents

require 'rex/text'
require 'rex/exploitation/obfuscatejs'

module Rex
module Exploitation

#
# Encapsulates the generation of the Alexander Sotirov's HeapLib javascript
# stub
#
class HeapLib

	#
	# The source file to load the javascript from
	#
	JavascriptFile = File.join(File.dirname(__FILE__), "heaplib.js.b64")

	#
	# The list of symbols found in the file.  This is used to dynamically
	# replace contents.
	#
	SymbolNames  = 
		{
			"Methods" =>
				[
					"vtable",
					"lookasideAddr",
					"lookaside",
					"freeList",
					"gc",
					"flushOleaut32",
					"freeOleaut32",
					"allocOleaut32",
					"free",
					"alloc",
					"addr",
					"hex",
					"round",
					"paddingStr",
					"padding",
					"debugBreak",
					"debugHeap",
					"debug",
				],
			"Classes" =>
				[	
					{ 'Namespace' => "heapLib", 'Class' => "ie" }
				],
			"Namespaces" =>
				[
					"heapLib"
				]
		}

	#
	# Initializes the heap library javascript
	#
	def initialize(custom_js = '')
		load_js(custom_js)
	end

	#
	# Return the replaced version of the javascript
	#
	def to_s
		@js
	end

protected

	#
	# Loads the raw javascript from the source file and strips out comments
	#
	def load_js(custom_js)
		
		# Grab the complete javascript
		File.open(JavascriptFile) { |f|
			@js = f.read
		}
		
		# Decode the text
		@js = Rex::Text.decode_base64(@js)
		
		# Append the real code
		@js += "\n" + custom_js
	
		# Obfuscate the javascript
		@js = ObfuscateJS.obfuscate(@js, 'Symbols' => SymbolNames)
	end

end

end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
librex-0.0.50 lib/rex/exploitation/heaplib.rb
librex-0.0.49 lib/rex/exploitation/heaplib.rb
librex-0.0.48 lib/rex/exploitation/heaplib.rb
librex-0.0.47 lib/rex/exploitation/heaplib.rb
librex-0.0.46 lib/rex/exploitation/heaplib.rb
librex-0.0.44 lib/rex/exploitation/heaplib.rb
librex-0.0.43 lib/rex/exploitation/heaplib.rb
librex-0.0.42 lib/rex/exploitation/heaplib.rb
librex-0.0.41 lib/rex/exploitation/heaplib.rb
librex-0.0.40 lib/rex/exploitation/heaplib.rb
librex-0.0.39 lib/rex/exploitation/heaplib.rb
librex-0.0.38 lib/rex/exploitation/heaplib.rb
librex-0.0.37 lib/rex/exploitation/heaplib.rb
librex-0.0.36 lib/rex/exploitation/heaplib.rb
librex-0.0.35 lib/rex/exploitation/heaplib.rb
librex-0.0.34 lib/rex/exploitation/heaplib.rb
librex-0.0.33 lib/rex/exploitation/heaplib.rb
librex-0.0.32 lib/rex/exploitation/heaplib.rb
librex-0.0.31 lib/rex/exploitation/heaplib.rb
librex-0.0.30 lib/rex/exploitation/heaplib.rb