Files
metasploit-gs/api/Msf/Exploit/Remote/HTTP/HttpCookieJar.html
T

912 lines
29 KiB
HTML
Raw Normal View History

2026-05-08 17:08:43 +00:00
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
Class: Msf::Exploit::Remote::HTTP::HttpCookieJar
&mdash; Documentation by YARD 0.9.37
</title>
<link rel="stylesheet" href="../../../../css/style.css" type="text/css" />
<link rel="stylesheet" href="../../../../css/common.css" type="text/css" />
<script type="text/javascript">
pathId = "Msf::Exploit::Remote::HTTP::HttpCookieJar";
relpath = '../../../../';
</script>
<script type="text/javascript" charset="utf-8" src="../../../../js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="../../../../js/app.js"></script>
</head>
<body>
<div class="nav_wrap">
<iframe id="nav" src="../../../../class_list.html?1"></iframe>
<div id="resizer"></div>
</div>
<div id="main" tabindex="-1">
<div id="header">
<div id="menu">
<a href="../../../../_index.html">Index (H)</a> &raquo;
<span class='title'><span class='object_link'><a href="../../../../Msf.html" title="Msf (module)">Msf</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../../../Exploit.html" title="Msf::Exploit (class)">Exploit</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../../Remote.html" title="Msf::Exploit::Remote (class)">Remote</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../HTTP.html" title="Msf::Exploit::Remote::HTTP (module)">HTTP</a></span></span>
&raquo;
<span class="title">HttpCookieJar</span>
</div>
<div id="search">
<a class="full_list_link" id="class_list_link"
href="../../../../class_list.html">
<svg width="24" height="24">
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
</svg>
</a>
</div>
<div class="clear"></div>
</div>
<div id="content"><h1>Class: Msf::Exploit::Remote::HTTP::HttpCookieJar
</h1>
<div class="box_info">
<dl>
<dt>Inherits:</dt>
<dd>
<span class="inheritName">Object</span>
<ul class="fullTree">
<li>Object</li>
<li class="next">Msf::Exploit::Remote::HTTP::HttpCookieJar</li>
</ul>
<a href="#" class="inheritanceTree">show all</a>
</dd>
</dl>
<dl>
<dt>Defined in:</dt>
<dd>lib/msf/core/exploit/remote/http/http_cookie_jar.rb</dd>
</dl>
</div>
<h2>Overview</h2><div class="docstring">
<div class="discussion">
<p>Acts as a wrapper for the 3rd party CookieJar (http-cookie)</p>
</div>
</div>
<div class="tags">
</div>
<h2>
Instance Method Summary
<small><a href="#" class="summary_toggle">collapse</a></small>
</h2>
<ul class="summary">
<li class="public ">
<span class="summary_signature">
<a href="#add-instance_method" title="#add (instance method)">#<strong>add</strong>(cookie) &#x21d2; Object </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Adds <code>cookie</code> to the jar.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#cleanup-instance_method" title="#cleanup (instance method)">#<strong>cleanup</strong>(expire_all = false) &#x21d2; Object </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Will remove all expired cookies.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#clear-instance_method" title="#clear (instance method)">#<strong>clear</strong> &#x21d2; Object </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Will remove all cookies from the jar.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#cookies-instance_method" title="#cookies (instance method)">#<strong>cookies</strong> &#x21d2; Object </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Returns an unordered array of all cookies stored in the jar.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#delete-instance_method" title="#delete (instance method)">#<strong>delete</strong>(cookie) &#x21d2; Object </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Will remove any cookie from the jar that has the same <code>name</code>, <code>domain</code> and <code>path</code> as the passed <code>cookie</code>.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#empty%3F-instance_method" title="#empty? (instance method)">#<strong>empty?</strong> &#x21d2; Boolean </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Returns <code>true</code> if the jar contains no cookies, else <code>false</code>.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong> &#x21d2; HttpCookieJar </a>
</span>
<span class="note title constructor">constructor</span>
<span class="summary_desc"><div class='inline'>
<p>Returns a new instance of <code>HttpCookieJar</code>.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#initialize_copy-instance_method" title="#initialize_copy (instance method)">#<strong>initialize_copy</strong>(other) &#x21d2; Object </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Modules are replicated before running.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#parse-instance_method" title="#parse (instance method)">#<strong>parse</strong>(set_cookie_header, origin_url) &#x21d2; Object </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Parses a Set-Cookie header value <code>set_cookie_header</code> and returns an array of <code>::Msf::Exploit::Remote::HTTP::HttpCookie</code> objects.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#parse_and_merge-instance_method" title="#parse_and_merge (instance method)">#<strong>parse_and_merge</strong>(set_cookie_header, origin_url) &#x21d2; Object </a>
</span>
<span class="summary_desc"><div class='inline'>
<p>Same as <code>parse</code>, but each <code>::Msf::Exploit::Remote::HTTP::HttpCookie</code> is also added to the jar.</p>
</div></span>
</li>
</ul>
<div id="constructor_details" class="method_details_list">
<h2>Constructor Details</h2>
<div class="method_details first">
<h3 class="signature first" id="initialize-instance_method">
#<strong>initialize</strong> &#x21d2; <tt><span class='object_link'><a href="" title="Msf::Exploit::Remote::HTTP::HttpCookieJar (class)">HttpCookieJar</a></span></tt>
</h3><div class="docstring">
<div class="discussion">
<p>Returns a new instance of <code>HttpCookieJar</code>.</p>
</div>
</div>
<div class="tags">
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
17
18
19
20
21</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/exploit/remote/http/http_cookie_jar.rb', line 17</span>
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span>
<span class='ivar'>@cookie_jar</span> <span class='op'>=</span> <span class='op'>::</span><span class='const'>HTTP</span><span class='op'>::</span><span class='const'>CookieJar</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='lbrace'>{</span>
<span class='label'>store:</span> <span class='const'><span class='object_link'><a href="HashStoreWithoutAutomaticExpiration.html" title="Msf::Exploit::Remote::HTTP::HashStoreWithoutAutomaticExpiration (class)">HashStoreWithoutAutomaticExpiration</a></span></span>
<span class='rbrace'>}</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
</div>
<div id="instance_method_details" class="method_details_list">
<h2>Instance Method Details</h2>
<div class="method_details first">
<h3 class="signature first" id="add-instance_method">
#<strong>add</strong>(cookie) &#x21d2; <tt>Object</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Adds <code>cookie</code> to the jar.</p>
<p><code>cookie</code> must be an instance or subclass of <code>Msf::Exploit::Remote::HTTP::HttpCookie</code>, or a TypeError` will be raised.</p>
<p>Returns <code>self</code>.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Raises:</p>
<ul class="raise">
<li>
<span class='type'>(<tt>TypeError</tt>)</span>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
29
30
31
32
33
34</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/exploit/remote/http/http_cookie_jar.rb', line 29</span>
<span class='kw'>def</span> <span class='id identifier rubyid_add'>add</span><span class='lparen'>(</span><span class='id identifier rubyid_cookie'>cookie</span><span class='rparen'>)</span>
<span class='id identifier rubyid_raise'>raise</span> <span class='const'>TypeError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Passed cookie is of class &#39;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_cookie'>cookie</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='embexpr_end'>}</span><span class='tstring_content'>&#39; and not a subclass of &#39;</span><span class='embexpr_beg'>#{</span><span class='const'><span class='object_link'><a href="../../../../Msf.html" title="Msf (module)">Msf</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../../../Exploit.html" title="Msf::Exploit (class)">Exploit</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../../Remote.html" title="Msf::Exploit::Remote (class)">Remote</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../HTTP.html" title="Msf::Exploit::Remote::HTTP (module)">HTTP</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="HttpCookie.html" title="Msf::Exploit::Remote::HTTP::HttpCookie (class)">HttpCookie</a></span></span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>unless</span> <span class='id identifier rubyid_cookie'>cookie</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="../../../../Msf.html" title="Msf (module)">Msf</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../../../Exploit.html" title="Msf::Exploit (class)">Exploit</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../../Remote.html" title="Msf::Exploit::Remote (class)">Remote</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../HTTP.html" title="Msf::Exploit::Remote::HTTP (module)">HTTP</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="HttpCookie.html" title="Msf::Exploit::Remote::HTTP::HttpCookie (class)">HttpCookie</a></span></span><span class='rparen'>)</span>
<span class='ivar'>@cookie_jar</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span><span class='lparen'>(</span><span class='id identifier rubyid_cookie'>cookie</span><span class='rparen'>)</span>
<span class='kw'>self</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="cleanup-instance_method">
#<strong>cleanup</strong>(expire_all = false) &#x21d2; <tt>Object</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Will remove all expired cookies. If <code>expire_all</code> is set as true, all session cookies are removed as well.</p>
<p>Returns <code>self</code>.</p>
</div>
</div>
<div class="tags">
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
63
64
65
66</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/exploit/remote/http/http_cookie_jar.rb', line 63</span>
<span class='kw'>def</span> <span class='id identifier rubyid_cleanup'>cleanup</span><span class='lparen'>(</span><span class='id identifier rubyid_expire_all'>expire_all</span> <span class='op'>=</span> <span class='kw'>false</span><span class='rparen'>)</span>
<span class='ivar'>@cookie_jar</span><span class='period'>.</span><span class='id identifier rubyid_cleanup'>cleanup</span><span class='lparen'>(</span><span class='id identifier rubyid_expire_all'>expire_all</span><span class='rparen'>)</span>
<span class='kw'>self</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="clear-instance_method">
#<strong>clear</strong> &#x21d2; <tt>Object</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Will remove all cookies from the jar.</p>
<p>Returns <code>nil</code>.</p>
</div>
</div>
<div class="tags">
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
55
56
57
58</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/exploit/remote/http/http_cookie_jar.rb', line 55</span>
<span class='kw'>def</span> <span class='id identifier rubyid_clear'>clear</span>
<span class='ivar'>@cookie_jar</span><span class='period'>.</span><span class='id identifier rubyid_clear'>clear</span>
<span class='kw'>self</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="cookies-instance_method">
#<strong>cookies</strong> &#x21d2; <tt>Object</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Returns an unordered array of all cookies stored in the jar.</p>
</div>
</div>
<div class="tags">
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
48
49
50</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/exploit/remote/http/http_cookie_jar.rb', line 48</span>
<span class='kw'>def</span> <span class='id identifier rubyid_cookies'>cookies</span>
<span class='ivar'>@cookie_jar</span><span class='period'>.</span><span class='id identifier rubyid_cookies'>cookies</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="delete-instance_method">
#<strong>delete</strong>(cookie) &#x21d2; <tt>Object</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Will remove any cookie from the jar that has the same <code>name</code>, <code>domain</code> and <code>path</code> as the passed <code>cookie</code>.</p>
<p>Returns <code>self</code>.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Raises:</p>
<ul class="raise">
<li>
<span class='type'>(<tt>TypeError</tt>)</span>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
39
40
41
42
43
44
45</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/exploit/remote/http/http_cookie_jar.rb', line 39</span>
<span class='kw'>def</span> <span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_cookie'>cookie</span><span class='rparen'>)</span>
<span class='kw'>return</span> <span class='kw'>if</span> <span class='ivar'>@cookie_jar</span><span class='period'>.</span><span class='id identifier rubyid_cookies'>cookies</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
<span class='id identifier rubyid_raise'>raise</span> <span class='const'>TypeError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Passed cookie is of class &#39;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_cookie'>cookie</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='embexpr_end'>}</span><span class='tstring_content'>&#39; and not a subclass of &#39;</span><span class='embexpr_beg'>#{</span><span class='const'><span class='object_link'><a href="../../../../Msf.html" title="Msf (module)">Msf</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../../../Exploit.html" title="Msf::Exploit (class)">Exploit</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../../Remote.html" title="Msf::Exploit::Remote (class)">Remote</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../HTTP.html" title="Msf::Exploit::Remote::HTTP (module)">HTTP</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="HttpCookie.html" title="Msf::Exploit::Remote::HTTP::HttpCookie (class)">HttpCookie</a></span></span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>unless</span> <span class='id identifier rubyid_cookie'>cookie</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="../../../../Msf.html" title="Msf (module)">Msf</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../../../Exploit.html" title="Msf::Exploit (class)">Exploit</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../../Remote.html" title="Msf::Exploit::Remote (class)">Remote</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../HTTP.html" title="Msf::Exploit::Remote::HTTP (module)">HTTP</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="HttpCookie.html" title="Msf::Exploit::Remote::HTTP::HttpCookie (class)">HttpCookie</a></span></span><span class='rparen'>)</span>
<span class='ivar'>@cookie_jar</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_cookie'>cookie</span><span class='rparen'>)</span>
<span class='kw'>self</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="empty?-instance_method">
#<strong>empty?</strong> &#x21d2; <tt>Boolean</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Returns <code>true</code> if the jar contains no cookies, else <code>false</code>.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Boolean</tt>)</span>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
69
70
71</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/exploit/remote/http/http_cookie_jar.rb', line 69</span>
<span class='kw'>def</span> <span class='id identifier rubyid_empty?'>empty?</span>
<span class='ivar'>@cookie_jar</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="initialize_copy-instance_method">
#<strong>initialize_copy</strong>(other) &#x21d2; <tt>Object</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Modules are replicated before running. This method ensures that the cookie jar from one run, will not impact subsequent runs.</p>
</div>
</div>
<div class="tags">
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
104
105
106
107</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/exploit/remote/http/http_cookie_jar.rb', line 104</span>
<span class='kw'>def</span> <span class='id identifier rubyid_initialize_copy'>initialize_copy</span><span class='lparen'>(</span><span class='id identifier rubyid_other'>other</span><span class='rparen'>)</span>
<span class='kw'>super</span>
<span class='ivar'>@cookie_jar</span> <span class='op'>=</span> <span class='id identifier rubyid_other'>other</span><span class='period'>.</span><span class='id identifier rubyid_instance_variable_get'>instance_variable_get</span><span class='lparen'>(</span><span class='symbol'>:@cookie_jar</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_clone'>clone</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="parse-instance_method">
#<strong>parse</strong>(set_cookie_header, origin_url) &#x21d2; <tt>Object</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Parses a Set-Cookie header value <code>set_cookie_header</code> and returns an array of <code>::Msf::Exploit::Remote::HTTP::HttpCookie</code> objects. Parts (separated by commas) that are malformed or considered unacceptable are silently ignored.</p>
</div>
</div>
<div class="tags">
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/exploit/remote/http/http_cookie_jar.rb', line 76</span>
<span class='kw'>def</span> <span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='id identifier rubyid_set_cookie_header'>set_cookie_header</span><span class='comma'>,</span> <span class='id identifier rubyid_origin_url'>origin_url</span><span class='rparen'>)</span>
<span class='id identifier rubyid_cookies'>cookies</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
<span class='op'>::</span><span class='const'>HTTP</span><span class='op'>::</span><span class='const'>Cookie</span><span class='op'>::</span><span class='const'>Scanner</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_set_cookie_header'>set_cookie_header</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_scan_set_cookie'>scan_set_cookie</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='comma'>,</span> <span class='id identifier rubyid_attrs'>attrs</span><span class='op'>|</span>
<span class='kw'>if</span> <span class='id identifier rubyid_name'>name</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>||</span> <span class='id identifier rubyid_name'>name</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
<span class='kw'>next</span>
<span class='kw'>end</span>
<span class='kw'>if</span> <span class='id identifier rubyid_attrs'>attrs</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_attrs'>attrs</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Hash</span><span class='rparen'>)</span>
<span class='id identifier rubyid_attrs'>attrs</span> <span class='op'>=</span> <span class='id identifier rubyid_attrs'>attrs</span><span class='period'>.</span><span class='id identifier rubyid_transform_keys'>transform_keys</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:to_sym</span><span class='rparen'>)</span>
<span class='id identifier rubyid_attrs'>attrs</span><span class='lbracket'>[</span><span class='symbol'>:origin</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_origin_url'>origin_url</span>
<span class='id identifier rubyid_cookies'>cookies</span> <span class='op'>&lt;&lt;</span> <span class='const'><span class='object_link'><a href="HttpCookie.html" title="Msf::Exploit::Remote::HTTP::HttpCookie (class)">HttpCookie</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="HttpCookie.html#initialize-instance_method" title="Msf::Exploit::Remote::HTTP::HttpCookie#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_attrs'>attrs</span><span class='rparen'>)</span>
<span class='kw'>else</span>
<span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Cookie header could not be parsed by &#39;scan_set_cookie&#39; successfully.</span><span class='tstring_end'>&quot;</span></span>
<span class='kw'>end</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_cookies'>cookies</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="parse_and_merge-instance_method">
#<strong>parse_and_merge</strong>(set_cookie_header, origin_url) &#x21d2; <tt>Object</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Same as <code>parse</code>, but each <code>::Msf::Exploit::Remote::HTTP::HttpCookie</code> is also added to the jar.</p>
</div>
</div>
<div class="tags">
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
96
97
98
99
100</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/exploit/remote/http/http_cookie_jar.rb', line 96</span>
<span class='kw'>def</span> <span class='id identifier rubyid_parse_and_merge'>parse_and_merge</span><span class='lparen'>(</span><span class='id identifier rubyid_set_cookie_header'>set_cookie_header</span><span class='comma'>,</span> <span class='id identifier rubyid_origin_url'>origin_url</span><span class='rparen'>)</span>
<span class='id identifier rubyid_cookies'>cookies</span> <span class='op'>=</span> <span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='id identifier rubyid_set_cookie_header'>set_cookie_header</span><span class='comma'>,</span> <span class='id identifier rubyid_origin_url'>origin_url</span><span class='rparen'>)</span>
<span class='id identifier rubyid_cookies'>cookies</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_c'>c</span><span class='op'>|</span> <span class='id identifier rubyid_add'>add</span><span class='lparen'>(</span><span class='id identifier rubyid_c'>c</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
<span class='id identifier rubyid_cookies'>cookies</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
</div>
</div>
<div id="footer">
Generated on Fri May 8 17:03:45 2026 by
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.37 (ruby-3.1.5).
</div>
</div>
</body>
</html>