去除app广告

首先说几种去广告的方法

1. 反编译apk软件,直接修改显示广告的部分,然后保存重新编译下

2. Java hook,就如金山毒霸,lbe安全大师之类的,我也在csdn的博客上看过大牛分析

3. 修改host文件,更改广告域名指向的指向,指向为本地

先来张软件截图,软件名称是功夫勇士,无意中看到同学在玩,还有个李小龙的头像,就去豌豆荚上下载了个,很旧的游戏但操作感不错,好像是从ios上移植过来的,放张开始界面,左下角明显的广告,
image
有点熟悉,好像是谷歌提供之类的,顺便说几个逆向工具,apktool,dextojar,JD-JUI,IDA Pro如果还不了解自行脑补吧

载入Apktool之后查看清单文件果然有一条配置Activity的语句

[代码]java代码:

尝试把这条语句去掉之后广告就没有了如图
image
如果这样就结束了,托马斯和群里的他们肯定会鄙视我的,所以我继续用dextojar把dex文件转成jar文件再弄到JD-JUI中看看源码,明显看得出
image
谷歌广告接口的细节

java代码:当然还是主要来看launchAdActivity这个类吧,内容太多放点关键吧
java代码:

1
public static void launchAdActivity(d paramd, e parame) { Activity localActivity; synchronized (a) { if (c == null) c = paramd; while (c == paramd) { localActivity = paramd.e(); if (localActivity != null) break; com.google.ads.util.a.e("activity was null while launching an AdActivity."); return; } com.google.ads.util.a.b("Tried to launch a new AdActivity with a different AdManager."); return; } Intent localIntent = new Intent(localActivity.getApplicationContext(), AdActivity.class); localIntent.putExtra("com.google.ads.AdOpener", parame.a()); try { com.google.ads.util.a.a("Launching AdActivity."); localActivity.startActivity(localIntent); return; } catch (ActivityNotFoundException localActivityNotFoundException) { com.google.ads.util.a.a(localActivityNotFoundException.getMessage(), localActivityNotFoundException); } } public g getOpeningAdWebView() { if (this.i != null) return this.i.f; synchronized (a) { if (c == null) { com.google.ads.util.a.e("currentAdManager was null while trying to get the opening AdWebView."); return null; } g localg = c.i(); if (localg != this.f) return localg; return null; } } public VideoView getVideoView() { return this.k; } public void onClick(View paramView) { finish(); } public void onCompletion(MediaPlayer paramMediaPlayer) { com.google.ads.util.a.d("Video finished playing."); if (this.k != null) this.k.setVisibility(8); this.f.loadUrl("javascript:AFMA_ReceiveMessage('onVideoEvent', {'event': 'finish'});"); } public void onCreate(Bundle paramBundle) { super.onCreate(paramBundle); d locald; Bundle localBundle; synchronized (a) { if (c != null) { locald = c; if (d == null) d = this; if ((this.i == null) &amp;&amp; (e != null)) this.i = e; e = this; this.h = null; this.j = false; this.k = null; localBundle = getIntent().getBundleExtra("com.google.ads.AdOpener"); if (localBundle == null) a("Could not get the Bundle used to create AdActivity."); } else { a("Could not get currentAdManager."); return; } } e locale = new e(localBundle); String str1 = locale.b(); HashMap localHashMap = locale.c(); if (this == d) locald.s(); if (str1.equals("intent")) { this.f = null; this.g = SystemClock.elapsedRealtime(); this.j = true; if (localHashMap == null) { a("Could not get the paramMap in launchIntent()"); return; } String str6 = (String)localHashMap.get("u"); if (str6 == null) { a("Could not get the URL parameter in launchIntent()."); return; } String str7 = (String)localHashMap.get("i"); String str8 = (String)localHashMap.get("m"); Uri localUri = Uri.parse(str6); Object localObject3; if (str7 == null) localObject3 = new Intent("android.intent.action.VIEW", localUri); synchronized (a) { while (true) { if (b == null) { b = this; if (c == null) break; c.t(); } try { com.google.ads.util.a.a("Launching an intent from AdActivity."); startActivity((Intent)localObject3); return; } catch (ActivityNotFoundException localActivityNotFoundException) { com.google.ads.util.a.a(localActivityNotFoundException.getMessage(), localActivityNotFoundException); finish(); return; } Intent localIntent = new Intent(str7); if (str8 != null) { localIntent.setDataAndType(localUri, str8); localObject3 = localIntent; } else { localIntent.setData(localUri); localObject3 = localIntent; } } com.google.ads.util.a.e("currentAdManager is null while trying to call onLeaveApplication()."); }</div>
<p style="color: #666666;"></p>
<p style="color: #666666;"><span style="color: #666666;"><span style="color: #666666; font-size: medium;">

广告的显示主要是一个webview,然后谷歌还用了一些工具类,包括还有定位,定位肯定是为了优化广告了,根据位置推送广告吧,

然后我还在这个AdSize类里发现了广告条大小的定义

java代码:
public class AdSize { public static final AdSize BANNER = new AdSize(320, 50, “320x50_mb”); public static final AdSize IAB_BANNER = new AdSize(468, 60, “468x60_as”); public static final AdSize IAB_LEADERBOARD = new AdSize(728, 90, “728x90_as”); public static final AdSize IAB_MRECT = new AdSize(300, 250, “300x250_as”); private int a; private int b; private String c; public AdSize(int paramInt1, int paramInt2) { this(paramInt1, paramInt2, null); } private AdSize(int paramInt1, int paramInt2, String paramString) { this.a = paramInt1; this.b = paramInt2; this.c = paramString; } public int getHeight() { return this.b; } public int getWidth() { return this.a; }
真正的广告类的定义也在这个包下,类名是AdView,篇幅有限,水平也有限,分析不当的请恳切指出,大牛笑笑就过来不要拍砖我