百度360必应搜狗淘宝本站头条
当前位置:网站首页 > 编程字典 > 正文

摆脱Android app广告的烦恼,通杀第三方sdk广告_安卓广告代码

toyiye 2024-04-03 23:10 29 浏览 0 评论

0x0 前言

应用商店APP中,各种第三方广告横行,插屏广告,还有横屏广告等让用户苦恼不堪。本次对第三方广告原理进行探索以及对第三方广告进行通杀尝试。

0x01 内容说明

1.第三方广告平台,有米广告sdk细节探索。

2.去除插屏广告普遍方法。

3.样本分析,对第三方广告进行通杀尝试。

广告相关

什么是广告?

广义来说,就是和游戏无关的都是广告。

植入广告的目的是什么?

(1)做推广

(2)获利

(3)其它

植入广告原理分析

用一个载体去承载广告,然后显示出来。使用的技术用静态布局,或者使用动态加载等方式。还是来看一下如果植入广告的具体操作吧。

0x02 有米第三方广告注入分析

1.说明

在第三方SDK进行引入的时候,程序员需要按照第三方的要求进行配置。

第三方广告主要涉及的内容有:

(1)应用ID或者KEY

(2)第三方sdk提供的Activity

(3)第三方sdk提供的service

(4)第三方要求的Android权限设置

2.有米官方文档分析

本次分析主要是针对无积分广告类型进行分析。

官方文档传送门

2.1 有米广告基本配置

除了导入sdk之外,有米广告需要配置应用信息。

这个信息需要在有米后台进行应用创建,就会得到相对应的key。

然后进行应用配置

AdManager.getInstance(this).init("5404dc241a8c4c9f", "6a5a3987ecbd349c",true);

如果是别人的加入的广告,改这里的key,可以让广告变成自己的,从而让自己变成受益人,但是不推荐这样做。

2.2 Androidmanifest.xml配置

2.2.1 Android 权限添加

<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />

这些权限是必须权限,用来获取广告,一般的广告都是需要Android权限来从服务器获取。

有米在代码里还添加了权限扫描验证,如果没有权限就会报错。

2.2.2 SDK Activity添加

<activity android:name="er.kj.iy.video.VideoActivity" 
 android:configChanges="keyboard|keyboardHidden|screenSize|orientation" 
 android:screenOrientation="landscape" 
 android:theme="@android:style/Theme.NoTitleBar" /> 
 <!-- 其他组件 --> 
 <activity android:name="er.kj.iy.SD" 
 android:configChanges="keyboard|keyboardHidden|orientation|screenSize" 
 android:theme="@android:style/Theme.NoTitleBar" />

2.2.3 service

 <service android:name="er.kj.iy.QW" 
 android:exported="false" />

这里的service是我们进行通杀的要点。

3.总结说明

当以上的内容全部满足的时候,有米第三方的sdk才能正常工作,如果其中的一个出了问题,那么广告也就不会出现了。所以我们主要针对其中的流程进行处理,就可以对广告进行去除。

4.有米官方demo分析

4.1 demo展示。

可以看到一共有五种广告。

插屏广告是我们最常见的广告,和今日推荐五秒类似,只不过五秒广告会自动退出,插屏广告需要自己手动退出。

我们来看一张gif图片,看一下五秒广告。

很多app软件都会出现这种广告,而且还会出现误点现象等,影响app的用户体验。

4.2 demo 反编译处理

工具:Android Killer

实验环境:夜神模拟器

说明:Android killer是集成工具,所以就不使用apktool,以及工具。

4.2.1 进行反编译

Android killer 使用非常方便,拖放文件即可。

首先来搞定一下“五秒广告”,我们通过对Androidmanifest.xml妙用来让这个五秒广告不进行执行。

关键点在于

<action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/>

思路:

这个两行决定了谁是首先启动的Activity,我们只要改变这个位置,就可以直接跳过“五秒广告”的骚扰,不过在跳过的时候需要对代码进行一定的分析。

这个并不是我们这篇的重点,但是也是一个非常灵活的技巧。

4.2.2 其他方法去除

思路:

广告无非就是从服务器发送过来的一段数据,那么这段数据总会有一个容器去接收它,那么我们就要从service进行入手了。既然要通过service进行广告的传递,那如果我们去除service,是不是广告也就不攻自破了呢。

尝试:

我们尝试去掉和广告相关的service,然后进行反编译。

首先找到位置,删除

进行反编译

最后进行测试

我们发现“五秒广告”已经成功去除,在查看其他广告的时候,也发现同样被去除了。

4.2.3 总结

在有米第三方广告中,我们只要去除和广告息息相关的service,就可以成功的进行去除广告,那么其他第三方广告是不是也是相同属性呢。为了提高普遍性,我们对几个样本进行通杀尝试。

0x03 通杀尝试

样本一

样本材料:机器人九号 APP

实验工具:Android killer

实验环境:夜神模拟器 6.0.1.0

样本分析

首先我们现在夜神模拟器上对样本进行安装。

然后打开样本,进行简单的观察。

我们发现有一个“五秒广告”,那么这个就是我们要杀死的主角了。

样本测试

先进行反编译,然后打开Androidmanifest.xml文件

<?xml version="1.0" encoding="utf-8" standalone="no"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" package="robot9.robot.deified.com.robot9" platformBuildVersionCode="25" platformBuildVersionName="7.1.1"> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.READ_PHONE_STATE"/> <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> <uses-permission android:name="android.permission.GET_TASKS"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.PACKAGE_USAGE_STATS"/> <uses-permission android:name="android.permission.WAKE_LOCK"/> <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/> <permission android:name="robot9.robot.deified.com.robot9.permission.C2D_MESSAGE" android:protectionLevel="signature"/> <uses-permission android:name="robot9.robot.deified.com.robot9.permission.C2D_MESSAGE"/> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:name="robot9.robot.deified.com.robot9.Utilities.RobotApplication" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize" android:name="xa.qwe.xz.Uxa" android:theme="@android:style/Theme.Light.NoTitleBar"/> <service android:exported="false" android:name="xa.qwe.xz.Znd"/> <service android:exported="false" android:name="xa.qwe.xz.Exl"/> <receiver android:name="xa.qwe.xz.Axk"> <intent-filter> <action android:name="android.intent.action.PACKAGE_ADDED"/> <data android:scheme="package"/> </intent-filter> </receiver> <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version"/> <activity android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode" android:name="com.google.android.gms.ads.AdActivity" android:theme="@android:style/Theme.Translucent"/> <activity android:configChanges="keyboard|keyboardHidden|orientation|screenSize" android:name="com.qq.e.ads.ADActivity"/> <activity android:configChanges="keyboard|keyboardHidden|orientation|screenSize" android:name="robot9.robot.deified.com.robot9.Robot9Activity" android:screenOrientation="portrait" android:theme="@style/Theme.AppCompat.NoActionBar"> ><intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity> <activity android:name="robot9.robot.deified.com.robot9.View.RobotPreference"/> <activity android:name="robot9.robot.deified.com.robot9.View.EmptyActivity" android:theme="@android:style/Theme.Translucent"/> <activity android:name="robot9.robot.deified.com.robot9.View.FreshScreenActivity" android:theme="@android:style/Theme.Translucent"/> <service android:enabled="true" android:name="robot9.robot.deified.com.robot9.Service.RobotAccessibilityService" android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE"> <intent-filter> <action android:name="android.accessibilityservice.AccessibilityService"/> </intent-filter> <meta-data android:name="android.accessibilityservice" android:resource="@xml/auto_robot_permissions"/> </service> <activity android:name="com.google.android.gms.ads.purchase.InAppPurchaseActivity" android:theme="@style/Theme.IAPTheme"/> <activity android:exported="false" android:name="com.google.android.gms.common.api.GoogleApiActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar"/> <receiver android:enabled="true" android:exported="false" android:name="com.google.android.gms.measurement.AppMeasurementReceiver"/> <receiver android:enabled="true" android:name="com.google.android.gms.measurement.AppMeasurementInstallReferrerReceiver" android:permission="android.permission.INSTALL_PACKAGES"> <intent-filter> <action android:name="com.android.vending.INSTALL_REFERRER"/> </intent-filter> </receiver> <service android:enabled="true" android:exported="false" android:name="com.google.android.gms.measurement.AppMeasurementService"/> <receiver android:exported="true" android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver" android:permission="com.google.android.c2dm.permission.SEND"> <intent-filter> <action android:name="com.google.android.c2dm.intent.RECEIVE"/> <action android:name="com.google.android.c2dm.intent.REGISTRATION"/> <category android:name="robot9.robot.deified.com.robot9"/> </intent-filter> </receiver> <receiver android:exported="false" android:name="com.google.firebase.iid.FirebaseInstanceIdInternalReceiver"/> <service android:exported="true" android:name="com.google.firebase.iid.FirebaseInstanceIdService"> <intent-filter android:priority="-500"> <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/> </intent-filter> </service> <provider android:authorities="robot9.robot.deified.com.robot9.firebaseinitprovider" android:exported="false" android:initOrder="100" android:name="com.google.firebase.provider.FirebaseInitProvider"/> </application></manifest>

我们注意到有很多行的包名展示的是com.google.android,一般来说这种包名意味着这个app里嵌入了第三方谷歌的广告。

广告的特征词是“ads”

那么我们找到和google相关的service进行删除测试

但是在实际实验的时候,“五秒广告”并没有去除,原本是怀疑可能这个方法不能达到通杀的时候,再次对Androidmanifest.xml文件进行细致的审计,突然发现了,整个APP中不止是嵌入了一个谷歌的第三方广告,还有一个qq的第三方广告。

我们删除service,然后反编译之后进行测试。

通杀结果测试

我们发现广告成功去除了。

由于gif录制工具导致录制时系统卡顿。可能会影响开启效果。

样本二

样本材料: 快乐小鸡 APP

实验工具:Android killer

实验环境:夜神模拟器 6.0.1.0

样本分析

安装测试

首先是“五秒广告”

然后有一个迷你型广告

样本测试

首先反编译,然后对Androidmanifest.xml文件的分析,和之前的样本分析流程一样。

<?xml version="1.0" encoding="utf-8" standalone="no"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.koodroid.chicken" platformBuildVersionCode="23" platformBuildVersionName="6.0-2704002"> <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> <uses-permission android:name="android.permission.READ_PHONE_STATE"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> <uses-permission android:name="android.permission.GET_TASKS"/> <uses-permission android:name="com.samsung.android.providers.context.permission.WRITE_USE_APP_FEATURE_SURVEY"/> <uses-permission android:name="android.permission.WAKE_LOCK"/> <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/> <permission android:name="com.koodroid.chicken.permission.C2D_MESSAGE" android:protectionLevel="signature"/> <uses-permission android:name="com.koodroid.chicken.permission.C2D_MESSAGE"/> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:name="com.koodroid.common.MainApplication" android:theme="@style/AppTheme"> <activity android:configChanges="orientation" android:label="@string/app_name" android:launchMode="singleTask" android:name="com.koodroid.chicken.MainActivity" android:theme="@android:style/Theme.NoTitleBar"/> <activity android:configChanges="keyboardHidden|orientation" android:label="@string/app_name" android:launchMode="singleTask" android:name="com.koodroid.chicken.RSplashActivity" android:screenOrientation="portrait" android:theme="@android:style/Theme.NoTitleBar"> <intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity> <activity android:configChanges="keyboard|keyboardHidden|orientation" android:name="com.baidu.mobads.AppActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar"/> <service android:exported="false" android:name="com.qq.e.comm.DownloadService"/> <activity android:configChanges="keyboard|keyboardHidden|orientation|screenSize" android:name="com.qq.e.ads.ADActivity"/> <meta-data android:name="UMENG_APPKEY" android:value="57eb8916e0f55a72de0001de"/> <meta-data android:name="UMENG_CHANNEL" android:value="Ali"/> <meta-data android:name="BaiduMobAd_APP_ID" android:value="a457abae"/> <activity android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode" android:name="com.google.android.gms.ads.AdActivity" android:theme="@android:style/Theme.Translucent"/> <activity android:name="com.google.android.gms.ads.purchase.InAppPurchaseActivity" android:theme="@style/Theme.IAPTheme"/> <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version"/> <activity android:exported="false" android:name="com.google.android.gms.common.api.GoogleApiActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar"/> <receiver android:enabled="true" android:exported="false" android:name="com.google.android.gms.measurement.AppMeasurementReceiver"/> <receiver android:enabled="true" android:name="com.google.android.gms.measurement.AppMeasurementInstallReferrerReceiver" android:permission="android.permission.INSTALL_PACKAGES"> <intent-filter> <action android:name="com.android.vending.INSTALL_REFERRER"/> </intent-filter> </receiver> <service android:enabled="true" android:exported="false" android:name="com.google.android.gms.measurement.AppMeasurementService"/> <provider android:authorities="com.koodroid.chicken.firebaseinitprovider" android:exported="false" android:initOrder="100" android:name="com.google.firebase.provider.FirebaseInitProvider"/> <receiver android:exported="true" android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver" android:permission="com.google.android.c2dm.permission.SEND"> <intent-filter> <action android:name="com.google.android.c2dm.intent.RECEIVE"/> <action android:name="com.google.android.c2dm.intent.REGISTRATION"/> <category android:name="com.koodroid.chicken"/> </intent-filter> </receiver> <receiver android:exported="false" android:name="com.google.firebase.iid.FirebaseInstanceIdInternalReceiver"/> <service android:exported="true" android:name="com.google.firebase.iid.FirebaseInstanceIdService"> <intent-filter android:priority="-500"> <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/> </intent-filter> </service> </application></manifest>

这个service,就是我们需要删除的广告服务

还有一些其他的和广告也一切删除了。

当这些服务都删除的时候,我们的去广告就成功了。

样本观察测试

我们发现样本的广告已经成功消除了。

0x04 通杀思考

1.Android 开发的基础是java,相对于c/c++来说, 更加容易被反编译,所以不法分子通过二次打包app,给app加上了sdk第三方软件广告来获取利益,给用户体验造成了很大的影响。

2.当广告恶劣到一定程度的时候,就相当于是一种病毒,通过改变app的运行方式,强制使用app内部权限,导致app主次分离,影响app本生的功能。

3.删除一个东西很简单,但是知道删除什么东西才是难点。

4.app第三方广告通杀方面,将第三方sdk提供的service服务进行删除,就可以成功的通杀市面上大部分的广告,我们通杀的要点就是Androidmanifest.xml文件,service将在Androidmanifest文件进行注册,所以我们需要做的就是删除service的注册信息,那么service将失去其意义,广告也将被删除。

5.我们通过对Androidmanifest.xml文件进行过滤,过滤并删除与广告相关的servcice。进行简单的工具的制作,那么就可以进行自动化通杀广告,给app进行一个绿化的能力。

相关推荐

为何越来越多的编程语言使用JSON(为什么编程)

JSON是JavascriptObjectNotation的缩写,意思是Javascript对象表示法,是一种易于人类阅读和对编程友好的文本数据传递方法,是JavaScript语言规范定义的一个子...

何时在数据库中使用 JSON(数据库用json格式存储)

在本文中,您将了解何时应考虑将JSON数据类型添加到表中以及何时应避免使用它们。每天?分享?最新?软件?开发?,Devops,敏捷?,测试?以及?项目?管理?最新?,最热门?的?文章?,每天?花?...

MySQL 从零开始:05 数据类型(mysql数据类型有哪些,并举例)

前面的讲解中已经接触到了表的创建,表的创建是对字段的声明,比如:上述语句声明了字段的名称、类型、所占空间、默认值和是否可以为空等信息。其中的int、varchar、char和decimal都...

JSON对象花样进阶(json格式对象)

一、引言在现代Web开发中,JSON(JavaScriptObjectNotation)已经成为数据交换的标准格式。无论是从前端向后端发送数据,还是从后端接收数据,JSON都是不可或缺的一部分。...

深入理解 JSON 和 Form-data(json和formdata提交区别)

在讨论现代网络开发与API设计的语境下,理解客户端和服务器间如何有效且可靠地交换数据变得尤为关键。这里,特别值得关注的是两种主流数据格式:...

JSON 语法(json 语法 priority)

JSON语法是JavaScript语法的子集。JSON语法规则JSON语法是JavaScript对象表示法语法的子集。数据在名称/值对中数据由逗号分隔花括号保存对象方括号保存数组JS...

JSON语法详解(json的语法规则)

JSON语法规则JSON语法是JavaScript对象表示法语法的子集。数据在名称/值对中数据由逗号分隔大括号保存对象中括号保存数组注意:json的key是字符串,且必须是双引号,不能是单引号...

MySQL JSON数据类型操作(mysql的json)

概述mysql自5.7.8版本开始,就支持了json结构的数据存储和查询,这表明了mysql也在不断的学习和增加nosql数据库的有点。但mysql毕竟是关系型数据库,在处理json这种非结构化的数据...

JSON的数据模式(json数据格式示例)

像XML模式一样,JSON数据格式也有Schema,这是一个基于JSON格式的规范。JSON模式也以JSON格式编写。它用于验证JSON数据。JSON模式示例以下代码显示了基本的JSON模式。{"...

前端学习——JSON格式详解(后端json格式)

JSON(JavaScriptObjectNotation)是一种轻量级的数据交换格式。易于人阅读和编写。同时也易于机器解析和生成。它基于JavaScriptProgrammingLa...

什么是 JSON:详解 JSON 及其优势(什么叫json)

现在程序员还有谁不知道JSON吗?无论对于前端还是后端,JSON都是一种常见的数据格式。那么JSON到底是什么呢?JSON的定义...

PostgreSQL JSON 类型:处理结构化数据

PostgreSQL提供JSON类型,以存储结构化数据。JSON是一种开放的数据格式,可用于存储各种类型的值。什么是JSON类型?JSON类型表示JSON(JavaScriptO...

JavaScript:JSON、三种包装类(javascript 包)

JOSN:我们希望可以将一个对象在不同的语言中进行传递,以达到通信的目的,最佳方式就是将一个对象转换为字符串的形式JSON(JavaScriptObjectNotation)-JS的对象表示法...

Python数据分析 只要1分钟 教你玩转JSON 全程干货

Json简介:Json,全名JavaScriptObjectNotation,JSON(JavaScriptObjectNotation(记号、标记))是一种轻量级的数据交换格式。它基于J...

比较一下JSON与XML两种数据格式?(json和xml哪个好)

JSON(JavaScriptObjectNotation)和XML(eXtensibleMarkupLanguage)是在日常开发中比较常用的两种数据格式,它们主要的作用就是用来进行数据的传...

取消回复欢迎 发表评论:

请填写验证码