转载自:http://intrepidusgroup.com/insight/2010/09/android-root-source-code-looking-at-the-c-skills/
Root Andoid现在主要是依靠两个漏洞:init进程的udev和adbd进程的setuid,下面是详细描述。之前的文章提到的rageagainstthecage这个程序利用的是setuid这个漏洞。
这两个漏洞的攻击程序源码在这里:/Files/super119/RageAgainstTheCage.zip
This is a bit of a follow up to our previous post, but we thought it would be interesting to dissect the source code of two of the recent Android root attacks: the udev exploit and the adb setuid exhaustion attack. The c-skillz site has posted the code for both exploits in the downloads available from their site. As they state, these attacks work basically against all Android phones released to date (and probably future ones if they run Android 2.1 or 2.2).
The udev exploit gained attention as one of the first attacks used against the Droid X, but was posted on the c-skillz site about a week before it made a great deal of noise on other blogs and forums. The download also included a README file which points out this attack mainly follows the exploit reported against udev and patched in 2009. Here’s a link to the CVE it points out: CVE-2009-1185.
Android does not have a separate udev executable and process link on standard Linux deployments. However, large portions of the udev code have been moved into the init daemon (init, like on a standard Linux system, is typically the first userland process and runs as root). In a simplistic and brief nutshell, udev offers dynamic management of devices; notably, it allows standard users to “hotplug” devices that may require root level access, such as a USB device. The kernel will pass a message to the userland udev demon, which will in turn act on the message. The issue is that versions of udev before 1.4.1 did not verify if these messages actually came from the kernel. Thus, a rogue application can submit a message to udev and have an action executed (which in the case of Android, is the init process running as root). While the kernel will need to be updated to send credentials with its messages to udev, the userland udev/init process is really where this vulnerability exists. I had originally referred to this as a kernel exploit, but that would technically be incorrect.
So here’s a quick overview of the exploid.c code: when the application runs, it copies itself to the sqlite_stmt_journals directory (remember, we’re not root yet, so we need a directory the “shell” user can write to). It will then send a NETLINK_KOBJECT_UEVENT message to run the copy of itself when the next hotplug event is triggered. The copied version of the executable then check if it is being run as root (this is our userland udev/init process) and if so, remounts the system partition (which is normally mounted as a read-only partition) and dumps a copy of /system/bin/sh as /system/bin/rootshell with the permissions of 04711 (executable with the user ID bit set so it always runs as root).
Now lets look at the adb setuid exhaustion attack. Compiled, this typically has the name “rageagainstthecage” and the code refers to it has “CVE-2010-EASY” in one comment, but whatever you call it, it’s a pretty smooth way of getting adbd (android’s debugging bridge daemon) to run as root. First the code will check that there is an NPROC setting. This is the maximum number of simultaneous processes which the system will allow. A quick “ulimit -a” once connected over adb should show you this setting for your device (this is set to 3301 processes on a Droid Incredible). The code will then try to find the process ID of the currently running adb daemon on the device. After that, the attack starts a loop to generated processes until it can no longer fork any more processes. Once the limit is hit, one process is killed off and the adb daemon process is restarted. As the code comment points out, this is a bit of a race at this point to make sure the adb can restart, but the number of processes stays maxed out. When the adb daemon starts up on an Android device, it is running as root. The code will later check if it should stay as root, or run in “secure” mode which drops its privileges to the “shell” account. This attack attemps to max out the process so that when the adb daemon attempts to call “setuid” in its code, the call will fail. The current adb code does not check if the setuid call was successful or not, so will happily keep running as root even if this fails.
- 大小: 54.6 KB
- 大小: 88.1 KB
分享到:
相关推荐
官方离线安装包,亲测可用。使用rpm -ivh [rpm完整包名] 进行安装
Udev 的配置文件位于 `/etc/udev/udev.conf`,其中设置了 udev 的一些基本参数,如 `udev_root`、`udev_rules` 和 `udev_log` 等。其中,`udev_root` 设置了 udev 的根目录,`udev_rules` 设置了规则文件的存放地址...
离线安装包,亲测可用
古德夫 从头开始开发Golang中的简单udev实现。 该库允许侦听和管理到用户空间Linux内核(自2.6.10版本开始)Netlink消息(即:NETLINK_KOBJECT_UEVENT)。 像一样,您将可以监视,显示和管理连接到系统的设备。如何...
android-udev-rules 描述 这些规则涉及并包括来自Archlinux和Github社区的许多建议。 安装 拱 在Arch上,只要按照的就足够了。 无需克隆此存储库。 其他发行 以下说明假定您使用的是带有systemd的GNU / Linux发行版 ...
本文将详细介绍udev的工作原理、配置方法以及一些实用的示例,旨在帮助Linux用户、设备驱动开发人员、设备测试人员和系统管理员等更好地理解和利用这一强大工具。 #### 二、udev概念解析 **1. 什么是udev?** ...
官方离线安装包,亲测可用。使用rpm -ivh [rpm完整包名] 进行安装
离线安装包,亲测可用
官方离线安装包,亲测可用。使用rpm -ivh [rpm完整包名] 进行安装
udev 的主要目标是提供一种动态的 `/dev` 目录管理和持久化的设备命名机制。相比 devfs,udev 提供了更多的灵活性和可定制性。它可以: - 动态创建和删除设备节点。 - 支持持久化的设备命名。 - 允许用户根据设备...
用udev的升级包,可以防止利用udev的漏洞非法取得root权限。
为了降低这种额外开销,本文档将重点介绍如何在Linux 2.6环境中利用两项内置工具——`udev`与`device-mapper`来提供I/O多路径支持及设备命名持久化功能。 #### Udev概述 `udev`是Linux内核的一部分,负责管理系统...
基于pyudev的ceph-disk实用程序端口,使用udev数据库对块设备进行分类,并查询各种ceph操作(例如准备和激活)的属性。 DMBlockDev类和其他解决方法可提供对Linux DM多路径的支持。 方法: 当前的ceph-disk通过...
離線安裝google chrome的deb文件 包括所依賴的deb packages
联上互联网,直接运行即可。
官方离线安装包,亲测可用
官方离线安装包,亲测可用。使用rpm -ivh [rpm完整包名] 进行安装
官方离线安装包,亲测可用。使用rpm -ivh [rpm完整包名] 进行安装
官方离线安装包,亲测可用。使用rpm -ivh [rpm完整包名] 进行安装
官方离线安装包,测试可用。使用rpm -ivh [rpm完整包名] 进行安装