OS X Manage Sonic Pi - Metasploit


This page contains detailed information about how to use the post/osx/manage/sonic_pi metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.

Module Overview


Name: OS X Manage Sonic Pi
Module: post/osx/manage/sonic_pi
Source code: modules/post/osx/manage/sonic_pi.rb
Disclosure date: -
Last modification time: 2019-07-25 15:09:35 +0000
Supported architecture(s): -
Supported platform(s): OSX
Target service / protocol: -
Target network port(s): -
List of CVEs: -

This module controls Sonic Pi via its local OSC server. The server runs on 127.0.0.1:4557 and receives OSC messages over UDP. Yes, this is RCE, but it's local. I suggest playing music. :-)

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.

Side Effects:

  • audio-effects: Module may cause a noise (Examples: audio output from the speakers or hardware beeps).
  • screen-effects: Module may show something on the screen (Example: a window pops up).

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/manage/sonic_pi

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/manage/sonic_pi
msf post(sonic_pi) > show options
    ... show and set options ...
msf post(sonic_pi) > set SESSION session-id
msf post(sonic_pi) > 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/manage/sonic_pi")
  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.

Knowledge Base


Introduction


This module controls Sonic Pi via its local OSC server.

The server runs on 127.0.0.1:4557 and receives OSC messages over UDP.

Setup


I've supported only OS X. I had no luck running Sonic Pi on Windows, and I can't test Raspberry Pi at the moment.

brew cask install sonic-pi if you have Homebrew or download and install Sonic Pi from https://sonic-pi.net/#mac.

Actions


Name  Description
----  -----------
Run   Run Sonic Pi code
Stop  Stop all jobs

Options


OSC_HOST

This is the OSC server host, which is 127.0.0.1 by default.

OSC_PORT

This is the OSC server (UDP) port, which is 4557 by default.

START_SONIC_PI

Enable this to start Sonic Pi if it isn't running already. Note that this will start the GUI, which will be visible to the user.

FILE

This is the path to Sonic Pi code you want to run. It can be arbitrary Ruby.

SonicPiPath

This is the path to the Sonic Pi executable within its application bundle.

RubyPath

This is the path to a Ruby executable. Sonic Pi's vendored Ruby is the default.

Usage


msf5 post(osx/manage/sonic_pi) > options

Module options (post/osx/manage/sonic_pi):

   Name            Current Setting                                             Required  Description
   ----            ---------------                                             --------  -----------
   FILE            /rapid7/metasploit-framework/data/post/sonic_pi_example.rb  yes       Path to Sonic Pi code
   OSC_HOST        127.0.0.1                                                   yes       OSC server host
   OSC_PORT        4557                                                        yes       OSC server port
   SESSION                                                                     yes       The session to run this module on.
   START_SONIC_PI  false                                                       yes       Start Sonic Pi


Post action:

   Name  Description
   ----  -----------
   Run   Run Sonic Pi code


msf5 post(osx/manage/sonic_pi) > advanced

Module advanced options (post/osx/manage/sonic_pi):

   Name         Current Setting                                         Required  Description
   ----         ---------------                                         --------  -----------
   RubyPath     /Applications/Sonic Pi.app/server/native/ruby/bin/ruby  yes       Path to Ruby executable
   SonicPiPath  /Applications/Sonic Pi.app/Contents/MacOS/Sonic Pi      yes       Path to Sonic Pi executable
   VERBOSE      true                                                    no        Enable detailed status messages
   WORKSPACE                                                            no        Specify the workspace for this module

msf5 post(osx/manage/sonic_pi) > show actions

Post actions:

   Name  Description
   ----  -----------
   Run   Run Sonic Pi code
   Stop  Stop all jobs


msf5 post(osx/manage/sonic_pi) > set session -1
session => -1
msf5 post(osx/manage/sonic_pi) > run

[+] Sonic Pi is running
[*] Running Sonic Pi code: /rapid7/metasploit-framework/data/post/sonic_pi_example.rb
[*] echo [snip] | base64 -D | /Applications/Sonic\ Pi.app/server/native/ruby/bin/ruby
[*] Post module execution completed
msf5 post(osx/manage/sonic_pi) > set action Stop
action => Stop
msf5 post(osx/manage/sonic_pi) > run

[+] Sonic Pi is running
[*] Stopping all jobs
[*] echo [snip] | base64 -D | /Applications/Sonic\ Pi.app/server/native/ruby/bin/ruby
[*] Post module execution completed
msf5 post(osx/manage/sonic_pi) >

Go back to menu.

Msfconsole Usage


Here is how the osx/manage/sonic_pi post exploitation module looks in the msfconsole:

msf6 > use post/osx/manage/sonic_pi

msf6 post(osx/manage/sonic_pi) > show info

       Name: OS X Manage Sonic Pi
     Module: post/osx/manage/sonic_pi
   Platform: OSX
       Arch: 
       Rank: Normal

Provided by:
  Sam Aaron
  wvu <[email protected]>

Module side effects:
 audio-effects
 screen-effects

Compatible session types:
  Meterpreter
  Shell

Available actions:
  Name  Description
  ----  -----------
  Run   Run Sonic Pi code
  Stop  Stop all jobs

Basic options:
  Name            Current Setting                                                             Required  Description
  ----            ---------------                                                             --------  -----------
  FILE            /opt/metasploit-framework/embedded/framework/data/post/sonic_pi_example.rb  yes       Path to Sonic Pi code
  OSC_HOST        127.0.0.1                                                                   yes       OSC server host
  OSC_PORT        4557                                                                        yes       OSC server port
  SESSION                                                                                     yes       The session to run this module on.
  START_SONIC_PI  false                                                                       yes       Start Sonic Pi

Description:
  This module controls Sonic Pi via its local OSC server. The server 
  runs on 127.0.0.1:4557 and receives OSC messages over UDP. Yes, this 
  is RCE, but it's local. I suggest playing music. :-)

References:
  https://sonic-pi.net/
  https://github.com/samaaron/sonic-pi/wiki/Sonic-Pi-Internals----GUI-Ruby-API
  http://opensoundcontrol.org/spec-1_0

Module Options


This is a complete list of options available in the osx/manage/sonic_pi post exploitation module:

msf6 post(osx/manage/sonic_pi) > show options

Module options (post/osx/manage/sonic_pi):

   Name            Current Setting                                                             Required  Description
   ----            ---------------                                                             --------  -----------
   FILE            /opt/metasploit-framework/embedded/framework/data/post/sonic_pi_example.rb  yes       Path to Sonic Pi code
   OSC_HOST        127.0.0.1                                                                   yes       OSC server host
   OSC_PORT        4557                                                                        yes       OSC server port
   SESSION                                                                                     yes       The session to run this module on.
   START_SONIC_PI  false                                                                       yes       Start Sonic Pi

Post action:

   Name  Description
   ----  -----------
   Run   Run Sonic Pi code

Advanced Options


Here is a complete list of advanced options supported by the osx/manage/sonic_pi post exploitation module:

msf6 post(osx/manage/sonic_pi) > show advanced

Module advanced options (post/osx/manage/sonic_pi):

   Name         Current Setting                                         Required  Description
   ----         ---------------                                         --------  -----------
   RubyPath     /Applications/Sonic Pi.app/server/native/ruby/bin/ruby  yes       Path to Ruby executable
   SonicPiPath  /Applications/Sonic Pi.app/Contents/MacOS/Sonic Pi      yes       Path to Sonic Pi executable
   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/manage/sonic_pi module can do:

msf6 post(osx/manage/sonic_pi) > show actions

Post actions:

   Name  Description
   ----  -----------
   Run   Run Sonic Pi code
   Stop  Stop all jobs

Evasion Options


Here is the full list of possible evasion options supported by the osx/manage/sonic_pi post exploitation module in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):

msf6 post(osx/manage/sonic_pi) > 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:

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.

Sonic Pi is not running


Here is a relevant code snippet related to the "Sonic Pi is not running" error message:

92:	  end
93:	
94:	  def run
95:	    begin
96:	      unless check_lsof
97:	        print_error('Sonic Pi is not running')
98:	
99:	        return if @tried
100:	
101:	        if datastore['START_SONIC_PI']
102:	          print_status('Starting Sonic Pi...')

Go back to menu.


References


See Also


Check also the following modules related to this module:

Authors


  • Sam Aaron
  • wvu

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.