@@ -107,6 +107,10 @@ def self.to_zip(files)
107
107
# @return [String]
108
108
# @return [NilClass]
109
109
def self . to_executable ( framework , arch , plat , code = '' , opts = { } )
110
+ if elf? code
111
+ return code
112
+ end
113
+
110
114
if arch . index ( ARCH_X86 )
111
115
112
116
if plat . index ( Msf ::Module ::Platform ::Windows )
@@ -959,6 +963,9 @@ def self.to_osx_app(exe, opts = {})
959
963
# @param big_endian [Boolean] Set to "false" by default
960
964
# @return [String]
961
965
def self . to_exe_elf ( framework , opts , template , code , big_endian = false )
966
+ if elf? code
967
+ return code
968
+ end
962
969
963
970
# Allow the user to specify their own template
964
971
set_template_default ( opts , template )
@@ -2127,6 +2134,9 @@ def self.to_executable_fmt(framework, arch, plat, code, fmt, exeopts)
2127
2134
exeopts [ :uac ] = true
2128
2135
Msf ::Util ::EXE . to_exe_msi ( framework , exe , exeopts )
2129
2136
when 'elf'
2137
+ if elf? code
2138
+ return code
2139
+ end
2130
2140
if !plat || plat . index ( Msf ::Module ::Platform ::Linux )
2131
2141
case arch
2132
2142
when ARCH_X86 , nil
@@ -2154,6 +2164,9 @@ def self.to_executable_fmt(framework, arch, plat, code, fmt, exeopts)
2154
2164
end
2155
2165
end
2156
2166
when 'elf-so'
2167
+ if elf? code
2168
+ return code
2169
+ end
2157
2170
if !plat || plat . index ( Msf ::Module ::Platform ::Linux )
2158
2171
case arch
2159
2172
when ARCH_X64
@@ -2293,6 +2306,10 @@ def self.find_payload_tag(mo, err_msg)
2293
2306
bo
2294
2307
end
2295
2308
2309
+ def self . elf? ( code )
2310
+ code [ 0 ..3 ] == "\x7F ELF"
2311
+ end
2312
+
2296
2313
end
2297
2314
end
2298
2315
end
0 commit comments