http://commondatastorage.googleapis.com/io2012/presentations/live%20to%20website/107.pdf

看看google的攻城师对android安全的认识:

1、敏感数据通过权限保护,这些权限都会由权贵把持,要想使用就得申请。

2、码农的安全意识很重要

码农很努力了,可惜由于缺乏安全意识,可能导致数据泄露:
- Storing personal data in a world-readable  file 全局读文件。。。
- Exporting an unprotected content provider  组件导出,人人都可以访问。组件导出,容易被人滥用,造成权限代理攻击。
- Logging personal data in logcat logs           喜欢log。。
还要考虑邪恶的外部环境啊
- Insecure wireless networks  传输容易被窃取,最近连ssl都被人攻破了
- Lost and stolen devices 丢手机

3、用户证书

随便android 没有ios那样有严格的开发者证书,自己随便玩证书。但也要严肃点。

毕竟证书承载了不少内容。

1)、同样的签名可以共用UID

2)、软件升级的问题。

因此,为了安全起见,程序猿也要保护好自己的私钥!!!要不然被人窃取了,他可能会窃取你的应用信息哦。

4、android安全架构

android的安全架构主要有这样几部分:

1)、linux DAC机制,也就是RWX,还有些特殊的组ID控制,比如internet

比如open()都是kernel通过uid控制

2)、组件认证,通常是被调用的一方进行权限控制,比如调用系统能力可能有System_server鉴权,如果和另一个应用交互,那就由另一个应用鉴权。其实就是IPC认证

5、沙箱

应用都是存在于自己的沙箱。

但也要考虑2个问题:

1)、反射的问题,现在很多hook的技术最后都是通过反射和java层对接。很邪恶

2)、native code不是法外之地,无法绕开permission机制,但可以修改进程空间,也就是动态修改应用状态。

另外进程间通信也有一些保护手段:

Intent filters---过滤而已
Permissions---就是摆设
Signatures-----真的有价值。共享签名的价值。

6、攻击入口

7、保护组件

Don't export app components unless you want other apps on the system to interact with your app

manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.example.awesome">
    <application android:label="@string/app_name">
        …
        <service android:name=".ServiceExample"
                 android:exported="false">
            <intent-filter>…</intent-filter>
        </service>
        …
    </application>
</manifest>

万不得已,不要到处。实在要到处,请下申请权限,而后共享签名控制(下面的最后一种)!!血泪教训

定义权限只是万里长征第一步,你定义了,别人申请即可,关键得签名控制!

protectionLevel="normal"  – A lower-risk permission that gives requesting applications
access to isolated application-level features, with minimal risk to other applications, the
system, or the user. This is the default protection level.            悄悄地干活,啥都不提示

protectionLevel="dangerous"   – A higher-risk permission that would give a requesting
application access to private user data or control over the device that can negatively impact
the user.                 就是提示,有啥用
protectionLevel="signature"  – Can be used to limit access to components to only apps
signed with the same certificate.             真正有价值的!

上述的权限控制都是你定义了,系统帮你控制验证,你自己也可以的,要自信点。

其实很多种方法(下面列的太少了)
- Context.registerReceiver(…)  can be used to register a BroadcastReceiver dynamically
• There is a version of  registerReceiver(…)  which can be used to specify permission the broadcaster must hold for your dynamically-registered receiver to be invoked.
- Context.checkCallingPermission(…) and  Context.enforceCallingPermission(…) can be  自己验证
used in your source code to make sure the calling app holds the appropriate permission.
 This can be used to implement  fine-grained permissions if needed.

• Avoid the  confused deputy problem:权限代理的问题,我申请了一个专利,也有学术界的论文提出解决防范,很简单就是一个 ∩!!!

下图说了,不申请权限要玩没门!!但申请了权限容易被一些屌丝杀软发现啊!!!肿么办!!


- If your app is using its granted permissions to respond to another app, check that the calling app has that permission as well

那就找有这些权限的,同时有漏洞的。。就是提供接口的。。。

8、注意细节啊

1)debug

android:debuggable   不要开启啊!!容易被人***
- Disabled by default
- Never leave this enabled in release code!
- Allows a user to debug your app - even without source code
- Users with physical access can run code as your app and access your app's data  开启你的隐私之旅。。。run-as有不懂的吗?

jlarimer-macbookair:~ jlarimer$ adb shell
shell@android:/ $ run-as com.example.awesomeness sh
shell@android:/data/data/com.example.awesomeness $ id
uid=10060(app_60) gid=10060(app_60)
shell@android:/data/data/com.example.awesomeness $ ls files/
secret_data.txt
shell@android:/data/data/com.example.awesomeness $ cat files/secret_data.txt
SECRETS!

2)、数据

Use MODE_PRIVATE for data files, shared preferences, and databases  保护自己的隐私,别全局读写啊
• openFileOutput(),   openSharedPreferences(),  and  openOrCreateDatabase() create  files in your app's
private data directory
External storage (sdcard) is shared storage     sd卡没有权限控制,都可以读取,要存储三思啊,不行就加密啊!现在有很多开源加密库!

encryptedMessage = Encrypt(K, "Login-OK=0")
AlteredMessage = EncryptedMessage … XOR {…,0x31}
Plaintext = Decrypt(K, AlteredMessage) = "Login-OK=1"

好码农

FileOutputStream fos = openFileOutput("private_data.txt", Context.MODE_PRIVATE);
SharedPreferences prefs = getSharedPreferences("data", Context.MODE_PRIVATE);

女神对任何人都是开放的!
FileOutputStream fos = openFileOutput("private_data.txt", Context.MODE_WORLD_WRITEABL
SharedPreferences prefs = getSharedPreferences("data", Context.MODE_WORLD_READABLE);

sd卡里面也不要存储程序哦:

Don't store code libraries that are world writable or on external storage 容易被替换,除非你校验
- Don't store paths to code libraries in files that are world writable or on external storage  路径也一样
- Don't process data from writable files in native code - memory corruption vulnerabilities could allow apps to run arbitrary code with your app's ID  C语言爱溢出啊!!
• Don't store personal or protected data on external storage without user consent

9、无线链路的安全

现在屌丝太多,就喜欢在星巴克搞WIFI Hack。

很多中间人攻击手段!

如何防护:

- HTTPS and SSL can protect against MitM attacks and prevent casual snooping  用https和ssl啊。但现在ssl在码农实现时存在太多的问题,详情看老王的书吧!比如Certificate pinning
-比如
URL url = new URL("https://www.google.com/");
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();

友情提示:

Use cryptographic signing for any DEX or native code libraries that you load dynamically  这都是邪恶的软件才干的!远程下载APK、dex动态执行的
- Better yet, don't run code from the network

10、webview

web的安全话题就大了。。。xss.....

webview 中JavaScript is disabled by default。缺省是禁止的

addJavascriptInterface() is dangerous 你可以启用的。

- Avoid exposing protected or personal data to a JavaScript interface   既然放开了,就很难保证了,js和java就可以通信了,同时同源机制会被破坏。
- Server or network could be compromised, you can't trust the code
- If you do use it, ensure that you're using HTTPS for the WebView

10、友情提示

不要滥用职权,人民不会宽恕的!!申请最小的权利即可!

Permissions aren't required if you launch an activity that has the permission 系统已有task了,就别再申请权限了,直接调用这些应用即可!google为啥不直接删除那些直接发短信的api。谁能告诉我!!!
- Getting a picture from the camera

// create Intent to take a picture and return control to the calling application没权限照样干!!
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
// create a file to save the image
fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE);
// set the image file name
intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
// start the image capture Intent
startActivityForResult(intent, MY_REQUEST_CO

- Sending an SMS through the SMS app  没权照样发!!

Uri smsNumber = Uri.parse("sms:5551212");
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(smsNumber);
intent.putExtra(Intent.EXTRA_TEXT, "hey there!");
startActivity(intent);

Permissions can be temporarily granted to apps by content providers 
- Letting the user pick a contact to share with your app           无需申请READ_CONTACTS啊!!

Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType(Phone.CONTENT_ITEM_TYPE);
startActivityForResult(intent, MY_REQUEST_CODE);
void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (data != null) {
        Uri uri = data.getData();
        if (uri != null) {
            try {
                Cursor c = getContentResolver().query(uri, new String[] {
                    Contacts.DISPLAY_NAME, Phone.NUMBER}, null, null, null);

11、trick

Need a unique identifier?   唯一标示终端靠啥!老衲找了很多年,没找到!!下面的这些就更不靠谱了!
- TelephonyManager.getDeviceId() requires  READ_PHONE_STATE  permission
- Settings.Secure.ANDROID_ID doesn't require a permission, but still not perfect
To identify an installation of your app
- Generate a UUID when your app starts and store it in shared preferences:
- String id = UUID.randomUUID().toString();
- Use Android Backup Service to save the shared preferences to the cloud
- See: https://developers.google.com/android/backup/

12、设备管理

设备管理本来是为企业管理MDM而生,可竟然被一些宵小用来作恶!!

最近史上最牛的恶意软件也用了设备管理,而后利用一个注册漏洞,竟然藏起来了。。让用户无法卸载这儿妖孽!!!

企业管理器激活后有很多功能,可以设置pin码复杂度,锁屏,擦出数据等等,ios的这部分就更丰富了!!

大家可以自己体验一下,激活后可以去激活!有个漏洞就是没有显示在激活列表。不去激活的话,应用是无法卸载的!于是成了邪恶!

最后

Use Android Lint  希望google 更加努力。让程序猿更多的时间和女神在一起!不要纠结在bug上!但现在的功能太小儿科!

这个功能很有商机!!有投资者看到了请与我联系。我做了应用漏洞检测工具!

Google安全团队对Android安全的认识的更多相关文章

  1. Google+ 团队的 Android UI 测试

    https://github.com/bboyfeiyu/android-tech-frontier/tree/master/android-blog/Google%2B%20%E5%9B%A2%E9 ...

  2. 如何使用Google Map API开发Android地图应用

    两年前开发过的GoogleMap已经大变样,最近有项目要用到GoogleMap,重新来配置Android GoogleMap开发环境,还真是踩了不少坑. 一.下载Android SDK Manager ...

  3. Google用户登录界面 Android实现

    实验效果: 项目目录: Java代码(放在Src文件下) package com.bn.chap9.login; import java.io.BufferedReader; import java. ...

  4. Google 地图 API for Android

    原文:Introduction to Google Maps API for Android 作者:Eunice Obugyei 译者:kmyhy 从健康类 app Runkeeper 到游戏 app ...

  5. Integrating Google Sign-In into Your Android App

    To integrate Google Sign-In into your Android app, configure Google Sign-In and add a button to your ...

  6. Android Google 地图 API for Android

    从健康类 app Runkeeper 到游戏 app 精灵宝可梦,位置服务对现代 app 来说越来越重要. 在本文中,我们将创建一个 app,名字就叫做 City Guide.这个 app 允许用户搜 ...

  7. Google I/O 2021 Android精华内容

    Google I/O 2021结束了, 都有什么精彩内容呢? Android部分的Playlist附上: Android & Play at Google I/O 2021 Developer ...

  8. ionic项目使用Google FCM插件和Google maps插件打包android报错冲突问题

    这段时间在调FCM推送服务的插件 ,原本以为去年调通过,应该很容易,没想到还是出问题了.现将问题及解决方法整理如下,仅供参考: 先看打包报错截图:         详细报错信息:Please fix ...

  9. comlink 是来自google chrome 团队的简化webwokers 开发的类库

    comlink 可以帮助我们简单webworkers 的开发,同时很小(1.1kb),具体使用我们可以看下面 一张图  说明 comlink 使用起来也比较方便,官方也提供了完整的api 文档 参考资 ...

随机推荐

  1. AngularJs + ASP.NET MVC

    [AngularJs + ASP.NET MVC]使用AntularJs快速建立ASP.NET MVC SPA網站 這幾天接觸到了AngularJs的美麗,讓饅頭有點躍躍欲試使用AngularJs來做 ...

  2. C++多线程分析

    我们开始谈论的线程之前先看看这些线载波前-进程. 进程,它是一个正在执行的程序的实例.是一个程序在其自身的地址空间的一次执行活动.进程是资源申请.调度.和独立执行的基本单位.进程有两部分组成: 1.操 ...

  3. 在 VS2013的ASPNET站点开发中用 xheditor v1.1.13 作为HTML编辑器

    要用vs2013开发一个博客站点,.net   framework  4,须要一个HTML编辑器作为写文章的工具.经多方试用,排除了dotnettextbox.kceditor.认为xheditor ...

  4. php连接sql server 2008数据库

    原文:php连接sql server 2008数据库 关于php连接sql server 2008的问题,2000的版本可以直接通过php中的配置文件修改,2005以上的版本就不行了,需要使用微软公司 ...

  5. 修改MvcPager分页控件以适用Bootstrap 效果(含英文版,可下载)

    软件开发分页效果必不可少,对于Asp.Net MVC 而言,MvcPager 是个不错的选择.请访问http://www.webdiyer.com/mvcpager/ 由于自带的分页样式不能和项目整体 ...

  6. [WebGL入门]十六,绘制多个模型

    注意:文章翻译http://wgld.org/.原作者杉本雅広(doxas),文章中假设有我的额外说明,我会加上[lufy:],另外.鄙人webgl研究还不够深入.一些专业词语.假设翻译有误.欢迎大家 ...

  7. nagios 安装和配置(含有nrpe结束)所有 (两)

    二.ndoutils 安装: 1.mysql安装(若未安装) #apt-get install mysql-servermysql-client 2.DBI安装(若未安装) #cd /usr/loca ...

  8. Linux下查看MySQL的安装路径

    Linux下查看mysql.apache是否安装,并卸载. 指令 ps -ef|grep mysql 得出结果 root               ?        :: /bin/sh /usr/ ...

  9. Windows下MYSQL自动备份批处理

    windows下MYSQL自动备份批处理 2011-05-04 09:16:45|  分类: mysql|举报|字号 订阅     按系统时间进行备份 注意mysql安装路径中如果有空格.就要把,.b ...

  10. [翻译]用Dart塑造Android未来

    明天回家,今天下午瞅时间翻译了Cyril Mottier的另外一篇有关Android前景的文章. 原谅地址是:http://cyrilmottier.com/2014/06/12/shaping-th ...