@@ -1117,6 +1117,28 @@ 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
+
1136
+ hash_sub = rig . to_h
1137
+ hash_sub [ :powershell ] = powershell
1138
+
1139
+ read_replace_script_template ( "to_powershell.hta.template" , hash_sub )
1140
+ end
1141
+
1120
1142
def self . to_win32pe_vbs ( framework , code , opts = { } )
1121
1143
to_exe_vbs ( to_win32pe ( framework , code , opts ) , opts )
1122
1144
end
@@ -1924,6 +1946,8 @@ def self.to_executable_fmt(framework, arch, plat, code, fmt, exeopts)
1924
1946
Msf ::Util ::EXE . to_win32pe_psh_reflection ( framework , code , exeopts )
1925
1947
when 'psh-cmd'
1926
1948
Msf ::Util ::EXE . to_powershell_command ( framework , arch , code )
1949
+ when 'hta-psh'
1950
+ Msf ::Util ::EXE . to_powershell_hta ( framework , arch , code )
1927
1951
end
1928
1952
end
1929
1953
@@ -1939,6 +1963,7 @@ def self.to_executable_fmt_formats
1939
1963
"exe-only" ,
1940
1964
"exe-service" ,
1941
1965
"exe-small" ,
1966
+ "hta-psh" ,
1942
1967
"loop-vbs" ,
1943
1968
"macho" ,
1944
1969
"msi" ,
0 commit comments