Skip to content

Commit b428736

Browse files
committed
Add support for injection of encrypted dll payloads
1 parent 1140efc commit b428736

File tree

4 files changed

+11
-12
lines changed

4 files changed

+11
-12
lines changed

lib/msf/core/post/windows/reflective_dll_injection.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,9 @@ def inject_dll_into_process(process, dll_path, loader_name: 'ReflectiveLoader',
7878
# @return [Array] Tuple of allocated memory address and offset to the
7979
# +ReflectiveLoader+ function.
8080
def inject_dll_data_into_process(process, dll_data, loader_name: 'ReflectiveLoader', loader_ordinal: EXPORT_REFLECTIVELOADER)
81-
offset = load_rdi_dll_from_data(dll_data, loader_name: loader_name, loader_ordinal: loader_ordinal)
82-
dll_mem = inject_into_process(process, dll_data)
81+
decrypted_dll_data = ::MetasploitPayloads.decrypt_payload(payload: dll_data)
82+
offset = load_rdi_dll_from_data(decrypted_dll_data, loader_name: loader_name, loader_ordinal: loader_ordinal)
83+
dll_mem = inject_into_process(process, decrypted_dll_data)
8384

8485
return dll_mem, offset
8586
end

lib/msf/core/reflective_dll_loader.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ module Msf::ReflectiveDLLLoader
2424
# @return [Array] Tuple of DLL contents and offset to the
2525
# +ReflectiveLoader+ function within the DLL.
2626
def load_rdi_dll(dll_path, loader_name: 'ReflectiveLoader', loader_ordinal: EXPORT_REFLECTIVELOADER)
27-
dll = ''
28-
::File.open(dll_path, 'rb') { |f| dll = f.read }
27+
encrypted_dll = ::File.binread(dll_path)
28+
dll = ::MetasploitPayloads.decrypt_payload(payload: encrypted_dll)
2929

3030
offset = parse_pe(dll, loader_name: loader_name, loader_ordinal: loader_ordinal)
3131

@@ -43,7 +43,8 @@ def load_rdi_dll(dll_path, loader_name: 'ReflectiveLoader', loader_ordinal: EXPO
4343
#
4444
# @return [Integer] offset to the +ReflectiveLoader+ function within the DLL.
4545
def load_rdi_dll_from_data(dll_data, loader_name: 'ReflectiveLoader', loader_ordinal: EXPORT_REFLECTIVELOADER)
46-
offset = parse_pe(dll_data, loader_name: loader_name, loader_ordinal: loader_ordinal)
46+
decrypted_dll_data = ::MetasploitPayloads.decrypt_payload(payload: dll_data)
47+
offset = parse_pe(decrypted_dll_data, loader_name: loader_name, loader_ordinal: loader_ordinal)
4748

4849
unless offset
4950
raise 'Cannot find the ReflectiveLoader entry point in DLL data'

lib/rex/post/meterpreter/extensions/priv/priv.rb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,8 @@ def getsystem(technique=TECHNIQUE[:any])
8282
raise RuntimeError, "#{elevators.chomp(', ')} not found", caller
8383
end
8484

85-
elevator_data = ''
86-
87-
::File.open(elevator_path, 'rb') { |f|
88-
elevator_data += f.read(f.stat.size)
89-
}
85+
encrypted_elevator_data = ::File.binread(elevator_path)
86+
elevator_data = ::MetasploitPayloads.decrypt_payload(payload: encrypted_elevator_data)
9087

9188
request.add_tlv(TLV_TYPE_ELEVATE_SERVICE_DLL, elevator_data)
9289
request.add_tlv(TLV_TYPE_ELEVATE_SERVICE_LENGTH, elevator_data.length)

modules/exploits/windows/local/ms15_078_atmfd_bof.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,8 +384,8 @@ def exploit
384384
library_path = ::File.expand_path(library_path)
385385

386386
print_status("Reflectively injecting the exploit DLL into #{process.pid}...")
387-
dll = ''
388-
::File.open(library_path, 'rb') { |f| dll = f.read }
387+
encrypted_dll = ::File.binread(library_path)
388+
dll = ::MetasploitPayloads.decrypt_payload(payload: encrypted_dll)
389389

390390
patch_win32k_offsets(dll)
391391
patch_nt_offsets(dll)

0 commit comments

Comments
 (0)