Skip to content

Commit 6b154b3

Browse files
committed
Land rapid7#3354, a handful of Set-Cookie fixes
2 parents fb8fb11 + 3f3283b commit 6b154b3

15 files changed

+33
-33
lines changed

modules/auxiliary/admin/2wire/xslt_password_reset.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ def run
130130
}, 25)
131131

132132
if res and res.code == 200
133-
if (res.headers['Set-Cookie'] and res.headers['Set-Cookie'].match(/(.*); path=\//))
133+
cookies = res.get_cookies
134+
if cookies && cookies.match(/(.*); path=\//)
134135
cookie= $1
135136
print_status("Got cookie #{cookie}. Password reset was successful!\n")
136137
end

modules/auxiliary/admin/http/axigen_file_access.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def login
167167

168168
if res and res.code == 303 and res.headers['Location'] =~ /_h=([a-f0-9]*)/
169169
@token = $1
170-
if res.headers['Set-Cookie'] =~ /_hadmin=([a-f0-9]*)/
170+
if res.get_cookies =~ /_hadmin=([a-f0-9]*)/
171171
@session = $1
172172
return true
173173
end

modules/auxiliary/admin/http/cfme_manageiq_evm_pass_reset.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def run
113113
print_error($1)
114114
return
115115
else
116-
session = $1 if res.headers['Set-Cookie'] =~ /_vmdb_session=(\h*)/
116+
session = $1 if res.get_cookies =~ /_vmdb_session=(\h*)/
117117

118118
if session.nil?
119119
print_error('Failed to retrieve the current session id')

modules/auxiliary/admin/http/foreman_openstack_satellite_priv_esc.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def run
6767
print_error('Authentication failed')
6868
return
6969
else
70-
session = $1 if res.headers['Set-Cookie'] =~ /_session_id=([0-9a-f]*)/
70+
session = $1 if res.get_cookies =~ /_session_id=([0-9a-f]*)/
7171

7272
if session.nil?
7373
print_error('Failed to retrieve the current session id')

modules/auxiliary/admin/http/mutiny_frontend_read_delete.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def login
139139
'method' => 'GET'
140140
})
141141

142-
if res and res.code == 200 and res.headers['Set-Cookie'] =~ /JSESSIONID=(.*);/
142+
if res and res.code == 200 and res.get_cookies =~ /JSESSIONID=(.*);/
143143
first_session = $1
144144
end
145145

@@ -165,7 +165,7 @@ def login
165165
'cookie' => "JSESSIONID=#{first_session}"
166166
})
167167

168-
if res and res.code == 200 and res.headers['Set-Cookie'] =~ /JSESSIONID=(.*);/
168+
if res and res.code == 200 and res.get_cookies =~ /JSESSIONID=(.*);/
169169
@session = $1
170170
return true
171171
end

modules/auxiliary/admin/http/tomcat_administration.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ def run_host(ip)
7373
'uri' => '/admin/',
7474
}, 25)
7575

76-
if (res and res.code == 200)
76+
if res && res.code == 200
7777

78-
if (res.headers['Set-Cookie'] and res.headers['Set-Cookie'].match(/JSESSIONID=(.*);(.*)/i))
78+
if res.get_cookies.match(/JSESSIONID=(.*);(.*)/i)
7979

8080
jsessionid = $1
8181

modules/auxiliary/admin/oracle/osb_execqr2.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,15 @@ def run
4949
'method' => 'POST',
5050
}, 5)
5151

52-
if (res and res.headers['Set-Cookie'] and res.headers['Set-Cookie'].match(/PHPSESSID=(.*);(.*)/i))
53-
54-
sessionid = res.headers['Set-Cookie'].split(';')[0]
52+
if res && res.get_cookies.match(/PHPSESSID=(.*);(.*)/i)
5553

5654
print_status("Sending command: #{datastore['CMD']}...")
5755

5856
send_request_cgi(
5957
{
6058
'uri' => '/property_box.php',
6159
'data' => 'type=Sections&vollist=75' + Rex::Text.uri_encode("&" + cmd),
62-
'cookie' => sessionid,
60+
'cookie' => res.get_cookies,
6361
'method' => 'POST',
6462
}, 5)
6563

modules/auxiliary/admin/oracle/osb_execqr3.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,15 @@ def run
4646
'method' => 'POST',
4747
}, 5)
4848

49-
if (res and res.headers['Set-Cookie'] and res.headers['Set-Cookie'].match(/PHPSESSID=(.*);(.*)/i))
50-
51-
sessionid = res.headers['Set-Cookie'].split(';')[0]
49+
if res && res.get_cookies.match(/PHPSESSID=(.*);(.*)/i)
5250

5351
print_status("Sending command: #{datastore['CMD']}...")
5452

5553
send_request_cgi(
5654
{
5755
'uri' => '/property_box.php',
5856
'data' => 'type=Job&jlist=' + Rex::Text.uri_encode('&' + cmd),
59-
'cookie' => sessionid,
57+
'cookie' => res.get_cookies,
6058
'method' => 'POST',
6159
}, 5)
6260

modules/auxiliary/admin/webmin/edit_html_fileaccess.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ def run
6868
'data' => data
6969
}, 25)
7070

71-
if res and res.code == 302 and res.headers['Set-Cookie'] =~ /sid/
72-
session = res.headers['Set-Cookie'].scan(/sid\=(\w+)\;*/).flatten[0] || ''
71+
if res and res.code == 302 and res.get_cookies =~ /sid/
72+
session = res.get_cookies.scan(/sid\=(\w+)\;*/).flatten[0] || ''
7373
if session and not session.empty?
7474
print_good "#{peer} - Authentication successful"
7575
else

modules/auxiliary/fuzzers/http/http_form_field.rb

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -455,21 +455,23 @@ def get_form_data(body)
455455
formidx = formidx + 1
456456
formcnt += 1
457457
end
458+
458459
if forms.size > 0
459460
print_status(" Forms : ")
460461
end
462+
461463
forms.each do | thisform |
462464
print_status(" - Name : #{thisform[:name]}, ID : #{thisform[:id]}, Action : #{thisform[:action]}, Method : #{thisform[:method]}")
463465
end
466+
464467
return forms
465468
end
466-
def extract_cookie(body)
467-
return body["Set-Cookie"]
468-
end
469+
469470
def set_cookie(cookie)
470471
@get_data_headers["Cookie"]=cookie
471472
@send_data[:headers]["Cookie"]=cookie
472473
end
474+
473475
def run
474476
init_fuzzdata()
475477
init_vars()
@@ -487,10 +489,11 @@ def run
487489
print_error("No response")
488490
return
489491
end
492+
490493
if datastore['HANDLECOOKIES']
491-
cookie = extract_cookie(response.headers)
494+
cookie = response.get_cookies
492495
set_cookie(cookie)
493-
print_status("Set cookie:#{cookie}")
496+
print_status("Set cookie: #{cookie}")
494497
print_status("Grabbing webpage #{datastore['URL']} from #{datastore['RHOST']} using cookies")
495498

496499
response = send_request_raw(

0 commit comments

Comments
 (0)