安全测试-AndroidManifest.xml元素分析(1)

目录

简介

一、AndroidManifest.xml 样例

二、AndroidManifest.xml 元素

2.1  manifest 元素

2.2 xmlns:android 属性

2.3 package 属性

2.4 android:versionCode 属性

 2.5 android:versionName 属性

 2.6 application元素

2.7 android:allowBackup 属性

2.8 permission 元素

2.9 android:name 属性

2.10 android:protect ionLevel 属性

2.11 

2.12 android:name 属性

三、Activity 界面组件

3.1 android:name 属性

四、Service 服务组件

五、Receiver 消息组件

六、Provider 内容组件


简介

        一AndroidManifest官方解释是应用清单(Manifest意思是货单),我们可以这样理解为apk包反编译后每个应用的根目录中都必须包含一个,并且文件名必须为AndroidManifest。这个文件中包含了APP的配置信息,系统需要根据里面的内容运行APP的代码,显示界面。Android四大基本组件都需要声明才能使用,每个组件都需要在AndroidManifest.xml文件中进行配置。
Android四大组

❥Activity:界面组件,就是一个单独的窗口(如冷启动应用进入界面的就是launchable-activity)。
❥Service:服务组件,用于在后台完成用户指定的操作(如后台音乐播放)。
❥Contentprovider:内容组件,是一种数据共享型组件,用于向其他组件乃至其他应用共享数据(如短信和联系人应用之间的数据共享)。
❥Broadcastreceiver:消息组件,监听/接收应用App发出的广播消息并做出响应(如电话呼入,耳机插入)。AndroidManifest.xml 样例

一、AndroidManifest.xml 样例

以下 XML 文件为AndroidManifest.xml 的一个简单示例,该示例为应用声明8个 Activity

<?xml version="1.0" encoding="utf-8" standalone="no"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.mwr.example.sieve">
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <permission android:label="Allows reading of the Key in Sieve" android:name="com.mwr.example.sieve.READ_KEYS" android:protectionLevel="dangerous"/>
    <permission android:label="Allows editing of the Key in Sieve" android:name="com.mwr.example.sieve.WRITE_KEYS" android:protectionLevel="dangerous"/>
    <application android:allowBackup="true" android:debuggable="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme">
        <activity android:clearTaskOnLaunch="true" android:excludeFromRecents="true" android:exported="true" android:finishOnTaskLaunch="true" android:label="@string/title_activity_file_select" android:name=".FileSelectActivity"/>
        <activity android:excludeFromRecents="true" android:label="@string/app_name" android:launchMode="singleTask" android:name=".MainLoginActivity" android:windowSoftInputMode="adjustResize|stateVisible">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <activity android:clearTaskOnLaunch="true" android:excludeFromRecents="true" android:exported="true" android:finishOnTaskLaunch="true" android:label="@string/title_activity_pwlist" android:name=".PWList"/>
        <activity android:clearTaskOnLaunch="true" android:excludeFromRecents="true" android:finishOnTaskLaunch="true" android:label="@string/title_activity_settings" android:name=".SettingsActivity"/>
        <activity android:clearTaskOnLaunch="true" android:excludeFromRecents="true" android:finishOnTaskLaunch="true" android:label="@string/title_activity_add_entry" android:name=".AddEntryActivity"/>
        <activity android:clearTaskOnLaunch="true" android:excludeFromRecents="true" android:finishOnTaskLaunch="true" android:label="@string/title_activity_short_login" android:name=".ShortLoginActivity"/>
        <activity android:clearTaskOnLaunch="true" android:excludeFromRecents="true" android:finishOnTaskLaunch="true" android:label="@string/title_activity_welcome" android:name=".WelcomeActivity"/>
        <activity android:clearTaskOnLaunch="true" android:excludeFromRecents="true" android:finishOnTaskLaunch="true" android:label="@string/title_activity_pin" android:name=".PINActivity"/>
        <service android:exported="true" android:name=".AuthService" android:process=":remote"/>
        <service android:exported="true" android:name=".CryptoService" android:process=":remote"/>
        <provider android:authorities="com.mwr.example.sieve.DBContentProvider" android:exported="true" android:multiprocess="true" android:name=".DBContentProvider">
            <path-permission android:path="/Keys" android:readPermission="com.mwr.example.sieve.READ_KEYS" android:writePermission="com.mwr.example.sieve.WRITE_KEYS"/>
        </provider>
        <provider android:authorities="com.mwr.example.sieve.FileBackupProvider" android:exported="true" android:multiprocess="true" android:name=".FileBackupProvider"/>
    </application>
</manifest>

二、AndroidManifest.xml 元素

2.1  manifest 

<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="1"
android :vers ionName="1.0"
package="com.mwr.example.sieve">

        首先,所有的 AndroidManifest.xml 都必须包含<manifest>元素。这是文件的根节点。它必须要 <application>元素,并且指明 xmlns:android package 属性。

2.2 xmlns:android 

 这个属性定义了Android 命名空间。

必须设置成"http://schemas.android.com/apk/res/android"。不要手动修改。

2.3 package 属性

包名也代着唯一的 appl ication ID,用来发布应用。包名由英文字母 (大小写均可) 、数 字和划线组成。每个独立的名字必须以字母开头。

参考:package="com.example.myapp"

2.4 android:versionCode 属性

的版本号。用来表明哪个版本更新。这个数字不会显示给用户。显示给用户的是 versionName。这数字必须是整数。不能用 16 进制,也就是说不接受 0x1这种参数

例:

 2.5 android:versionName 属性

对外发布版本号 

 2.6 application元素

<application
android:allowBackup="true"
android : icon="@mipmap/ic_ launcher"
android:roundIcon="@mipmap/ic_ launcher_round"
android : label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">

       应用的声明,此元素包含用于声明每个应用组件的子元素,并且具有会影响所有组件的属性。

其中许多属性 (如 iconlabelpermiss ionprocesstaskAffinity al lowTaskReparenting) 会

件元素的相应属性设置默认值。其他属性 (如 debuggableenabled description allowClearUserData) 则为整个应用设置值,并且不能被组件替换。

2.7 android:allowBackup 属性

        是否允许应用参与备份和恢复基础架构。如果将此属性设为 false,则永远不会为该应用执 份或恢复,即使是采用全系统备份方法也不例外 (这种备份方法通常会通过 adb 保存所 有应用数据) 此属性的默认值为 true

2.8 permission 元素

<permission android:name="getu i.permission.GetuiService.com.tal.kaoyan"
android:protect ionLevel="normal"/>

明限制此应用安全权限。

2.9 android:name 属性

限的名称

2.10 android:protect ionLevel 属性

出于全考虑,Android 中对一些访问进行了限制,如网络访问 (需付费) 以及获取联系人  (及隐私) 等。应用程序如果想要进行此类访问,则需要申请相应权限。Android 对这些 限进行了四类分级,不同级别的权限对应不同的认证方式。

  *normal:低风险权限,只要申请了就可以使用 (在 AndroidManifest.xml 中添加

<uses-permission>标签) ,安装时不需要用户确认

  * dangerous:高风险权限,安装时需要用户的确认才可使用;

  * signature:只有当申请权限的应用程序的数字签名与声明此权限的应用程序的数字

签名相时 (如果是申请系统权限,则需要与系统签名相同) ,才能将权限授给它;

 *  signatureOrSystem:申请权限的应用数字签名与该应用数字签名相同,或者申请权限

的应用为系统应用才可以授权

2.11 <uses-permission>

指定用户必须授予的系统权限,以便应用正常运行。当 (在运行Android 5.1 和更低版本 上) 安装应用或 (在运行Android 6.0 和更高版本的设备上) 运行应用时,用户需要手 授予权限。

<uses-permiss ion android :name="android.permission.SYSTEM_ALERT_WINDOW"/> <uses-permiss ion android :name="android.permission. INTERNET"/>

<uses-permiss ion android :name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permiss ion android :name="android.permission.ACCESS_NETWORK_STATE"/>  <uses-permiss ion android :name="android.permission.ACCESS_WIFI_STATE"/>

2.12 android:name 属性

权限的名称。

三、Activity 界面组件

 声明实应用部分可视化界面的 Activity,必须用 AndroidManifest 中的 <activity>元素表示所  Activity。系统不会识别和运行任何未进行声明的Activity

3.1 android:name 属性

android:name 表示实现 Activity 的类的名称,是 Activity 的子类。

四、Service 服务组件

使用<service>将服务 (Service) 子类声明为应用的一个组件。与 Activity 不同,服务缺少可 视化界面,服务用于实现长时间运行的后台操作

五、Receiver 消息组件

使用<receiver>将广播接收器 (BroadcastReceiver 子类) 声明为应用的组件之一。广播接收器 许应用接收由系统或其他应用广播的 Intent

六、Provider 内容组件

 

应用中的有内容提供程序都必须在清单文件的 <provider> 元素中定义,声明内容提供程序 件。

 七、intent-filter

intent-filter 成中文就是意图过滤器,主要用来过滤隐式意图。当用户进行一项操作的 Android 系统会根据配置的意图过滤器 来寻找可以响应该操作的组件服务,由<action> <category> <data> 三个属性构成

   到这里我们基本掌握了AndroidManifest.xml 元素里面的属性内容,对我们后续进行app包体的安全测试业务有一定帮助,那本章节就先了解到这吧,咋们后面的章节再详细介绍与实践。

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
E:\JIULANG\WordsFairy\App\app\build\intermediates\tmp\manifest\androidTest\debug\tempFile1ProcessTestManifest11394250735464286492.xml:27:9-33:20 Error: android:exported needs to be explicitly specified for element <activity#androidx.test.core.app.InstrumentationActivityInvoker$BootstrapActivity>. Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details. E:\JIULANG\WordsFairy\App\app\build\intermediates\tmp\manifest\androidTest\debug\tempFile1ProcessTestManifest11394250735464286492.xml:34:9-40:20 Error: android:exported needs to be explicitly specified for element <activity#androidx.test.core.app.InstrumentationActivityInvoker$EmptyActivity>. Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details. E:\JIULANG\WordsFairy\App\app\build\intermediates\tmp\manifest\androidTest\debug\tempFile1ProcessTestManifest11394250735464286492.xml:41:9-47:20 Error: android:exported needs to be explicitly specified for element <activity#androidx.test.core.app.InstrumentationActivityInvoker$EmptyFloatingActivity>. Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.
07-25

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值