Skip to content

Commit 73c2610

Browse files
committed
Merge remote-tracking branch 'jvazquez-r7/mipsle_elf_support' into rapid7
[Closes 1666]
2 parents 1d95abc + e78635f commit 73c2610

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
; build with:
2+
; nasm elf_mipsle_template.s -f bin -o template_mipsle_linux.bin
3+
4+
BITS 32
5+
6+
org 0x00400000
7+
8+
ehdr: ; Elf32_Ehdr
9+
db 0x7F, "ELF", 1, 1, 1, 0 ; e_ident
10+
db 0, 0, 0, 0, 0, 0, 0, 0 ;
11+
dw 2 ; e_type = ET_EXEC for an executable
12+
dw 0x8 ; e_machine = MIPS
13+
dd 1 ; e_version
14+
dd _start ; e_entry
15+
dd phdr - $$ ; e_phoff
16+
dd 0 ; e_shoff
17+
dd 0 ; e_flags
18+
dw ehdrsize ; e_ehsize
19+
dw phdrsize ; e_phentsize
20+
dw 1 ; e_phnum
21+
dw 0 ; e_shentsize
22+
dw 0 ; e_shnum
23+
dw 0 ; e_shstrndx
24+
25+
ehdrsize equ $ - ehdr
26+
27+
phdr: ; Elf32_Phdr
28+
dd 1 ; p_type = PT_LOAD
29+
dd 0 ; p_offset
30+
dd $$ ; p_vaddr
31+
dd $$ ; p_paddr
32+
dd 0xDEADBEEF ; p_filesz
33+
dd 0xDEADBEEF ; p_memsz
34+
dd 7 ; p_flags = rwx
35+
dd 0x1000 ; p_align
36+
37+
phdrsize equ $ - phdr
38+
39+
_start:
40+
84 Bytes
Binary file not shown.

lib/msf/util/exe.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,13 @@ def self.to_executable(framework, arch, plat, code='', opts={})
120120
end
121121
# XXX: Add PPC OS X and Linux here
122122
end
123+
124+
if(arch.index(ARCH_MIPSLE))
125+
if(plat.index(Msf::Module::Platform::Linux))
126+
return to_linux_mipsle_elf(framework, code)
127+
end
128+
# XXX: Add remaining MIPSLE systems here
129+
end
123130
nil
124131
end
125132

@@ -710,6 +717,11 @@ def self.to_linux_armle_elf(framework, code, opts={})
710717
return elf
711718
end
712719

720+
def self.to_linux_mipsle_elf(framework, code, opts={})
721+
elf = to_exe_elf(framework, opts, "template_mipsle_linux.bin", code)
722+
return elf
723+
end
724+
713725
def self.to_exe_vba(exes='')
714726
exe = exes.unpack('C*')
715727
vba = ""

0 commit comments

Comments
 (0)