Skip to content

Commit 9c028c1

Browse files
author
Tod Beardsley
committed
Fixes rapid7#4083, make the split nil-safe
In the reported case, the expected cookies were not present on the response, thus, the second split was trying to split a `nil`. This solves the immediately problem by a) splitting up the splits into discrete sections, and b) `NilClass#to_s`'ing the result of the first split. This makes the split safe. Now, there may be a larger issue here where you're not getting the expected cookies -- it sounds like the target in this case is responding differently, which implies that the module isn't going to be effective against that particular target. But, at least it won't crash. It may merely try fruitlessly the entire run, though. I can't know without looking at a pcap, and in the reported case, a pcap seems unlikely since this was a bug found in the field.
1 parent 71a6ec8 commit 9c028c1

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

modules/auxiliary/scanner/http/owa_login.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,15 @@ def try_user_pass(opts)
213213
return :Skip_pass
214214
end
215215
else
216-
# these two lines are the authentication info
216+
# The authentication info is in the cookies on this response
217217
cookies = res.get_cookies
218-
sessionid = 'sessionid=' << cookies.split('sessionid=')[1].split('; ')[0]
219-
cadata = 'cadata=' << cookies.split('cadata=')[1].split('; ')[0]
220-
headers['Cookie'] = 'PBack=0; ' << sessionid << '; ' << cadata
218+
sessionid_value = cookies.split('sessionid=')[1]
219+
sessionid_value = sessionid_value.to_s.split('; ')[0]
220+
sessionid_header = "sessionid=#{sessionid_value}"
221+
cadata_value = cookies.split('cadata=')[1]
222+
cadata_value = cadata_value.to_s.split('; ')[0]
223+
cadata_header = "cadata=#{cadata_value}"
224+
headers['Cookie'] = 'PBack=0; ' << sessionid_header << '; ' << cadata_header
221225
end
222226

223227
begin

0 commit comments

Comments
 (0)