Skip to content
This repository has been archived by the owner on Nov 25, 2023. It is now read-only.

Commit

Permalink
Merge pull request #179 from MSkjel/MSkjel
Browse files Browse the repository at this point in the history
Patched a bunch of Blockers. Added some easy debug messages
  • Loading branch information
chiehmin authored Mar 13, 2019
2 parents a6a6dd5 + 500d872 commit e64f61f
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public class Main implements IXposedHookZygoteInit,

public static Blocker[] blockers = {
/* Popular adnetwork */
new Ad2iction(), new Adbert(), new Adcolony(), new Adfurikun(), new AdMarvel(), new Admob(), new AdmobGms(), new Adtech(), new Amazon(), new Amobee(),
new Ad2iction(), new Adbert(), new Adcolony(), new Adfurikun(), new AdMarvel(), /*new Admob(),*/ new AdmobGms(), new Adtech(), new Amazon(), new Amobee(),
new Aotter(), new AppBrain(), new Applovin(), new Appnext(), new Avocarrot(), new Bonzai(), new Chartboost(), new Clickforce(), new Domob(), new Facebook(), new Freewheel(), new Flurry(),
new GmsDoubleClick(), new Hodo(), new ImpAct(), new Inmobi(), new Intowow(), new Ironsource(), new KuAd(), new mAdserve(), new Madvertise(), new MasAd(),
new MdotM(), new Millennial(), new Mobclix(), new MobFox(), new MoPub(), new Nend(), new Og(), new Onelouder(), new OpenX(), new SmartAdserver(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public static boolean blockAdFunction(final String packageName, final String ad,
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {

String debugMsg = String.format("Detect %s %s(Object) in %s", ad, adFunc, packageName);
String debugMsg = String.format("Detect %s %s(%s) in %s", ad, adFunc, parameter.toString(), packageName);
Util.log(packageName, debugMsg);
if (removeAd) {
Util.notifyRemoveAdView(null, packageName, 1);
Expand All @@ -128,7 +128,7 @@ public static boolean blockAdFunction(final String packageName, final String ad,
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {

String debugMsg = String.format("Detect %s %s(Object, Object) in %s", ad, adFunc, packageName);
String debugMsg = String.format("Detect %s %s(%s, %s) in %s", ad, adFunc, parameter1.toString(), parameter2.toString(), packageName);
Util.log(packageName, debugMsg);
if (removeAd) {
Util.notifyRemoveAdView(null, packageName, 1);
Expand All @@ -149,7 +149,7 @@ public static boolean blockAdFunction(final String packageName, final String ad,
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {

String debugMsg = String.format("Detect %s %s(Object, Object) in %s", ad, adFunc, packageName);
String debugMsg = String.format("Detect %s %s(%s, %s, %s) in %s", ad, adFunc, parameter1.toString(), parameter2.toString(), parameter3.toString(), packageName);
Util.log(packageName, debugMsg);
if (removeAd) {
Util.notifyRemoveAdView(null, packageName, 1);
Expand Down Expand Up @@ -195,7 +195,7 @@ public static boolean blockAdFunctionWithResult(final String packageName, final
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {

String debugMsg = String.format("Detect %s %s(Object) in %s", ad, adFunc, packageName);
String debugMsg = String.format("Detect %s %s(%s) in %s", ad, adFunc, parameter.toString(), packageName);
Util.log(packageName, debugMsg);
if (removeAd) {
Util.notifyRemoveAdView(null, packageName, 1);
Expand All @@ -218,7 +218,7 @@ public static boolean blockAdFunctionWithResult(final String packageName, final
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {

String debugMsg = String.format("Detect %s %s(Object, Object) in %s", ad, adFunc, packageName);
String debugMsg = String.format("Detect %s %s(%s, %s) in %s", ad, adFunc, parameter1.toString(), parameter2.toString(), packageName);
Util.log(packageName, debugMsg);
if (removeAd) {
Util.notifyRemoveAdView(null, packageName, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ public abstract class Blocker {
* @return True if currrent handling app using this adnetwork. False otherwise.
*/
abstract public boolean handleLoadPackage(final String packageName, XC_LoadPackage.LoadPackageParam lpparam, final boolean removeAd);

abstract public String getBanner();

abstract public String getBannerPrefix();

public String getName() {
return getClass().getSimpleName();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@
public class Adcolony extends Blocker
{
public static final String Adcolony_Storage = "com.adcolony.sdk.ab";
public static final String INTER_ADS = "com.adcolony.sdk.AdColonyInterstitial";

@Override
public boolean handleLoadPackage(String packageName, XC_LoadPackage.LoadPackageParam lpparam, boolean removeAd)
{
boolean result = false;

result |= ApiBlocking.blockAdFunctionWithResult(packageName, Adcolony_Storage, "a", String.class, 0.0d, lpparam, removeAd);

result |= ApiBlocking.blockAdFunctionWithResult(packageName, INTER_ADS, "isExpired", true, lpparam, removeAd);
result |= ApiBlocking.blockAdFunctionWithResult(packageName, INTER_ADS, "show", true, lpparam, removeAd);

return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.XposedHelpers.ClassNotFoundError;
import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam;

/**
* Is not used anymore.
*
* @deprecated Doesnt do anything anymore. All Ads are loaded from GMS.
*/
@Deprecated
public class Admob extends Blocker {

public static final String BANNER = "com.google.ads.AdView";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,17 @@ public class AdmobGms extends Blocker {

public boolean handleLoadPackage(final String packageName, LoadPackageParam lpparam, final boolean removeAd) {
boolean result = false;

result |= ApiBlocking.removeBanner(packageName, BANNER, "loadAd", lpparam, removeAd);

result |= ApiBlocking.removeBanner(packageName, SEARCH_BANNER, "loadAd", lpparam, removeAd);
result |= ApiBlocking.blockAdFunction(packageName, INTER_ADS, "loadAd", lpparam, removeAd);

result |= ApiBlocking.blockAdFunction(packageName, INTER_ADS, "loadAd", "com.google.android.gms.ads.AdRequest", lpparam, removeAd);
result |= ApiBlocking.blockAdFunction(packageName, INTER_ADS, "show", lpparam, removeAd);
result |= ApiBlocking.blockAdFunction(packageName, AD_LOADER, "loadAd", lpparam, removeAd);

result |= ApiBlocking.blockAdFunction(packageName, AD_LOADER, "loadAd", "com.google.android.gms.ads.AdRequest", lpparam, removeAd);
result |= ApiBlocking.blockAdFunction(packageName, AD_LOADER, "loadAds", "com.google.android.gms.ads.AdRequest", int.class, lpparam, removeAd);

return result;
}
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,20 @@ public class Amazon extends Blocker {

public static final String BANNER = "com.amazon.device.ads.AdLayout";
public static final String BANNER_PREFIX = "com.amazon.device.ads";

public static final String AD_REQUEST = "com.amazon.device.ads.DTBAdRequest";

public boolean handleLoadPackage(final String packageName, LoadPackageParam lpparam, final boolean removeAd) {
boolean result = false;

result |= ApiBlocking.removeBanner(packageName, BANNER, "setListener", lpparam, removeAd);
result |= ApiBlocking.removeBannerWithResult(packageName, BANNER, "loadAd", new Boolean(true), lpparam, removeAd);

return result;
result |= ApiBlocking.blockAdFunction(packageName, AD_REQUEST, "loadAd", "com.amazon.device.ads.DTBAdCallback", lpparam, removeAd);
result |= ApiBlocking.blockAdFunction(packageName, AD_REQUEST, "internalLoadAd", lpparam, removeAd);
result |= ApiBlocking.blockAdFunction(packageName, AD_REQUEST, "loadAdRequest", lpparam, removeAd);

return result;
}
@Override
public String getBannerPrefix() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import android.os.Bundle;
import android.view.View;

import java.util.EnumSet;

import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.XposedHelpers;
Expand All @@ -15,11 +17,11 @@
import static de.robv.android.xposed.XposedHelpers.findClass;

public class Facebook extends Blocker {
private static final String LOAD_AD = "loadAd";
public static final String BANNER = "com.facebook.ads.AdView";
public static final String BANNER_PREFIX = "com.facebook.ads";
public static final String INTER = "com.facebook.ads.InterstitialAd";
public static final String NATIVE_AD = "com.facebook.ads.NativeAd";
public static final String NATIVE_ADS_MGR = "com.facebook.ads.NativeAdsManager";
public static final String AUDIENCE_NETWORK = "com.facebook.ads.AudienceNetworkActivity";

@Override
Expand All @@ -33,13 +35,25 @@ public String getBanner() {
}

public boolean handleLoadPackage(final String packageName, XC_LoadPackage.LoadPackageParam lpparam, final boolean removeAd) {

boolean result = false;
result |= ApiBlocking.removeBanner(packageName, BANNER, LOAD_AD, lpparam, removeAd);

result |= ApiBlocking.removeBanner(packageName, BANNER, "loadAd", lpparam, removeAd);
result |= ApiBlocking.removeBanner(packageName, BANNER, "setAdListener", lpparam, removeAd);
result |= ApiBlocking.blockAdFunction(packageName, INTER, LOAD_AD, lpparam, removeAd);
result |= ApiBlocking.blockAdFunction(packageName, NATIVE_AD, LOAD_AD, lpparam, removeAd);

result |= ApiBlocking.blockAdFunction(packageName, INTER, "loadAd", lpparam, removeAd);
result |= ApiBlocking.blockAdFunction(packageName, INTER, "loadAd", EnumSet.class, lpparam, removeAd);
result |= ApiBlocking.blockAdFunction(packageName, INTER, "loadAdFromBid", String.class, lpparam, removeAd);
result |= ApiBlocking.blockAdFunction(packageName, INTER, "loadAdFromBid", EnumSet.class, String.class, lpparam, removeAd);

result |= ApiBlocking.blockAdFunction(packageName, NATIVE_AD, "loadAd", lpparam, removeAd);
result |= ApiBlocking.blockAdFunction(packageName, NATIVE_AD, "loadAd", EnumSet.class, lpparam, removeAd);
result |= ApiBlocking.blockAdFunction(packageName, NATIVE_AD, "loadAdFromBid", String.class, lpparam, removeAd);
result |= ApiBlocking.blockAdFunction(packageName, NATIVE_AD, "loadAdFromBid", EnumSet.class, String.class, lpparam, removeAd);

result |= ApiBlocking.blockAdFunction(packageName, NATIVE_ADS_MGR, "loadAds", EnumSet.class, lpparam, removeAd);

result |= customHandle(packageName, lpparam, removeAd);

return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public class GmsDoubleClick extends Blocker {
public static final String BANNER = "com.google.android.gms.ads.doubleclick.PublisherAdView";
public static final String BANNER_PREFIX = "com.google.android.gms.ads.doubleclick";

public static final String INTER_ADS = "com.google.android.gms.ads.doubleclick.PublisherInterstitialAd";

@Override
public String getBannerPrefix() {
return BANNER_PREFIX;
Expand All @@ -25,9 +27,16 @@ public String getBannerPrefix() {
public String getBanner() {
return BANNER;
}

public boolean handleLoadPackage(final String packageName, LoadPackageParam lpparam, final boolean removeAd) {
boolean result = false;
result |= ApiBlocking.removeBanner(packageName, BANNER, "loadAd", lpparam, removeAd);

//This wont do anything. The loadAd method takes an argument. Therefor it cannot be hooked with removeBanner
//result |= ApiBlocking.removeBanner(packageName, BANNER, "loadAd", lpparam, removeAd);

result |= ApiBlocking.blockAdFunction(packageName, BANNER, "loadAd", "com.google.android.gms.ads.doubleclick.PublisherAdRequest", lpparam, removeAd);
result |= ApiBlocking.blockAdFunction(packageName, INTER_ADS, "loadAd", "com.google.android.gms.ads.doubleclick.PublisherAdRequest", lpparam, removeAd);
result |= ApiBlocking.blockAdFunction(packageName, INTER_ADS, "show", lpparam, removeAd);

return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,20 @@
public class Vungle extends Blocker
{
public static final String VUNGLE_WARREN = "com.vungle.warren.Vungle";
public static final String VUNGLE_WARREN_STORAGE = "com.vungle.warren.Storage";
public static final String VUNGLE_PUBLISHER = "com.vungle.publisher.VunglePub";

@Override
public boolean handleLoadPackage(String packageName, XC_LoadPackage.LoadPackageParam lpparam, boolean removeAd)
{
boolean result = false;

result |= ApiBlocking.blockAdFunction(packageName, VUNGLE_WARREN, "canPlayAd", "com.vungle.warren.model.Advertisement", lpparam, removeAd);
result |= ApiBlocking.blockAdFunctionWithResult(packageName, VUNGLE_WARREN_STORAGE, "findValidAdvertisementForPlacement", String.class, null, lpparam, removeAd);
result |= ApiBlocking.blockAdFunction(packageName, VUNGLE_WARREN, "loadAd", String.class, "com.vungle.warren.LoadAdCallback", "com.vungle.warren.PublisherDirectDownload", lpparam, removeAd);
//result |= ApiBlocking.blockAdFunction(packageName, VUNGLE_WARREN, "canPlayAd", String.class, lpparam, removeAd);
//result |= ApiBlocking.blockAdFunction(packageName, VUNGLE_WARREN, "canPlayAd", "com.vungle.warren.model.Advertisement", lpparam, removeAd);
result |= ApiBlocking.blockAdFunction(packageName, VUNGLE_PUBLISHER, "loadAd", String.class, lpparam, removeAd);
result |= ApiBlocking.blockAdFunction(packageName, VUNGLE_PUBLISHER, "isAdPlayable", String.class, lpparam, removeAd);

return result;
}
Expand Down

0 comments on commit e64f61f

Please sign in to comment.