GithubHelp home page GithubHelp logo

gutpuncher / 103-early-anti-adblock Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mechazawa/103-early-anti-adblock

0.0 0.0 0.0 648 KB

Detect adblockers without Javascript by abusing early hints

License: Other

TypeScript 97.31% Dockerfile 2.69%

103-early-anti-adblock's Introduction

103 Early Anti Adblock

Proof of concept that detects adblockers without Javascript by abusing 103 Early Hints

Running

The application can be run either through a Docker container or directly on your machine using Node.js.

Docker

Using Docker simplifies the setup and ensures consistency across different environments. To launch the application in a Docker container, execute the following command:

npm run docker

This command wraps the process of building the Docker image and running the container. It ensures that you don't need to manually set up the environment on your local machine.

Node

If you prefer running the application directly on your local environment, follow these steps:

Install the project dependencies using npm.

npm install

The application requires SSL certificates for HTTP2.

npm run certs

Start the application

npm run serve

How

The core idea behind this proof of concept is the use of 103 Early Hints response. By sending early hints prior to the actual response, the server can determine whether an adblocker is present based on the client's handling of these hints. If adblock is detected, the server can then serve an alternative page. This method is particularly effective because it doesn't depend on JavaScript, which can be disabled or manipulated by users.

            ┌───────┐                ┌──────┐                  ┌───────┐                ┌──────┐
            │Browser│                │Server│                  │Browser│                │Server│
            └───┬───┘                └──┬───┘                  └───┬───┘                └──┬───┘
               ┌┴┐   GET /index.html   ┌┴┐                        ┌┴┐   GET /index.html   ┌┴┐
               │ │ ───────────────────>│ │                        │ │ ───────────────────>│ │
               │ │                     │ │                        │ │                     │ │
               │ │   103 Early Hints   │ │                        │ │   103 Early Hints   │ │
               │ │ <───────────────────│ │                        │ │ <───────────────────│ │
  ╔═══════════╤╪═╪═════════════════════╪═╪═══╗       ╔═══════════╤╪═╪═════════════════════╪═╪═══╗
  ║ PREFETCH  ││ │                     │ │   ║       ║ PREFETCH  ││ │                     │ │   ║
  ╟───────────┘│ │ GET /adv.css?ABCDEF │┌┴┐  ║       ╟───────────┘│ │ GET /adv.css?ABCDEF │┌┴┐  ║
  ║            │ │ ────────────────────>│ │  ║       ║            │ │ ──────────────────X ││ │  ║
  ║            │ │                     ││ │  ║       ║            │ │                     ││ │  ║
  ║            │ │   204 No Content    ││ │──║───┐   ║            │ │                     ││ │──║───┐
  ║            │ │ <────────────────────│ │  ║   │   ║            │ │                     │└┬┘  ║   │
  ║            │ │                     │└┬┘  ║   │   ╚════════════╪═╪═════════════════════╪═╪═══╝   │
  ╚════════════╪═╪═════════════════════╪═╪═══╝   │                │ │                     │ │ ┌─────┴─────────────┐  
               │ │                     │ │ ┌─────┴─────────────┐  │ │                     │ │ │Prefetch timeout:  │
               │ │       200 OK        │ │ │Resource fetched:  │  │ │       200 OK        │ │ │Adblock detected   │
               │ │<────────────────────│ │ │No adblock detected│  │ │<────────────────────│ │ └───────────────────┘
               └┬┘                     └┬┘ └───────────────────┘  └┬┘                     └┬┘
            ┌───┴───┐                ┌──┴───┐                  ┌───┴───┐                ┌──┴───┐
            │Browser│                │Server│                  │Browser│                │Server│
            └───────┘                └──────┘                  └───────┘                └──────┘
                              

Support

At the moment this technique only works in Firefox. Chrome does not allow adblockers to interact with resources loaded using early hints, nor does it display resources loaded using early hints in the developer console. Additionally, Safari does not support preload early hints at all. Browsers that do not fully support early hints can be easily detected by adding a harmless dummy resource to preload that will not be blocked by adblockers.

Currently, this unintended side-effect may not be a significant problem due to these factors. However, as browsers continue to expand their support for early hints, it could become a reliable method for detecting adblockers.

I have previously demonstrated other techniques for detecting adblockers during the server response. Although those require a more involved implementation, they are more effective and less likely to produce false positives.

Further Reading

Some good resource for learning more about 103 Early Hints can be found here:

Why

For evil

103-early-anti-adblock's People

Contributors

mechazawa 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.