Skip to content

javascript-utilities/toxic-cookies

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Poison Cookies

Tool for poisoning browser cookies of currently loaded domain

Byte size of Poison Cookies Open Issues Open Pull Requests Latest commits Build Status



Requirements

Use npm to install development dependencies...

cd ~/git/hub/javascript-utilities/toxic-cookies

npm install

Note, npm is not necessarily required to make use of this project.


Quick Start

If using this project within GitHub Pages, or similar deployments, then it is encouraged the use of Git Submodules to track dependencies.

Bash Variables

_module_name='toxic-cookies'
_module_https_url="https://github.com/javascript-utilities/toxic-cookies.git"
_module_base_dir='assets/javascript/modules'
_module_path="${_module_base_dir}/${_module_name}"

Bash Submodule Commands

cd "<your-git-project-path>"

git checkout gh-pages
mkdir -vp "${_module_base_dir}"

git submodule add -b main\
                  --name "${_module_name}"\
                  "${_module_https_url}"\
                  "${_module_path}"

Your ReadMe File

Suggested additions for your ReadMe.md file so everyone has a good time with submodules

Clone with the following to avoid incomplete downloads


    git clone --recurse-submodules <url-for-your-project>


Update/upgrade submodules via


    git submodule update --init --merge --recursive

Commit and Push

git add .gitmodules
git add "${_module_path}"


## Add any changed files too


git commit -F- <<'EOF'
:heavy_plus_sign: Adds `javascript-utilities/toxic-cookies#1` submodule



**Additions**


- `.gitmodules`, tracks submodules AKA Git within Git _fanciness_

- `README.md`, updates installation and updating guidance

- `_modules_/toxic-cookies`, Tool for poisoning browser cookies of currently loaded domain
EOF


git push origin gh-pages

πŸŽ‰ Excellent πŸŽ‰ your project is now ready to begin unitizing code from this repository!


Usage

index.html

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>Toxic Cookies Tests</title>
    <script src="assets/javascript/toxic-cookies/toxic-cookies.js" differ></script>
    <script src="assets/javascript/index.js" differ></script>
  </head>

  <body>
    <div id="container__inputs">
      <input type="button"
             id="button__poison_cookies"
             for="button__print_cookies"
             value="Poison Cookies">

      <input type="button"
             id="button__print_cookies"
             for="container__cookie_output"
             value="Print Cookies">

      <input type="button"
             id="button__empty_cookies"
             for="button__print_cookies"
             value="Empty Cookies">

      <input type="button"
             id="button__refresh"
             value="Refresh">
    </div>

    <div id="container__outputs">
      <pre id="container__cookie_output"></pre>
    </div>
  </body>
</html>

assets/javascript/index.js

'use strict';


const toxic_cookies = new Toxic_Cookies({
  clean_keys: [ 'auth' ],
  max_bite_size: 4090,
  path: document.location.pathname,
  key_callback: () => { return Math.random(); },
  value_callback: () => { return Math.random(); },
});


window.addEventListener('load', () => {
  const button__poison_cookies = document.getElementById('button__poison_cookies');
  button__poison_cookies.addEventListener('click', (event) => {
    toxic_cookies.poisionAllCookies();

    const button__print_cookies__id = event.target.getAttribute('for');
    const button__print_cookies = document.getElementById(button__print_cookies__id);
    button__print_cookies.click();
  });

  const button__print_cookies = document.getElementById('button__print_cookies');
  button__print_cookies.addEventListener('click', (event) => {
    const objectified_cookies = toxic_cookies.constructor.objectifyCookies();
    const output_id = event.target.getAttribute('for');
    const container__cookie_output = document.getElementById(output_id);
    container__cookie_output.innerText = JSON.stringify(objectified_cookies, null, 2);
  });

  const button__empty_cookies = document.getElementById('button__empty_cookies');
  button__empty_cookies.addEventListener('click', (event) => {
    const experation = toxic_cookies.constructor.calculateCookieExpiration(-1);
    const cookie_metadata = `expires=${experation};path=${toxic_cookies.path}`;

    const objectified_cookies = toxic_cookies.constructor.objectifyCookies();
    Object.entries(objectified_cookies).forEach(([key, value]) => {
      if (!toxic_cookies.clean_keys.includes(key)) {
        window.document.cookie = `${key}=;${cookie_metadata}`;
      }
    });

    const button__print_cookies__id = event.target.getAttribute('for');
    const button__print_cookies = document.getElementById(button__print_cookies__id);
    button__print_cookies.click()
  });

  const button__refresh = document.getElementById('button__refresh');
  button__refresh.addEventListener('click', (_event) => {
    window.location.reload(false);
    return false;
  });

  button__print_cookies.click();
});

Monitor your server/service logs if available.


Notes

This project is intended for testing serves(es) and/or domain(s) that permit fuzzing tools; ie. check bug bounty rules for a given domain prior to utilizing this tool.

This repository may not be feature complete and/or fully functional, Pull Requests that add features or fix bugs are certainly welcomed.


Contributing

Options for contributing to toxic-cookies and javascript-utilities


Forking

Start making a Fork of this repository to an account that you have write permissions for.

cd ~/git/hub/javascript-utilities/toxic-cookies

git remote add fork [email protected]:<NAME>/toxic-cookies.git
  • Commit your changes and push to your fork, eg. to fix an issue...
cd ~/git/hub/javascript-utilities/toxic-cookies


git commit -F- <<'EOF'
:bug: Fixes #42 Issue


**Edits**


- `<SCRIPT-NAME>` script, fixes some bug reported in issue
EOF


git push fork main

Note, the -u option may be used to set fork as the default remote, eg. git push fork main however, this will also default the fork remote for pulling from too! Meaning that pulling updates from origin must be done explicitly, eg. git pull origin main

  • Then on GitHub submit a Pull Request through the Web-UI, the URL syntax is https://github.com/<NAME>/<REPO>/pull/new/<BRANCH>

Note; to decrease the chances of your Pull Request needing modifications before being accepted, please check the dot-github repository for detailed contributing guidelines.


Sponsor

Thanks for even considering it!

With sponsor__shields_io__liberapay you may sponsor javascript-utilities on a repeating basis.

Regardless of if you're able to financially support projects such as toxic-cookies that javascript-utilities maintains, please consider sharing projects that are useful with others, because one of the goals of maintaining Open Source repositories is to provide value to the community.


Attribution


License

Tool for poisoning browser cookies of currently loaded domain
Copyright (C) 2020 S0AndS0

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, version 3 of the License.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <https://www.gnu.org/licenses/>.

For further details review full length version of AGPL-3.0 License.