173 lines
5.7 KiB
HTML
173 lines
5.7 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>JSDoc: Source: browser/cookie.js</title>
|
|
|
|
<script src="scripts/prettify/prettify.js"> </script>
|
|
<script src="scripts/prettify/lang-css.js"> </script>
|
|
<!--[if lt IE 9]>
|
|
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
|
<![endif]-->
|
|
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
|
|
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div id="main">
|
|
|
|
<h1 class="page-title">Source: browser/cookie.js</h1>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<section>
|
|
<article>
|
|
<pre class="prettyprint source linenums"><code>//
|
|
// Copyright (c) 2006-2021 Wade Alcorn - wade@bindshell.net
|
|
// Browser Exploitation Framework (BeEF) - http://beefproject.com
|
|
// See the file 'doc/COPYING' for copying permission
|
|
//
|
|
|
|
/**
|
|
* Provides fuctions for working with cookies.
|
|
* Several functions adopted from http://techpatterns.com/downloads/javascript_cookies.php
|
|
* Original author unknown.
|
|
* @namespace beef.browser.cookie
|
|
*/
|
|
beef.browser.cookie = {
|
|
|
|
/** @memberof beef.browser.cookie */
|
|
setCookie: function (name, value, expires, path, domain, secure)
|
|
{
|
|
|
|
var today = new Date();
|
|
today.setTime( today.getTime() );
|
|
|
|
if ( expires )
|
|
{
|
|
expires = expires * 1000 * 60 * 60 * 24;
|
|
}
|
|
var expires_date = new Date( today.getTime() + (expires) );
|
|
|
|
document.cookie = name + "=" +escape( value ) +
|
|
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
|
|
( ( path ) ? ";path=" + path : "" ) +
|
|
( ( domain ) ? ";domain=" + domain : "" ) +
|
|
( ( secure ) ? ";secure" : "" );
|
|
},
|
|
/** @memberof beef.browser.cookie */
|
|
getCookie: function(name)
|
|
{
|
|
var a_all_cookies = document.cookie.split( ';' );
|
|
var a_temp_cookie = '';
|
|
var cookie_name = '';
|
|
var cookie_value = '';
|
|
var b_cookie_found = false;
|
|
|
|
for ( i = 0; i < a_all_cookies.length; i++ )
|
|
{
|
|
a_temp_cookie = a_all_cookies[i].split( '=' );
|
|
cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
|
|
if ( cookie_name == name )
|
|
{
|
|
b_cookie_found = true;
|
|
if ( a_temp_cookie.length > 1 )
|
|
{
|
|
cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
|
|
}
|
|
return cookie_value;
|
|
break;
|
|
}
|
|
a_temp_cookie = null;
|
|
cookie_name = '';
|
|
}
|
|
if ( !b_cookie_found )
|
|
{
|
|
return null;
|
|
}
|
|
},
|
|
/** @memberof beef.browser.cookie */
|
|
deleteCookie: function (name, path, domain)
|
|
{
|
|
if ( this.getCookie(name) ) document.cookie = name + "=" +
|
|
( ( path ) ? ";path=" + path : "") +
|
|
( ( domain ) ? ";domain=" + domain : "" ) +
|
|
";expires=Thu, 01-Jan-1970 00:00:01 GMT";
|
|
},
|
|
|
|
/** @memberof beef.browser.cookie */
|
|
veganLol: function (){
|
|
var to_hell= '';
|
|
var min = 17;
|
|
var max = 25;
|
|
var lol_length = Math.floor(Math.random() * (max - min + 1)) + min;
|
|
|
|
var grunt = function(){
|
|
var moo = Math.floor(Math.random() * 62);
|
|
var char = '';
|
|
if(moo < 36){
|
|
char = String.fromCharCode(moo + 55);
|
|
}else{
|
|
char = String.fromCharCode(moo + 61);
|
|
}
|
|
if(char != ';' && char != '='){
|
|
return char;
|
|
}else{
|
|
return 'x';
|
|
}
|
|
};
|
|
|
|
while(to_hell.length < lol_length){
|
|
to_hell += grunt();
|
|
}
|
|
return to_hell;
|
|
},
|
|
/** @memberof beef.browser.cookie */
|
|
hasSessionCookies: function (name){
|
|
this.setCookie( name, beef.browser.cookie.veganLol(), '', '/', '', '' );
|
|
|
|
cookiesEnabled = (this.getCookie(name) == null)? false:true;
|
|
this.deleteCookie(name, '/', '');
|
|
return cookiesEnabled;
|
|
|
|
},
|
|
/** @memberof beef.browser.cookie */
|
|
hasPersistentCookies: function (name){
|
|
this.setCookie( name, beef.browser.cookie.veganLol(), 1, '/', '', '' );
|
|
|
|
cookiesEnabled = (this.getCookie(name) == null)? false:true;
|
|
this.deleteCookie(name, '/', '');
|
|
return cookiesEnabled;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
beef.regCmp('beef.browser.cookie');</code></pre>
|
|
</article>
|
|
</section>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<nav>
|
|
<h2><a href="index.html">Home</a></h2><h3>Namespaces</h3><ul><li><a href="beef.are.html">are</a></li><li><a href="beef.browser.html">browser</a></li><li><a href="beef.browser.cookie.html">cookie</a></li><li><a href="beef.browser.popup.html">popup</a></li><li><a href="beef.dom.html">dom</a></li><li><a href="beef.encode.base64.html">base64</a></li><li><a href="beef.encode.json.html">json</a></li><li><a href="beef.geolocation.html">geolocation</a></li><li><a href="beef.hardware.html">hardware</a></li><li><a href="beef.init.html">init</a></li><li><a href="beef.logger.html">logger</a></li><li><a href="beef.mitb.html">mitb</a></li><li><a href="beef.net.html">net</a></li><li><a href="beef.net.connection.html">connection</a></li><li><a href="beef.net.cors.html">cors</a></li><li><a href="beef.net.dns.html">dns</a></li><li><a href="beef.net.local.html">local</a></li><li><a href="beef.net.portscanner.html">portscanner</a></li><li><a href="beef.net.requester.html">requester</a></li><li><a href="beef.net.xssrays.html">xssrays</a></li><li><a href="beef.os.html">os</a></li><li><a href="beef.session.html">session</a></li><li><a href="beef.timeout.html">timeout</a></li><li><a href="beef.updater.html">updater</a></li><li><a href="beef.webrtc.html">webrtc</a></li><li><a href="beef.websocket.html">websocket</a></li><li><a href="BeefJS.html">BeefJS</a></li><li><a href="browser_jools.html">browser_jools</a></li><li><a href="platform.html">platform</a></li></ul>
|
|
</nav>
|
|
|
|
<br class="clear">
|
|
|
|
<footer>
|
|
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.3</a> on Thu Jan 02 2020 16:29:11 GMT+1000 (Australian Eastern Standard Time)
|
|
</footer>
|
|
|
|
<script> prettyPrint(); </script>
|
|
<script src="scripts/linenumber.js"> </script>
|
|
</body>
|
|
</html>
|