Skip to content

Commit dfab26e

Browse files
committed
Land rapid7#3359, more Set-Cookie fixes
2 parents 827feae + df4b832 commit dfab26e

36 files changed

+64
-63
lines changed

modules/auxiliary/scanner/http/dolibarr_login.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ def get_sid_token
4242
'uri' => normalize_uri(@uri.path)
4343
})
4444

45-
return [nil, nil] if not (res and res.headers['Set-Cookie'])
45+
return [nil, nil] if res.nil? || res.get_cookies.empty?
4646

4747
# Get the session ID from the cookie
48-
m = res.headers['Set-Cookie'].match(/(DOLSESSID_.+);/)
48+
m = get_cookies.match(/(DOLSESSID_.+);/)
4949
id = (m.nil?) ? nil : m[1]
5050

5151
# Get the token from the decompressed HTTP body response

modules/auxiliary/scanner/http/glassfish_login.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def try_glassfish_login(version,user,pass)
167167
print_status("Trying credential GlassFish 2.x #{user}:'#{pass}'....")
168168
res = try_login(user,pass)
169169
if res and res.code == 302
170-
session = $1 if (res and res.headers['Set-Cookie'] =~ /JSESSIONID=(.*); /i)
170+
session = $1 if res && res.get_cookies =~ /JSESSIONID=(.*); /i
171171
res = send_request('/applications/upload.jsf', 'GET', session)
172172

173173
p = /<title>Deploy Enterprise Applications\/Modules/
@@ -180,7 +180,7 @@ def try_glassfish_login(version,user,pass)
180180
print_status("Trying credential GlassFish 3.x #{user}:'#{pass}'....")
181181
res = try_login(user,pass)
182182
if res and res.code == 302
183-
session = $1 if (res and res.headers['Set-Cookie'] =~ /JSESSIONID=(.*); /i)
183+
session = $1 if res && res.get_cookies =~ /JSESSIONID=(.*); /i
184184
res = send_request('/common/applications/uploadFrame.jsf', 'GET', session)
185185

186186
p = /<title>Deploy Applications or Modules/

modules/auxiliary/scanner/http/mediawiki_svg_fileaccess.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def get_first_session
6464
}
6565
})
6666

67-
if res and res.code == 200 and res.headers['Set-Cookie'] and res.headers['Set-Cookie'] =~ /([^\s]*session)=([a-z0-9]+)/
67+
if res && res.code == 200 && res.get_cookies =~ /([^\s]*session)=([a-z0-9]+)/
6868
return $1,$2
6969
else
7070
return nil
@@ -134,8 +134,8 @@ def authenticate
134134
'cookie' => session_cookie
135135
})
136136

137-
if res and res.code == 302 and res.headers['Set-Cookie'] =~ /UserID=/
138-
parse_auth_cookie(res.headers['Set-Cookie'])
137+
if res and res.code == 302 and res.get_cookies.include?('UserID=')
138+
parse_auth_cookie(res.get_cookies)
139139
return true
140140
else
141141
return false

modules/auxiliary/scanner/http/owa_login.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def try_user_pass(opts)
200200
return :abort
201201
end
202202

203-
if action.name != "OWA_2013" and not res.headers['set-cookie']
203+
if action.name != "OWA_2013" and res.get_cookies.empty?
204204
print_error("#{msg} Received invalid repsonse due to a missing cookie (possibly due to invalid version), aborting")
205205
return :abort
206206
end
@@ -233,8 +233,9 @@ def try_user_pass(opts)
233233
end
234234
else
235235
# these two lines are the authentication info
236-
sessionid = 'sessionid=' << res.headers['set-cookie'].split('sessionid=')[1].split('; ')[0]
237-
cadata = 'cadata=' << res.headers['set-cookie'].split('cadata=')[1].split('; ')[0]
236+
cookies = res.get_cookies
237+
sessionid = 'sessionid=' << cookies.split('sessionid=')[1].split('; ')[0]
238+
cadata = 'cadata=' << cookies.split('cadata=')[1].split('; ')[0]
238239
headers['Cookie'] = 'PBack=0; ' << sessionid << '; ' << cadata
239240
end
240241

modules/auxiliary/scanner/http/sentry_cdu_enum.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def do_login(user, pass)
8282
'authorization' => basic_auth(user,pass)
8383
})
8484

85-
if (res and res.headers['Set-Cookie'])
85+
if res and !res.get_cookies.empty?
8686
print_good("#{rhost}:#{rport} - SUCCESSFUL LOGIN - #{user.inspect}:#{pass.inspect}")
8787

8888
report_hash = {

modules/auxiliary/scanner/http/sevone_enum.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def is_app_sevone?
5656
'method' => 'GET'
5757
})
5858

59-
if (res and res.code.to_i == 200 and res.headers['Set-Cookie'].include?('SEVONE'))
59+
if (res and res.code.to_i == 200 and res.get_cookies.include?('SEVONE'))
6060
version_key = /Version: <strong>(.+)<\/strong>/
6161
version = res.body.scan(version_key).flatten
6262
print_good("#{rhost}:#{rport} - Application confirmed to be SevOne Network Performance Management System version #{version}")

modules/auxiliary/scanner/http/smt_ipmi_url_redirect_traversal.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def login
7575
}
7676
})
7777

78-
if res and res.code == 200 and res.body.to_s =~ /self.location="\.\.\/cgi\/url_redirect\.cgi/ and res.headers["Set-Cookie"].to_s =~ /(SID=[a-z]+)/
78+
if res and res.code == 200 and res.body.to_s =~ /self.location="\.\.\/cgi\/url_redirect\.cgi/ and res.get_cookies =~ /(SID=[a-z]+)/
7979
return $1
8080
else
8181
return nil

modules/auxiliary/scanner/http/splunk_web_login.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ def get_login_cookie
8282
session_id = ''
8383
cval = ''
8484

85-
if res and res.code == 200 and res.headers['Set-Cookie']
86-
res.headers['Set-Cookie'].split(';').each {|c|
85+
if res and res.code == 200 and !res.get_cookies.empty?
86+
res.get_cookies.split(';').each {|c|
8787
c.split(',').each {|v|
8888
if v.split('=')[0] =~ /cval/
8989
cval = v.split('=')[1]

modules/auxiliary/scanner/http/symantec_brightmail_logfile.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ def get_login_data
8686
last_login = '' #A hidden field in the login page
8787

8888
res = send_request_raw({'uri'=>'/brightmail/viewLogin.do'})
89-
if res and res.headers['Set-Cookie']
90-
sid = res.headers['Set-Cookie'].scan(/JSESSIONID=([a-zA-Z0-9]+)/).flatten[0] || ''
89+
if res and !res.get_cookies.empty?
90+
sid = res.get_cookies.scan(/JSESSIONID=([a-zA-Z0-9]+)/).flatten[0] || ''
9191
end
9292

9393
if res
@@ -147,4 +147,4 @@ def run_host(ip)
147147
download_file(sid, fname)
148148
end
149149

150-
end
150+
end

modules/auxiliary/scanner/http/tomcat_enum.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def do_login(user)
102102
'data' => post_data,
103103
}, 20)
104104

105-
if res and res.code == 200 and res.headers['Set-Cookie']
105+
if res and res.code == 200 and !res.get_cookies.empty?
106106
vprint_error("#{target_url} - Apache Tomcat #{user} not found ")
107107
elsif res and res.code == 200 and res.body =~ /invalid username/i
108108
vprint_error("#{target_url} - Apache Tomcat #{user} not found ")

0 commit comments

Comments
 (0)