Skip to content

Commit 936c29e

Browse files
committed
Land rapid7#3387, some Set-Cookie msftidy warning fixes
2 parents 1914e0a + df97c66 commit 936c29e

21 files changed

+41
-44
lines changed

modules/exploits/multi/http/wikka_spam_exec.rb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ def get_cookie
9090

9191
# Get the cookie in this format:
9292
# 96522b217a86eca82f6d72ef88c4c7f4=pr5sfcofh5848vnc2sm912ean2; path=/wikka
93-
if res and res.headers['Set-Cookie']
94-
cookie = res.headers['Set-Cookie'].scan(/(\w+\=\w+); path\=.+$/).flatten[0]
93+
if res and !res.get_cookies.empty?
94+
cookie = res.get_cookies
9595
else
9696
fail_with(Failure::Unknown, "#{peer} - No cookie found, will not continue")
9797
end
@@ -141,9 +141,10 @@ def login(cookie)
141141
'vars_post' => login
142142
})
143143

144-
if res and res.headers['Set-Cookie'] =~ /user_name/
145-
user = res.headers['Set-Cookie'].scan(/(user_name\@\w+=\w+);/)[0] || ""
146-
pass = res.headers['Set-Cookie'].scan(/(pass\@\w+=\w+)/)[0] || ""
144+
if res and res.get_cookies =~ /user_name/
145+
c = res.get_cookies
146+
user = c.scan(/(user_name\@\w+=\w+);/)[0] || ""
147+
pass = c.scan(/(pass\@\w+=\w+)/)[0] || ""
147148
cookie_cred = "#{cookie}; #{user}; #{pass}"
148149
else
149150
cred = "#{datastore['USERNAME']}:#{datastore['PASSWORD']}"

modules/exploits/multi/http/zabbix_script_exec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def exploit
8888
fail_with("Login failed")
8989
end
9090

91-
sess = login.headers['Set-Cookie']
91+
sess = login.get_cookies
9292

9393
dash = send_request_cgi({
9494
'method' => 'GET',

modules/exploits/multi/php/php_unserialize_zval_cookie.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ def check
255255
end
256256

257257
# Detect the phpBB cookie name
258-
if (res.headers['Set-Cookie'] and res.headers['Set-Cookie'] =~ /(.*)_(sid|data)=/)
258+
if res.get_cookies =~ /(.*)_(sid|data)=/
259259
vprint_status("The server may require a cookie name of '#{$1}_data'")
260260
end
261261

modules/exploits/unix/http/lifesize_room.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ def exploit
5656
'method' => 'GET',
5757
}, 10)
5858

59-
if not (res and res.headers['set-cookie'])
59+
if res.nil? || res.get_cookies.empty?
6060
fail_with(Failure::NotFound, 'Could not obtain a Session ID')
6161
end
6262

63-
sessionid = 'PHPSESSID=' << res.headers['set-cookie'].split('PHPSESSID=')[1].split('; ')[0]
63+
sessionid = 'PHPSESSID=' << res.get_cookies.split('PHPSESSID=')[1].split('; ')[0]
6464

6565
headers = {
6666
'Cookie' => sessionid,

modules/exploits/unix/webapp/foswiki_maketext.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def do_login(username, password)
7575
}
7676
})
7777

78-
if not res or res.code != 302 or res.headers['Set-Cookie'] !~ /FOSWIKISID=([0-9a-f]*)/
78+
if not res or res.code != 302 or res.get_cookies !~ /FOSWIKISID=([0-9a-f]*)/
7979
vprint_status "#{res.code}\n#{res.body}"
8080
return nil
8181
end
@@ -102,15 +102,15 @@ def inject_code(session, code)
102102
vprint_good("validation_key found: #{validation_key}")
103103

104104
if session.empty?
105-
if res.headers['Set-Cookie'] =~ /FOSWIKISID=([0-9a-f]*)/
105+
if res.get_cookies =~ /FOSWIKISID=([0-9a-f]*)/
106106
session = $1
107107
else
108108
vprint_error("Error using anonymous access")
109109
return nil
110110
end
111111
end
112112

113-
if res.headers['Set-Cookie'] =~ /FOSWIKISTRIKEONE=([0-9a-f]*)/
113+
if res.get_cookies =~ /FOSWIKISTRIKEONE=([0-9a-f]*)/
114114
strike_one = $1
115115
else
116116
vprint_error("Error getting the FOSWIKISTRIKEONE value")

modules/exploits/unix/webapp/hastymail_exec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def login
103103
})
104104

105105
if res and res.code == 303
106-
@session_id = res["Set-Cookie"]
106+
@session_id = res.get_cookies
107107
print_good "#{peer} - Authentication successful"
108108
end
109109
end

modules/exploits/unix/webapp/invision_pboard_unserialize_exec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def cookie_prefix
7575
'method' => 'GET'
7676
})
7777

78-
if res and res.code == 200 and res.headers['Set-Cookie'] =~ /(.+)session/
78+
if res and res.code == 200 and res.get_cookies =~ /(.+)session/
7979
print_status("#{peer} - Cookie prefix #{$1} found")
8080
cookie_prefix = $1
8181
end

modules/exploits/unix/webapp/joomla_media_upload_exec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def exploit
177177
print_status("#{peer} - Checking Access to Media Component...")
178178
res = get_upload_form
179179

180-
if res and (res.code == 200 or res.code == 302) and res.headers['Set-Cookie'] and res.body =~ /You are not authorised to view this resource/
180+
if res and (res.code == 200 or res.code == 302) and !res.get_cookies.empty? and res.body =~ /You are not authorised to view this resource/
181181
print_status("#{peer} - Authentication required... Proceeding...")
182182

183183
if @username.empty? or @password.empty?
@@ -196,7 +196,7 @@ def exploit
196196
if not res or res.code != 303
197197
fail_with(Failure::NoAccess, "#{peer} - Unable to Authenticate")
198198
end
199-
elsif res and (res.code == 200 or res.code == 302) and res.headers['Set-Cookie'] and res.body =~ /<form action="(.*)" id="uploadForm"/
199+
elsif res and (res.code == 200 or res.code == 302) and !res.get_cookies.empty? and res.body =~ /<form action="(.*)" id="uploadForm"/
200200
print_status("#{peer} - Authentication isn't required.... Proceeding...")
201201
@cookies = res.get_cookies.sub(/;$/, "")
202202
else

modules/exploits/unix/webapp/nagios_graph_explorer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def get_login_data
7979
return '' if !res
8080

8181
nsp = res.body.scan(/<input type='hidden' name='nsp' value='(.+)'>/).flatten[0] || ''
82-
cookie = (res.headers['Set-Cookie'] || '').scan(/nagiosxi=(\w+); /).flatten[0] || ''
82+
cookie = res.get_cookies.scan(/nagiosxi=(\w+); /).flatten[0] || ''
8383
return nsp, cookie
8484
end
8585

modules/exploits/unix/webapp/openemr_sqli_privesc_upload.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def login(base, name, pass)
9494
}
9595
})
9696

97-
if res && res.code == 200 and res.headers['Set-Cookie'] =~ /OpenEMR=([a-zA-Z0-9]+)/
97+
if res && res.code == 200 and res.get_cookies =~ /OpenEMR=([a-zA-Z0-9]+)/
9898
session = $1
9999
print_status("#{rhost}:#{rport} - Login successful")
100100
print_status("#{rhost}:#{rport} - Session cookie is [ #{session} ]")

0 commit comments

Comments
 (0)