Android逆向学习(四)app修改smali函数跳过弹窗广告,等待广告,更新提醒
一、写在前面
这是吾爱破解课程的第三个练习,我在写这篇博客时遇到了vscode插件bug,已经想办法联系原作者了,希望能够尽快更新修复这个问题,废话少说let’s go
二、任务目标
打开后会出现一个带有时间的广告弹窗和一大堆弹出广告,我们的任务就是去掉这些东西

三、去除等待广告
我们首先打开开发助手的activity查看,看看这个activity是怎么一个调用的

我们可以发现这个调用的逻辑是这样MainActivity -> AdActivity -> AlertDialog
我们就按这个查,先查AdActivity
然后我竟然发现了smali2java的bug,绝了,这个bug的修复放在了番外篇,会进行一个简单介绍和bug修复的方法

然后我们分析这个代码的结构,最神奇的地方来了,这个jadx开源软件也有一个问题

这里有一个代码没有被翻译成java,当然这一段我们光看smali代码也能看出来这个是用lambda表达式调用了jump这个方法,我们可以换个逆向工具来看一下这个的具体代码

这里就很明显可以看出这是等时间到了之后就调用了jump函数然后打开了一个新的activity
我们可以这样,我的想法如下图
1 2 3 4 5
| protected void onCreate(Bundle bundle) { super.onCreate(bundle); setContentView(2131427365); loadAd(); }
|
说干就干

然后我们打包运行一下(注:打开方式见第一篇博客)

四、去除更新通知
这时我们可以看到之前的广告没有了,然后根据我们之前看的jump代码
1 2 3 4
| public final void jump() { startActivity(new Intent((Context) this, ChallengeThird.class)); finish(); }
|
他是使用intent跳转到了ChallengeThird.class,intent是android切换activity的一个方法,在这里建议最好学android逆向之前先了解一下android开发,我很久以前学过android开发,有时间的话会开始重新写一下相关博客,可以看一下《android第一行代码》,最好的android开发书,没有之一
所以我们开始查看这个class看看大概是怎么样的一个代码逻辑(下面这个就是逆向出来的代码)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| public final class ChallengeThird extends AppCompatActivity { protected void onCreate(Bundle bundle) { super.onCreate(bundle); setContentView(2131427362); Context context = (Context) this; AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle("这是二号广告标题"); builder.setMessage("这是二号广告内容"); builder.setCancelable(false); builder.setPositiveButton("前往论坛", new ChallengeThird$.ExternalSyntheticLambda1(this)); builder.setNegativeButton("退出软件", ChallengeThird$.ExternalSyntheticLambda2.INSTANCE); builder.show(); new CommonDialog.Builder(context).setMessage("一号广告弹窗已就位").setNegativeButton("退出软件", ChallengeThird$.ExternalSyntheticLambda3.INSTANCE).setMessageColor(-16777216).setPositiveButton("前往论坛", new ChallengeThird$.ExternalSyntheticLambda0(this)).setWith(0.8f).create().show(); checkUpdate(); }
public static final void m1onCreate$lambda2$lambda0(ChallengeThird challengeThird, DialogInterface dialogInterface, int i) { Intent intent = new Intent("android.intent.action.VIEW"); intent.setData(Uri.parse("https://www.52pojie.cn/forum.php")); challengeThird.startActivity(intent); }
public static final void m4onCreate$lambda4(ChallengeThird challengeThird, DialogInterface dialogInterface, int i) { Intent intent = new Intent("android.intent.action.VIEW"); intent.setData(Uri.parse("https://www.52pojie.cn/forum.php")); challengeThird.startActivity(intent); }
private final void checkUpdate() { ((AppService) ServiceCreator.INSTANCE.create(AppService.class)).getAppUpdate().enqueue(new checkUpdate.1(this)); }
public final int getVersionCode(Context context) { try { return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode; } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); return 0; } } }
|
然后我在进行逆向时发现了这么一个好玩的东西,这个checkupdate方法,然后我们可以在另一个文件中找到这个类,然后我们看到这个是个进行版本匹配的一个函数,废话少说直接修改

我们了解代码逻辑后直接锁定在这一块代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| invoke-virtual {p1}, Lcom/zj/dongbeiwangshi/network/UpdataResponse;->getVersionCode()I
move-result p1
if-ge p2, p1, :cond_0
.line 72 iget-object p1, p0, Lcom/zj/dongbeiwangshi/ui/ChallengeThird$checkUpdate$1;->this$0:Lcom/zj/dongbeiwangshi/ui/ChallengeThird;
check-cast p1, Landroid/content/Context;
invoke-static {p1}, Lcom/zj/dongbeiwangshi/util/DialogUtilsKt;->showUpdatinDialog(Landroid/content/Context;)V
:cond_0 return-void
|
我们按上面的修改,然后重新打包运行一下

很好,我们成功的去掉了更新提醒,下一个就是广告弹窗了
五、去除广告弹窗
这里有两个广告弹窗,一般广告弹窗都是.show文件调用的,我们只需要想办法把这两个弹窗的show函数给干掉就行了,根据我们两篇比对着查找,我们很轻松就发现两个show的位置


直接给注释掉,简单粗暴
六、去除横幅广告
本来以为结束了,结果半路又杀出来一个

横幅广告是吧,这一看就是一个图片,先查后干
我们当时分析的时候没有在smali代码中发现这个东西,这就说明他肯定在布局文件里面,然后一查,果不其然,在layout目录下的布局文件中

直接删了,然后顺便还可以更改一下最后的图标

所以终于完成了,希望这个文章对你有帮助