Skip to content

Commit c07f390

Browse files
committed
Add CookieExpiration option, add trailing slash to URI.
1 parent 05067b4 commit c07f390

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

lib/msf/core/exploit/remote/browser_exploit_server.rb

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ def initialize(info={})
7979
], Exploit::Remote::BrowserExploitServer)
8080

8181
register_advanced_options([
82-
OptString.new('CookieName', [false, "The name of the tracking cookie", DEFAULT_COOKIE_NAME])
82+
OptString.new('CookieName', [false, "The name of the tracking cookie", DEFAULT_COOKIE_NAME]),
83+
OptString.new('CookieExpiration', [false, "Cookie expiration in years (blank=expire on exit)"])
8384
], Exploit::Remote::BrowserExploitServer)
8485
end
8586

@@ -98,7 +99,7 @@ def sync(&block)
9899
# @return [String] URI to the exploit page
99100
#
100101
def get_module_resource
101-
"#{get_resource.chomp("/")}/#{@exploit_receiver_page}"
102+
"#{get_resource.chomp("/")}/#{@exploit_receiver_page}/"
102103
end
103104

104105
#
@@ -403,7 +404,7 @@ def get_detection_html(user_agent)
403404
</script>
404405
<noscript>
405406
<img style="visibility:hidden" src="#{get_resource.chomp("/")}/#{@noscript_receiver_page}/">
406-
<meta http-equiv="refresh" content="1; url=#{get_resource.chomp("/")}/#{@exploit_receiver_page}/">
407+
<meta http-equiv="refresh" content="1; url=#{get_module_resource}">
407408
</noscript>
408409
|
409410
end
@@ -414,8 +415,13 @@ def cookie_name
414415
end
415416

416417
def cookie_header(tag)
417-
expires = (DateTime.now + 365*20).to_time.strftime("%a, %d %b %Y 12:00:00 GMT")
418-
"#{cookie_name}=#{tag}; Expires=#{expires};"
418+
cookie = "#{cookie_name}=#{tag};"
419+
if datastore['CookieExpiration'].present?
420+
expires_date = (DateTime.now + 365*datastore['CookieExpiration'].to_i)
421+
expires_str = expires_date.to_time.strftime("%a, %d %b %Y 12:00:00 GMT")
422+
cookie << " Expires=#{expires};"
423+
end
424+
cookie
419425
end
420426

421427
#
@@ -431,7 +437,7 @@ def on_request_uri(cli, request)
431437
# This is the information gathering stage
432438
#
433439
if get_profile(retrieve_tag(cli, request))
434-
send_redirect(cli, "#{get_resource.chomp("/")}/#{@exploit_receiver_page}")
440+
send_redirect(cli, get_module_resource)
435441
return
436442
end
437443

0 commit comments

Comments
 (0)