@@ -127,6 +127,13 @@ def self.to_executable(framework, arch, plat, code='', opts={})
127
127
end
128
128
# XXX: Add remaining MIPSLE systems here
129
129
end
130
+
131
+ if ( arch . index ( ARCH_MIPSBE ) )
132
+ if ( plat . index ( Msf ::Module ::Platform ::Linux ) )
133
+ return to_linux_mipsbe_elf ( framework , code )
134
+ end
135
+ # XXX: Add remaining MIPSLE systems here
136
+ end
130
137
nil
131
138
end
132
139
@@ -615,7 +622,7 @@ def self.to_osx_x64_macho(framework, code, opts={})
615
622
# segments as writable and overwrites the entrypoint (usually _start) with
616
623
# the payload.
617
624
#
618
- def self . to_exe_elf ( framework , opts , template , code )
625
+ def self . to_exe_elf ( framework , opts , template , code , big_endian = false )
619
626
620
627
# Allow the user to specify their own template
621
628
set_template_default ( opts , template )
@@ -640,11 +647,21 @@ def self.to_exe_elf(framework, opts, template, code)
640
647
# Use the proper offsets and pack size
641
648
case elf [ 4 ]
642
649
when 1 , "\x01 " # ELFCLASS32 - 32 bit (ruby 1.8 and 1.9)
643
- elf [ 0x44 , 4 ] = [ elf . length ] . pack ( 'V' ) #p_filesz
644
- elf [ 0x48 , 4 ] = [ elf . length + code . length ] . pack ( 'V' ) #p_memsz
650
+ if big_endian
651
+ elf [ 0x44 , 4 ] = [ elf . length ] . pack ( 'N' ) #p_filesz
652
+ elf [ 0x48 , 4 ] = [ elf . length + code . length ] . pack ( 'N' ) #p_memsz
653
+ else # little endian
654
+ elf [ 0x44 , 4 ] = [ elf . length ] . pack ( 'V' ) #p_filesz
655
+ elf [ 0x48 , 4 ] = [ elf . length + code . length ] . pack ( 'V' ) #p_memsz
656
+ end
645
657
when 2 , "\x02 " # ELFCLASS64 - 64 bit (ruby 1.8 and 1.9)
646
- elf [ 0x60 , 8 ] = [ elf . length ] . pack ( 'Q' ) #p_filesz
647
- elf [ 0x68 , 8 ] = [ elf . length + code . length ] . pack ( 'Q' ) #p_memsz
658
+ if big_endian
659
+ elf [ 0x60 , 8 ] = [ elf . length ] . pack ( 'Q>' ) #p_filesz
660
+ elf [ 0x68 , 8 ] = [ elf . length + code . length ] . pack ( 'Q>' ) #p_memsz
661
+ else # little endian
662
+ elf [ 0x60 , 8 ] = [ elf . length ] . pack ( 'Q' ) #p_filesz
663
+ elf [ 0x68 , 8 ] = [ elf . length + code . length ] . pack ( 'Q' ) #p_memsz
664
+ end
648
665
else
649
666
raise RuntimeError , "Invalid ELF template: EI_CLASS value not supported"
650
667
end
@@ -722,6 +739,11 @@ def self.to_linux_mipsle_elf(framework, code, opts={})
722
739
return elf
723
740
end
724
741
742
+ def self . to_linux_mipsbe_elf ( framework , code , opts = { } )
743
+ elf = to_exe_elf ( framework , opts , "template_mipsbe_linux.bin" , code , true )
744
+ return elf
745
+ end
746
+
725
747
def self . to_exe_vba ( exes = '' )
726
748
exe = exes . unpack ( 'C*' )
727
749
vba = ""
0 commit comments