File tree Expand file tree Collapse file tree 2 files changed +70
-2
lines changed
spec/lib/rex/exploitation Expand file tree Collapse file tree 2 files changed +70
-2
lines changed Original file line number Diff line number Diff line change @@ -88,8 +88,10 @@ def load_js(custom_js, opts = {})
88
88
89
89
if opts [ :newobfu ]
90
90
# Obfuscate the javascript using the new lexer method
91
- @js = JSObfu . new ( @js )
92
- return @js . obfuscate
91
+ js_obfu = JSObfu . new ( @js )
92
+ js_obfu . obfuscate
93
+ @js = js_obfu . to_s
94
+ return @js
93
95
elsif opts [ :noobfu ]
94
96
# Do not obfuscate, let the exploit do the work (useful to avoid double obfuscation)
95
97
return @js
Original file line number Diff line number Diff line change
1
+ # -*- coding:binary -*-
2
+ require 'spec_helper'
3
+
4
+ require 'rex/exploitation/heaplib'
5
+
6
+ describe Rex ::Exploitation ::HeapLib do
7
+
8
+ let ( :custom_code ) { "var test = 'metasploit';" }
9
+ let ( :plain_signature ) { 'JavaScript Heap Exploitation library' }
10
+ let ( :signature ) { 'function(maxAlloc, heapBase)' }
11
+ let ( :methods ) {
12
+ [
13
+ 'lookasideAddr' ,
14
+ 'lookaside' ,
15
+ 'flushOleaut32' ,
16
+ 'freeOleaut32' ,
17
+ 'allocOleaut32' ,
18
+ 'paddingStr' ,
19
+ 'debugBreak' ,
20
+ 'debugHeap'
21
+ ]
22
+ }
23
+
24
+ subject ( :heap_lib_class ) do
25
+ described_class . allocate
26
+ end
27
+
28
+ subject ( :heap_lib ) do
29
+ described_class . new
30
+ end
31
+
32
+ describe "#initialize" do
33
+ it "returns an String" do
34
+ expect ( heap_lib_class . send ( :initialize ) ) . to be_a ( String )
35
+ end
36
+
37
+ it "returns the heap lib code" do
38
+ expect ( heap_lib_class . send ( :initialize ) ) . to include ( signature )
39
+ end
40
+
41
+ it "obfuscates with ObfuscateJS by default" do
42
+ methods . each do |m |
43
+ expect ( heap_lib_class . send ( :initialize ) ) . to_not include ( m )
44
+ end
45
+ end
46
+
47
+ it "allows to provide custom JS code as argument" do
48
+ expect ( heap_lib_class . send ( :initialize , custom_code ) ) . to include ( custom_code )
49
+ end
50
+
51
+ it "allows to disable obfuscation" do
52
+ expect ( heap_lib_class . send ( :initialize , '' , { :noobfu => true } ) ) . to include ( plain_signature )
53
+ end
54
+
55
+ it "allows to use JSObfu for obfuscation" do
56
+ expect ( heap_lib_class . send ( :initialize , '' , { :newobfu => true } ) ) . to_not include ( plain_signature )
57
+ end
58
+ end
59
+
60
+ describe "#to_s" do
61
+ it "returns the heap lib js code" do
62
+ expect ( heap_lib . to_s ) . to include ( signature )
63
+ end
64
+ end
65
+
66
+ end
You can’t perform that action at this time.
0 commit comments