@@ -1117,6 +1117,29 @@ def self.to_powershell_command(framework, arch, code)
1117
1117
method : 'reflection' )
1118
1118
end
1119
1119
1120
+ def self . to_powershell_hta ( framework , arch , code )
1121
+ template_path = File . join ( Msf ::Config . data_directory ,
1122
+ "templates" ,
1123
+ "scripts" )
1124
+
1125
+ powershell = Rex ::Powershell ::Command . cmd_psh_payload ( code ,
1126
+ arch ,
1127
+ template_path ,
1128
+ encode_final_payload : true ,
1129
+ remove_comspec : true ,
1130
+ method : 'reflection' )
1131
+
1132
+ # Intialize rig and value names
1133
+ rig = Rex ::RandomIdentifierGenerator . new ( )
1134
+ rig . init_var ( :var_shell )
1135
+ rig . init_var ( :var_fso )
1136
+
1137
+ hash_sub = rig . to_h
1138
+ hash_sub [ :powershell ] = powershell
1139
+
1140
+ read_replace_script_template ( "to_powershell.hta.template" , hash_sub )
1141
+ end
1142
+
1120
1143
def self . to_win32pe_vbs ( framework , code , opts = { } )
1121
1144
to_exe_vbs ( to_win32pe ( framework , code , opts ) , opts )
1122
1145
end
@@ -1928,6 +1951,8 @@ def self.to_executable_fmt(framework, arch, plat, code, fmt, exeopts)
1928
1951
Msf ::Util ::EXE . to_win32pe_psh_reflection ( framework , code , exeopts )
1929
1952
when 'psh-cmd'
1930
1953
Msf ::Util ::EXE . to_powershell_command ( framework , arch , code )
1954
+ when 'hta-psh'
1955
+ Msf ::Util ::EXE . to_powershell_hta ( framework , arch , code )
1931
1956
end
1932
1957
end
1933
1958
@@ -1943,6 +1968,7 @@ def self.to_executable_fmt_formats
1943
1968
"exe-only" ,
1944
1969
"exe-service" ,
1945
1970
"exe-small" ,
1971
+ "hta-psh" ,
1946
1972
"loop-vbs" ,
1947
1973
"macho" ,
1948
1974
"msi" ,
0 commit comments