Android Security Model

前言

Android security model 基于:

  • Linux 基于用户的保护 Linux user-based protection
    • 保证APP对系统中其他进程的绝缘,APP不应该被其他APP或者进程直接读写数据或内存
    • root 和系统进程是最常受到恶意攻击,所以保持最小数量的root和系统进程对于安全设备是至关重要的
  • APK签名 APK Signing
  • 用户权限 User Permissions

UID 和 GID

UID(User IDs)

  • 每一个安装在系统的程序和资源都会获取一个UID,例如“u0_a15”
    • 默认时,进程只能够访问同一个UID下的资源。也就是说,android为UID下的资源启动保护机制,禁止不同UID的进程访问
    • 每一个APP都是在自己的sandbox中执行

UID 在android framework定义如下:

  • root:0
  • system:1000
  • reserved for system use: >1000 and <10000
  • Users applications (u0_a*): >= 10000
    更多信息在
    system/core/include/private/android_filesystem_config.h
#define AID_ROOT             0  /* traditional unix root user */
#define AID_SYSTEM        1000  /* system server */
#define AID_RADIO         1001  /* telephony subsystem, RIL */
...
#define AID_APP          10000  /* first app user */
...
static const struct android_id_info android_ids[] = {
    { "root",          AID_ROOT, },
    { "system",        AID_SYSTEM, },
    { "radio",         AID_RADIO, },

GID

GID是一个包含一个或者多个user的唯一标示

Android用UID和GID为资源分配不同的特权,比如SD card、network。UID和GID映射在Linux权限下
默认时,系统为APP生成UID,你也可以在AndroidManifest.xml中指定
如果两个进程想要同一个UID,他们必须用同一个证书进行签名。
举例:system UID是1000,如果APP想使用这个UID,APP必须用platform签名并且设置UID

android:sharedUserId="android.id.system"

每一个用户至少是一个group的一员,默认时,GID和UID一样。一个用户也可能被列在多个group里。
当APP请求具有GID保护的权限时,APP将被加入到相应的group中。
以下文件的那个一了所有和Linux group相关的权限。
framework/base/data/etc/platform.xml

    <permission name="android.permission.BLUETOOTH_ADMIN" >
        <group gid="net_bt_admin" />
    </permission>
    <permission name="android.permission.BLUETOOTH" >
        <group gid="net_bt" />
    </permission>

怎么查找进程的UID, GID

启动APP的时候检查log
如果APP想要运行是查询GID,使用:

mContext.getPackageManger().getPackageGids("PACKAGE_NAME");

每一个GID都和一个特权相关,比如1006是Camera, 3003 network socket

APK signing

Android用signing作为一个作者标示的方式,并且在APP之间建立信任关系
signing并不等同加密,也并没有加密任何东西
证书是为了标示APP的作者
举例来说,证书分为:platform,shared, media
可以在Android.mk中定义sign的证书

LOCAL_PACKAGE_NAME := Bluetooth
LOCAL_CERTIFICATE := platform

所有的APP都必须经过证书signing。没有signing的APP是不能被安装的。
用SDK开发的时候,APP会被会SDK编译工具signing,用的是SDK build tools生成的debug key。这样signing的APP是没有办法发布的
生成自己的额key并且sign
方法1: key tool + jarsigner(available in JDK)
方法2: openssl + signapk

证书

证书全部在
“/build/target/product/security”
私有证书的类型
platform - a key for packages that are part of the core platform
shared - a key for things that are shared in the home/contacts process
media - a key for packages that are part of the media/download system
releasekey(testacy) - a generic key for packages that do noe otherwise specify a key
release key 用在商业ROM,testacy用在debug ROM
如果APP没有在Android.mk中定义 LOCAL_CERTIFICATE :=, 那么默认会被releasekey sign

Use Permission

如果一个APP想要使用系统特权,需要在AndroidManifest.xml中声明权限
APP 没有申请资源,访问受限的西苑会又SecurityException
Protection Level


Android Security: Attacks and Defenses is for anyone interested in learning about the strengths and weaknesses of the Android platform from a security perspective. Starting with an introduction to Android OS architecture and application programming, it will help readers get up to speed on the basics of the Android platform and its security issues. Explaining the Android security model and architecture, the book describes Android permissions, including Manifest permissions, to help readers analyze applications and understand permission requirements. It also rates the Android permissions based on security implications and covers JEB Decompiler. The authors describe how to write Android bots in JAVA and how to use reversing tools to decompile any Android application. They also cover the Android file system, including import directories and files, so readers can perform basic forensic analysis on file system and SD cards. The book includes access to a wealth of resources on its website: www.androidinsecurity.com. It explains how to crack SecureApp.apk discussed in the text and also makes the application available on its site. The book includes coverage of advanced topics such as reverse engineering and forensics, mobile device pen-testing methodology, malware analysis, secure coding, and hardening guidelines for Android. It also explains how to analyze security implications for Android mobile devices/applications and incorporate them into enterprise SDLC processes. The book’s site includes a resource section where readers can access downloads for applications, tools created by users, and sample applications created by the authors under the Resource section. Readers can easily download the files and use them in conjunction with the text, wherever needed. Visit www.androidinsecurity.com for more information.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值