0x00 關(guān)于AndroidManifest.xml
網(wǎng)站建設(shè)哪家好,找創(chuàng)新互聯(lián)!專注于網(wǎng)頁設(shè)計(jì)、網(wǎng)站建設(shè)、微信開發(fā)、成都微信小程序、集團(tuán)企業(yè)網(wǎng)站建設(shè)等服務(wù)項(xiàng)目。為回饋新老客戶創(chuàng)新互聯(lián)還提供了聊城免費(fèi)建站歡迎大家使用!
AndroidManifest.xml 是每個(gè)android程序中必須的文件。它位于整個(gè)項(xiàng)目的根目錄,Manifest文件提供有關(guān)應(yīng)用程序到Android系統(tǒng)的基本信息,系統(tǒng)必須具有該信息才能運(yùn)行任何應(yīng)用程序的代碼。換句話說APP是跑在Android系統(tǒng)上,既然要跑在其上,就必須提供信息給Android System,這些信息就存在AndroidManifest中。AndroidManifest.xml
存放在 app/src/main/ 目錄下。在反編譯APK文件后,其文件是以亂碼格式存在,需要進(jìn)行轉(zhuǎn)換才能正常查看。
AndroidManifest.xml的主要功能
<?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>
0x01 AndroidManifest.xml風(fēng)險(xiǎn)點(diǎn)分析
1、allowBackup設(shè)置風(fēng)險(xiǎn)
Android API Level 8 (Android 2.1)及其以上Android系統(tǒng)提供了為應(yīng)用程序數(shù)據(jù)的備份和恢復(fù)功能,此功能的開關(guān)決定于該應(yīng)用程序中 AndroidManifest.xml 文件中的 allowBackup 屬性值,其屬性值默認(rèn)是 true。當(dāng)allowBackup的屬性值沒有顯示設(shè)置為false時(shí),攻擊者可通過 adb backup 和 adb restore 來進(jìn)行對(duì)應(yīng)用數(shù)據(jù)的備份和恢復(fù),從而可能獲取明文存儲(chǔ)的用戶的敏感信息。
android:allowBackup=["true" | "false"]
$ adb backup -nosystem -noshared -apk -f com.example.demo $ adb restore com.example.demo
2、debuggable設(shè)置風(fēng)險(xiǎn)
該屬性用于指定應(yīng)用程序是否能夠被調(diào)試,即使是以用戶模式運(yùn)行在設(shè)備上的時(shí)候,如果設(shè)置為true,則可以被調(diào)試;但是現(xiàn)在Android版本均默認(rèn)debuggable的屬性值為false,所以建議使用默認(rèn)配置。
android:debuggable=["true" | "false"]
3、組件導(dǎo)出風(fēng)險(xiǎn)
四大組件
可導(dǎo)出的組件能被第三方APP任意調(diào)用,導(dǎo)致敏感信息泄露,并可能被利用于繞過認(rèn)證、惡意代碼注入、sql注入、拒絕服務(wù)等攻擊;
Activity中exported的默認(rèn)值
而intent filter標(biāo)簽代表是主Activity,而每個(gè)APP都會(huì)有一個(gè)主Activity,所以當(dāng)應(yīng)用的Activity不必要導(dǎo)出時(shí),或者配置了intent filter標(biāo)簽,建議顯示設(shè)置android:exported="false"。如果組件必須要導(dǎo)出給其他應(yīng)用使用,建議對(duì)組件進(jìn)行權(quán)限控制。
Broadcast Receive和Service的默認(rèn)值都跟Activity的一樣。
Content Provider中exported的默認(rèn)值
當(dāng)minSdkVersion或者targetSdkVersion小于16時(shí),默認(rèn)為true 大于17時(shí),默認(rèn)為false
4、自定義權(quán)限風(fēng)險(xiǎn)
在Android系統(tǒng)的安全模型中,應(yīng)用程序在默認(rèn)的情況下不可以執(zhí)行任何對(duì)其他應(yīng)用程序、系統(tǒng)或用戶帶來負(fù)面影響的操作。如果應(yīng)用需要執(zhí)行某些操作,就需要聲明使用這個(gè)操作對(duì)應(yīng)的權(quán)限,也就是在AndroidManifest.xml文件中添加<uses-permission>標(biāo)記,當(dāng)然也可以自定義屬于自己的permission。但是如果權(quán)限控制不當(dāng),那么就可能導(dǎo)致各種越權(quán)等安全問題。
<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"/> android:protectionLevel=["normal" | "dangerous" | "signature" | "signatureOrSystem"]
0x02 AndroidManifest.xml結(jié)構(gòu)
<?xmlversion="1.0"encoding="utf-8"?> <manifest> <application> <activity> <intent-filter> <action/> <category/> </intent-filter> </activity> <activity-alias> <intent-filter></intent-filter> <meta-data/> </activity-alias> <service> <intent-filter></intent-filter> <meta-data/> </service> <receiver> <intent-filter></intent-filter> <meta-data/> </receiver> <provider> <grant-uri-permission/> <meta-data/> </provider> <uses-library/> </application> <uses-permission/> <permission/> <permission-tree/> <permission-group/> <instrumentation/> <uses-sdk/> <uses-configuration/> <uses-feature/> <supports-screens/> </manifest>
0x03 AndroidManifest.xml分節(jié)介紹
1、manifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.woody.test" android:sharedUserId="string" android:sharedUserLabel="string resource" android:versionCode="integer" android:versionName="string" android:installLocation=["auto" | "internalOnly" | "preferExternal"] > </manifest>
2、application
<application android:allowClearUserData=["true" | "false"] android:allowTaskReparenting=["true" | "false"] android:backupAgent="string" android:debuggable=["true" | "false"] android:description="string resource" android:enabled=["true" | "false"] android:hasCode=["true" | "false"] android:icon="drawable resource" android:killAfterRestore=["true" | "false"] android:label="string resource" android:manageSpaceActivity="string" android:name="string" android:permission="string" android:persistent=["true" | "false"] android:process="string" android:restoreAnyVersion=["true" | "false"] android:taskAffinity="string" android:theme="resource or theme" > </application>
3、activity
<activity android:allowTaskReparenting=["true" | "false"] android:alwaysRetainTaskState=["true" | "false"] android:clearTaskOnLaunch=["true" | "false"] android:configChanges=["mcc", "mnc", "locale", "touchscreen", "keyboard", "keyboardHidden", "navigation", "orientation", "screenLayout", "fontScale", "uiMode"] android:enabled=["true" | "false"] android:excludeFromRecents=["true" | "false"] android:exported=["true" | "false"] android:finishOnTaskLaunch=["true" | "false"] android:icon="drawable resource" android:label="string resource" android:launchMode=["multiple" | "singleTop" | "singleTask" | "singleInstance"] android:multiprocess=["true" | "false"] android:name="string" android:noHistory=["true" | "false"] android:permission="string" android:process="string" android:screenOrientation=["unspecified" | "user" | "behind" | "landscape" | "portrait" | "sensor" | "nosensor"] android:stateNotNeeded=["true" | "false"] android:taskAffinity="string" android:theme="resource or theme" android:windowSoftInputMode=["stateUnspecified", "stateUnchanged", "stateHidden", "stateAlwaysHidden", "stateVisible", "stateAlwaysVisible", "adjustUnspecified", "adjustResize", "adjustPan"] > </activity>
4、intent-filter
<intent-filter android:icon="drawable resource" android:label="string resource" android:priority="integer" > <action /> <category /> <data /> </intent-filter>
5、meta-data
<meta-data android:name="string" android:resource="resource specification" android:value="string"/>
6、activity-alias
<activity-alias android:enabled=["true" | "false"] android:exported=["true" | "false"] android:icon="drawable resource" android:label="string resource" android:name="string" android:permission="string" android:targetActivity="string"> <intent-filter/> <meta-data/> </activity-alias>
7、service
<service android:enabled=["true" | "false"] android:exported[="true" | "false"] android:icon="drawable resource" android:label="string resource" android:name="string" android:permission="string" android:process="string"> </service>
8、receiver
9、provider
<provider android:authorities="list" android:enabled=["true" | "false"] android:exported=["true" | "false"] android:grantUriPermissions=["true" | "false"] android:icon="drawable resource" android:initOrder="integer" android:label="string resource" android:multiprocess=["true" | "false"] android:name="string" android:permission="string" android:process="string" android:readPermission="string" android:syncable=["true" | "false"] android:writePermission="string"> <grant-uri-permission/> <meta-data/> </provider>
10、uses-library 11、supports-screens
<supports-screens android:smallScreens=["true" | "false"] android:normalScreens=["true" | "false"] android:largeScreens=["true" | "false"] android:anyDensity=["true" | "false"] />
12、uses-configuration和uses-feature
<uses-configuration android:reqFiveWayNav=["true" | "false"] android:reqHardKeyboard=["true" | "false"] android:reqKeyboardType=["undefined" | "nokeys" | "qwerty" | "twelvekey"] android:reqNavigation=["undefined" | "nonav" | "dpad" | "trackball" | "wheel"] android:reqTouchScreen=["undefined" | "notouch" | "stylus" | "finger"] /> <uses-feature android:glEsVersion="integer" android:name="string" android:required=["true" | "false"] />
13、uses-sdk
<uses-sdk android:minSdkVersion="integer" android:targetSdkVersion="integer" android:maxSdkVersion="integer"/>
14、instrumentation
<instrumentation android:functionalTest=["true" | "false"] android:handleProfiling=["true" | "false"] android:icon="drawable resource" android:label="string resource" android:name="string" android:targetPackage="string"/>
15、<permission>、<uses-permission>、<permission-tree />、<permission-group />區(qū)別
最常用的當(dāng)屬<uses-permission>,
當(dāng)我們需要獲取某個(gè)權(quán)限的時(shí)候就必須在我們的manifest文件中聲明,此<uses-permission>
與<application>同級(jí),具體權(quán)限列表請(qǐng)看此處
通常情況下我們不需要為自己的應(yīng)用程序聲明某個(gè)權(quán)限,除非你提供了供其他應(yīng)用程序調(diào)用的代碼或者數(shù)據(jù)。這個(gè)時(shí)候你才需要使用<permission> 這個(gè)標(biāo)簽。很顯然這個(gè)標(biāo)簽可以讓我們聲明自己的權(quán)限。比如:
<permission android:name="com.teleca.project.MY_SECURITY" . . . />
那么在activity中就可以聲明該自定義權(quán)限了,如:
<application . . .> <activity android:name="XXX" . . . > android:permission="com.teleca.project.MY_SECURITY"> </activity> </application>
當(dāng)然自己聲明的permission也不能隨意的使用,還是需要使用<uses-permission>
來聲明你需要該權(quán)限<permission-group>
就是聲明一個(gè)標(biāo)簽,該標(biāo)簽代表了一組permissions,而<permission-tree>
是為一組permissions聲明了一個(gè)namespace。這兩個(gè)標(biāo)簽可以看之前的系列文章。
到此這篇關(guān)于AndroidManifest.xml中含蓋的安全問題的文章就介紹到這了,更多相關(guān)AndroidManifest.xml中含蓋的安全問題內(nèi)容請(qǐng)搜索創(chuàng)新互聯(lián)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持創(chuàng)新互聯(lián)!
網(wǎng)頁題目:AndroidManifest.xml中含蓋的安全問題詳解
本文URL:http://aaarwkj.com/article42/jeiiec.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站維護(hù)、微信公眾號(hào)、動(dòng)態(tài)網(wǎng)站、標(biāo)簽優(yōu)化、虛擬主機(jī)、網(wǎng)站內(nèi)鏈
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)