reek / anti-adblock-killer

Anti-Adblock Killer helps you keep your Ad-Blocker active, when you visit a website and it asks you to disable.
http://reek.github.io/anti-adblock-killer/
Other
6.01k stars 762 forks source link

Anti-bait as a second line of defense #1556

Open b3nsn0w opened 8 years ago

b3nsn0w commented 8 years ago

I've experimented a little with F*ckAdBlock and BlockAdblock (the strong one), found some ways around them not using their variables, but rather interrupting their detection process and stopping the adblocker from taking the bait. It's not a full solution, but it was tested against and defeated both of the two above, regardless how the sites customize it. I'm giving a full userscript below, but by taking (and maybe extending) only the bait variable and the contents of the loop this can be integrated into your project. Just loop it fast enough to evade the bait before they could detect you. (If I knew how this works in your code, this would be a pull request.)

// ==UserScript==
// @name         BaitKiller
// @version      0.1
// @description  FuckFuckAdBlock
// @author       Ben Snow
// @include http://*/*
// @include https://*/*
// @grant unsafeWindow
// @grant GM_addStyle
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_xmlhttpRequest
// @grant GM_registerMenuCommand
// @grant GM_deleteValue
// @grant GM_listValues
// @grant GM_getResourceText
// @grant GM_getResourceURL
// @grant GM_log
// @grant GM_openInTab
// @grant GM_setClipboard
// @grant GM_info
// @grant GM_getMetadata
// @run-at document-start
// ==/UserScript==

(function() {
    'use strict';

    var bait = '.pub_300x250, .pub_300x250m, .pub_728x90, .text-ad, .textAd, .text_ad, .text_ads, .text-ads, .text-ad-links, #ad-left, #adBannerWrap, #ad-frame, #ad-header, #ad-img, #ad-inner, #ad-label, #ad-lb, #ad-footer, #ad-container, #ad-container-1, #ad-container-2, #Ad300x145, #Ad300x250, #Ad728x90, #AdArea, #AdFrame1, #AdFrame2, #AdFrame3, #AdFrame4, #AdLayer1, #AdLayer2, #Ads_google_01, #Ads_google_02, #Ads_google_03, #Ads_google_04, #DivAd, #DivAd1, #DivAd2, #DivAd3, #DivAdA, #DivAdB, #DivAdC, #AdImage, #AdDiv, #AdBox160, #AdContainer, #glinkswrapper, #adTeaser, #banner_ad, #adBanner, #adbanner, #adAd, #bannerad, #ad_box, #ad_channel, #adserver, #bannerid, #adslot, #popupad, #adsense, #google_ad, #outbrain-paid, #sponsored_link' ;

    requestAnimationFrame( function killBait() {

        // Evade F*ckAdBlock's bait and BlockAdblock's first line of defense
        Array.prototype.slice.call( document.querySelectorAll( bait ) ).filter( function( element ) {
            var style = window.getComputedStyle( element, null ) ;
            return style.width == '1px' || style.height == '1px' || parseFloat( style.left ) <= -1000 || parseFloat( style.top ) <= -1000 ;
        }).map( function( element ) {
            element.setAttribute( 'style', element.style.cssText.split(';').filter( function( property ) {
                return property && !~['display','visibility','opacity'].indexOf( property.split(':')[0].trim() ) ;
            }).join(';') + '; display: initial !important; visibility: initial !important; opacity: 0.001 !important' ) ; // 0.001 is not 0, but it's below 0.004 which is the smallest visible amount
        });

        // Trigger a shortcut through BlockAdBlock's second line
        Array.prototype.slice.call( document.querySelectorAll( '[src="pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"]' ) ).map( function( element ) {
            element.parentNode.removeChild( element ) ; // Don't worry, it already ran, we just don't want anyone to see it did
        });
        if( !document.querySelector( 'ins.adsbygoogle' ) ) {
            var ins = document.createElement('ins') ;
            ins.classList.add( 'adsbygoogle' ) ;
            document.body.appendChild( ins ) ;
        }

        // Keep on looping
        requestAnimationFrame( killBait ) ;
    });
})();

I borrowed a few lines from your initial comments to test it out. Also, here you can find a slightly deobfuscated and shamelessly commented version of BlockAdblock's default code (just rename it to JS because GitHub didn't let me upload it). A bit deeper in their code than the .bab() function they have a few countermeasures, some so strong that if they start using it, userscripts may not be enough, we would need a different kind of adblocker for that. Or a service worker, hopefully, that arrives fast enough.

Also, if you know any other anti-adblock technologies, I'd be glad to trick my way through them.

reek commented 8 years ago

Hi, thank you, but your solution does not work, I also already have a solution to counter these two scripts, by cons you can try to find solution to these issues

b3nsn0w commented 8 years ago

That's strange, I never suggest untested code. In which conditions did it not work? Which adblocker did you test it with?

Also, this is not a replacement for your solution, but an additional layer of defense. For example, your fake FckAdBlock script works perfectly until the site starts renaming it, then you need to set it manually for each site. This solution, however, doesn't take out FckAdBlock by faking the library but instead tries to secure the bait and keep it intact, so even if F*ckAdBlock works, it will think the bait is unblocked. It's possible that my solution failed to defend the bait against your adblocker, that's why I'm interested in which one you used. I used Tampermonkey, uBlock, and Chrome 50.

The majority of the issues you linked have the tag "Anti-Adblock". Is that a specific plugin? Quite ironically all my search queries end up at your script (or at some random tutorials), so if it is a specific plugin, could you link the page where I could acquire it if I was a site admin who hated adblock and tried to block it?

reek commented 8 years ago

Which adblocker did you test it with ?

Win10, Firefox, AdBlock Plus, Greasemonkey.

Also, this is not a replacement for your solution, but an additional layer of defense

Yes, your solution may be useful for custom FAB

I used Tampermonkey, uBlock, and Chrome 50

Make sure your solution also works when the option uBO Parse and enforce cosmetic filters. is checked and unchecked. You must also test it with the following Ad-Blockers Adblock, Adblock Plus, Adguard AdBlocker

The majority of the issues you linked have the tag "Anti-Adblock". Is that a specific plugin?

For any request about new anti-adblock script, why do I call this label ?

could you link the page where I could acquire it if I was a site admin who hated adblock and tried to block it ?

It probably is but it also helps users find Aak

b3nsn0w commented 8 years ago

Just tested against FAB and BlockAdblock with Adblock, Adblock Plus, and Adguard AdBlocker on the harshest settings I could find, and uBO's parse and enforce cosmetic filters was already turned on. I couldn't reproduce the issue in Chrome, will try again tomorrow in Firefox.

reek commented 8 years ago

Tested on:

Result tests:


With firefox, I replace the document.body.appendChild( ins ) ; by document.documentElement.appendChild( ins ) ;, if it was not working