Git Product home page Git Product logo

sink-logger's Introduction

sink-logger

Transparently log all data passed into known JavaScript sinks - Sink Logger extension for Burp.

Description

Sink Logger is a Burp Suite Extension that allows to transparently monitor various JavaScript sinks. All data passed into the defined sinks is logged into the browser's console. This is done by injecting a custom Proxy initialization script into chosen HTTP responses and "proxifying" all sinks.

Logs

Technical details

The extension intercepts responses and does 2 major things:

  • In case the response is HTML or JavaScript it injects a script initializing a custom Proxy.
var QF9iYXlvdG9w = QF9iYXlvdG9w || new Proxy({}, {
    set: function(target, key, value, receiver) {
        if (value != undefined && value !== "") {
            if ((value + "").startsWith("[object")) {
                try {
                    var svalue = JSON.stringify(value);
                } catch(error) {}
            }
            console.warn(`Sink log (${key}): ${svalue !== undefined ? svalue : value}`);
        }
        return Reflect.set(target, key, value, receiver);
    }
});
  • It "proxifies" all sinks. Currently 3 different sink types are supported: .innerHTML, eval() and document.write().
self.sinkPatterns = {
    # pattern: replacement passed into re.sub()
    r'\.innerHTML=': '.innerHTML=QF9iYXlvdG9w.innerHTML=',
    r'eval\(([^)])': r'eval(QF9iYXlvdG9w.eval=\1',
    r'document\.write\(([^)])': r'document.write(QF9iYXlvdG9w.write=\1'
}

Note: You can easily add custom sinks, or any other assignment / method call you want to proxify, by extending this dictionary. No other code changes are needed.

"Proxifying" a sink means to edit existing JavaScript so that every sink is preceded by an assignment to the proxy:

x.innerHTML=x.trim(); // becomes x.innerHTML=QF9iYXlvdG9w.innerHTML=x.trim();
document.write("string"); // becomes document.write(QF9iYXlvdG9w.write="string");

No sematic changes, no syntax errors (please report an issue if you find out otherwise).

Remarks

  • During the process CSP headers (and the <meta> tag) as well as SRI checks are stripped. This puts you at risk when surfing the web.
  • Websites may break. The aim is to be completely transparent, in some cases, however, the modifications may result in invalid JavaScript syntax or otherwise break web-apps. Please consider reporting an issue if you encounter such behavior.

sink-logger's People

Contributors

avano avatar bayotop avatar karelorigin avatar

Watchers

 avatar

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.