Android Device Rooting Lab

Total Page:16

File Type:pdf, Size:1020Kb

Android Device Rooting Lab SEED Labs 1 Android Device Rooting Lab Copyright c 2015 - 2016 Wenliang Du, Syracuse University. The development of this document was partially funded by the National Science Foundation under Award No. 1303306 and 1318814. This work is licensed under a Creative Commons Attribution-NonCommercial- ShareAlike 4.0 International License. A human-readable summary of (and not a substitute for) the license is the following: You are free to copy and redistribute the material in any medium or format. You must give appropriate credit. If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original. You may not use the material for commercial purposes. 1 Overview Android devices do not allow their owners to have the root privilege on the device. This is fine for normal customers, but for users who want to make deep customizations on their devices, this is too restrictive. There are ways to overcome these restrictions, most of which require the root privilege on the device. The process of gaining the root device on Android devices is called rooting. Being able to root Android devices is a very useful skill for security experts. The objective of this lab is two-fold. First, through this lab, students will get familiar with the process of device rooting and understand why certain steps are needed. Many people can root Android devices, but not many people fully understand why things have to be done in a particular way. Second, the entire rooting mechanism involves many pieces of knowledge about the Android system and operating system in general, so it serves as a great vehicle for students to gain such in-depth system knowledge. In this lab, we will ask students to develop a complete rooting package from scratch, and demonstrate how to use the package to root the Android VM provided by us. 2 Background Knowledge 2.1 Background Knowledge about Rooting The purpose of rooting an Android device is to gain the root privilege inside the Android OS. There are many reasons why people want to do that. For example, Android devices often come with many pre-installed system apps that are useless most of the time, but they take storage space, RAM, system resources, and drain device battery. These useless apps are generally known as bloatware; they are installed in protected places, and only the root user (or other privileged user) can remove them. Although the device is owned by a user, the user is not allowed to run code using the root privilege. Users can only get the root privilege if the device is rooted. In general, rooting allows users to customize their phones, removing restrictions, adding new features, and making changes to the system. There are several approaches to root an Android device, and we will discuss them in more details in this lab. Figure 1 provides a summary of these approaches. Modifying Android from inside. The first rooting approach is doing it from inside Android. For an un- rooted device, everything that the user runs is running with a normal user ID (not root). Therefore, rooting from inside Android means that the user has to gain the root privilege as a normal user. Obviously, this is impossible for a perfectly implemented operating system. However, the chances are that Android may not be perfectly implemented, so there might exist vulnerabilities in the system. If these vulnerabilities are inside the kernel or daemons running with the root privilege, users can exploit these vulnerabilities to gain the root privilege. This is one of the techniques to root Android devices. SEED Labs 2 In the past, there were many rooting exploits, such as RageAgainstTheCage, which took advantage of RLIMIT NPROC max, the value specifying how many processes a given UID can run. This exploit first uses "adb shell" to run a shell on the device via the adb daemon. The UID of the shell will be 2000. The exploit then forks new processes until the number of processes have reached the limit and the fork call will fail. At this point, the exploit kills the adbd daemon, and then reconnect to it using "adb shell". This causes the system to restart the adb daemon. When adb is started, it always has the root privilege, but it will drop the privilege to UID 2000 using setuid(2000). Unfortunately, the UID 2000 has already used up its process quota, so the call will fail. Unfortunately, the adb daemon fails to handle the failure correctly: instead of exiting, it keeps running, while retaining the root privilege. As results, the "adb shell" command will give users a root shell. This vulnerability has already been fixed after Android 2.2. You need to Modify Android OS because Stock Android OS doesn’t provide root Rooting Overview privilege to the user out of the box Unlocked bootloader allows Modify Android OS you to run your own OS by flashing the image file to specific Android Partition. Before Booting into After Booting into Android Android OS OS Find Vulnerability in Unlock Bootloader Stock Recovery only Android OS that escalate allows you to apply OTA User Privilege Change the entire Android updates authorized by System Image Update Android System manufacturer. We need Image by applying OTA to replace Stock Recovery with Custom Recovery to Gives root shell (Over The-Air) updates apply our own OTA Unpack Android System updates which bypasses Image (system.img) or get signature verification it from manufacturer or Replace Stock Recovery Getting root shell is trusted third party provider breakthrough, you can do with Custom Recovery whatever with root shell to Android file system Modify system image by changing build type or by adding some SUID su binary Custom Recovery will run update-binary from the OTA package to apply Basically update- Commercial Android devices uses User updates build which disallows root access via Gives root shell binary is a binary file shell. But It can be turned into the that runs updater- userdebug or engineering build which script that guides recovery to install files gives root access through the shell by Gives root shell setting ro.secure = 0. from OTA package to main Android OS to achieve rooting. Figure 1: Rooting Android Devices Modifying Android from outside. Since Android’s access control prevents a normal user from modifying the part of the system that is only modifiable by the root, doing it inside Android is going to subject to the access control. However, if we can do it from outside, we are not subject to Android’s access control any more. This leads to the second approach, which is to directly modify Android’s system files from outside. Assume that another operating system is installed on your Android device. This means that the device SEED Labs 3 has a dual-boot configuration, allowing you to boot into any of these two operating systems when the device powers on. If we boot into this second operating system, and become the root for this OS, we can mount the partition used by the Android system. Once this partition is mounted, we can access all the files stored inside the partition. Because Android is not running, its access control has no use. Therefore, we can make arbitrary changes to its files. For example, we can place some programs in the system, and modify Android’s initialization scripts, and ask Android to run our programs as a root during its initialization process. The good news is that most Android devices do have the second operating system installed, and it is called recovery OS. As the name indicates, it is meant for recovery purposes, but it is mostly used for updat- ing operating system. The bad news is that this operating system also has access controls, preventing users from running arbitrary programs or commands. Recovery OS is typically placed on devices by vendors, who use the OS to update Android, but not wanting users to make arbitrary updates. To enforce that, re- covery OSes do not give users a shell prompt, preventing users from running arbitrary commands. Instead, they take a package provided from outside (either from users or downloaded from the Internet); the package contains the commands and files needed for updating the Android OS. This mechanism is widely used for OS update, and it is called Over-The-Air (OTA) update. The package is called OTA package, which has a standard file structure that we will talk about later. Most recovery OSes only accept the packages made by the vendors to ensure that any update to the Android OS is approved by the vendors. This is enforced using digital signatures, i.e., the package needs to be signed by vendors, or it will not be accepted by the recovery OS. This protection becomes a roadblock for rooting, because the package that we use for rooting purposes will not come from the vendor of the device. We need to find ways to bypass this access control. Reinstall recovery OS. Instead of bypassing the access controls of the recovery OS, the easiest way is to replace the entire stock recovery OS with another recovery OS that does not have such access controls. This new recovery OS, called custom recovery OS, will not include the signature verification part, so we can provide any OTA packages to the recovery OS. This will allow us to make arbitrary changes to the Android partition. Here is another bad news. There is another access control that prevents us from replacing the stock recovery OS, and this time it is the bootloader. Bootloader is a low level code that loads an operating system or some other system software for the computer after the computer is powered on.
Recommended publications
  • Android (Operating System) 1 Android (Operating System)
    Android (operating system) 1 Android (operating system) Android Home screen displayed by Samsung Nexus S with Google running Android 2.3 "Gingerbread" Company / developer Google Inc., Open Handset Alliance [1] Programmed in C (core), C++ (some third-party libraries), Java (UI) Working state Current [2] Source model Free and open source software (3.0 is currently in closed development) Initial release 21 October 2008 Latest stable release Tablets: [3] 3.0.1 (Honeycomb) Phones: [3] 2.3.3 (Gingerbread) / 24 February 2011 [4] Supported platforms ARM, MIPS, Power, x86 Kernel type Monolithic, modified Linux kernel Default user interface Graphical [5] License Apache 2.0, Linux kernel patches are under GPL v2 Official website [www.android.com www.android.com] Android is a software stack for mobile devices that includes an operating system, middleware and key applications.[6] [7] Google Inc. purchased the initial developer of the software, Android Inc., in 2005.[8] Android's mobile operating system is based on a modified version of the Linux kernel. Google and other members of the Open Handset Alliance collaborated on Android's development and release.[9] [10] The Android Open Source Project (AOSP) is tasked with the maintenance and further development of Android.[11] The Android operating system is the world's best-selling Smartphone platform.[12] [13] Android has a large community of developers writing applications ("apps") that extend the functionality of the devices. There are currently over 150,000 apps available for Android.[14] [15] Android Market is the online app store run by Google, though apps can also be downloaded from third-party sites.
    [Show full text]
  • 2019 China Military Power Report
    OFFICE OF THE SECRETARY OF DEFENSE Annual Report to Congress: Military and Security Developments Involving the People’s Republic of China ANNUAL REPORT TO CONGRESS Military and Security Developments Involving the People’s Republic of China 2019 Office of the Secretary of Defense Preparation of this report cost the Department of Defense a total of approximately $181,000 in Fiscal Years 2018-2019. This includes $12,000 in expenses and $169,000 in DoD labor. Generated on 2019May02 RefID: E-1F4B924 OFFICE OF THE SECRETARY OF DEFENSE Annual Report to Congress: Military and Security Developments Involving the People’s Republic of China OFFICE OF THE SECRETARY OF DEFENSE Annual Report to Congress: Military and Security Developments Involving the People’s Republic of China Annual Report to Congress: Military and Security Developments Involving the People’s Republic of China 2019 A Report to Congress Pursuant to the National Defense Authorization Act for Fiscal Year 2000, as Amended Section 1260, “Annual Report on Military and Security Developments Involving the People’s Republic of China,” of the National Defense Authorization Act for Fiscal Year 2019, Public Law 115-232, which amends the National Defense Authorization Act for Fiscal Year 2000, Section 1202, Public Law 106-65, provides that the Secretary of Defense shall submit a report “in both classified and unclassified form, on military and security developments involving the People’s Republic of China. The report shall address the current and probable future course of military-technological development of the People’s Liberation Army and the tenets and probable development of Chinese security strategy and military strategy, and of the military organizations and operational concepts supporting such development over the next 20 years.
    [Show full text]
  • Ah! Universal Android Rooting Is Back
    AH! UNIVERSAL ANDROID ROOTING IS BACK Wen `Memeda` Xu @K33nTeam ABOUT ME Wen Xu a.k.a Memeda @antlr7 • Security research intern at KeenTeam • Android Roo6ng • Soware exploita6on • Senior student at Shanghai Jiao Tong University • Member of LoCCS • Vice-captain of CTF team 0ops • Rank 2rd in the world on CTFTIME AGENDA • Present Situa6on of Android Roo6ng • Awesome Bug (CVE-2015-3636) • Fuzzing • Analysis • Awesome Exploita6on Techniques • Object Re-filling in kernel UAF • Kernel Code Execu@on • Targe@ng 64bit Devices • Future PART I Present Situation PRESENT SITUATION Root for what? • Goal • uid=0(root) gid=0(root) groups=0(root) • Kernel arbitrary read/write • Cleaning • SELinux • … PRESENT SITUATION • SoC (Driver) • Missing argument sani6Za6on (ioctl/mmap) • Qualcomm camera drivers bug CVE-2014-4321, CVE-2014-4324 CVE-2014-0975, CVE-2014-0976 • TOCTTOU • Direct dereference in user space CVE-2014-8299 • Chip by chip A BIG DEAL • Universal root soluon • Universally applied bug • Confronng Linux kernel • Universally applied exploita6on techniques • One exploit for hundreds of thousands of devices • Adaptability (Hardcode) • User-friendly (Stability) • COMING BACK AGAIN! PART II Bug Hunting FUZZING Open source kernel syscall fuzzer • Trinity • hps://github.com/kernelslacker/trinity • Scalability • Ported to ARM Linux FUZZING Let’s take a look at our log when we wake up ;) • Crical paging fault at 0x200200?!! SK: PING SOCKET OBJECT IN KERNEL user_sock_fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_ICMP); 2 3 1 LIST_POISON2 == 0X200200 ping_unhash
    [Show full text]
  • Satisfy That Android Sweet Tooth
    IBM Security Thought Leadership White Paper Satisfy that Android sweet tooth Do Android’s dessert-named updates improve device and data security enough to work for the enterprise? Satisfy that Android sweet tooth Android is ready for the enterprise. Is your continues to grow. The wide variety of Android devices enterprise ready for Android? available means that they are often a good fit for corporate- owned device programs. For example, many field-based employees need rugged Android devices built to stand up to Introduction dust, shock, vibration, rain, humidity, solar radiation, altitude, Android has long ruled the consumer market. Now, the latest and temperature extremes. Others want Android devices with security advancements from Google and device manufacturers, data capture features ideal for inventory control and warehouse and support for Android by leading EMM solution providers, operations. are expanding its presence in the enterprise. To help ensure security and compliance with industry standards and This growth comes with some unintended consequences, as government regulations, enterprises need a way to protect well as important considerations for IT. Companies are and manage the wide range of available devices, versions, and allowing employees to use their own preferred or industry- idiosyncrasies of the world’s most popular mobile operating specific devices, but IT must address the very real concerns of system. protecting corporate data and providing standardized management. It’s not a one-solution-fits-all situation. IT needs to examine its device and application landscape and decide what security and The most popular mobile platform in the world also has a management capabilities are essential in a customized volatile security record;2 however, Android’s recent, sweetly- enterprise mobility strategy.
    [Show full text]
  • On Root Detection Strategies for Android Devices
    On Root Detection Strategies for Android Devices Raphael Bialon Department of Computer Science, Heinrich-Heine-University Düsseldorf, Germany [email protected] Abstract—The Android operating system runs on the majority they are executed on and the confidentiality of communication of smartphones nowadays. Its success is driven by its availability channels used. to a variety of smartphone hardware vendors on the one hand, This can directly contradict with users enjoying the cus- and the customization possibilities given to its users on the other hand. While other big smartphone operating systems restrict user tomizability of their devices, as one popular method to enable configuration to a given set of functionality, Android users can broad control over ones’ device is the act of gaining elevated leverage the whole potential of their devices. This high degree privileges through a process called rooting. of customization enabled by a process called rooting, where the As our main contribution we propose a method for remote users escalate their privileges to those of the operating system, rooting detection in wireless tethering networks provided by introduces security, data integrity and privacy concerns. Several rooting detection mechanisms for Android devices already exist, an Android device. Such networks define a special case of aimed at different levels of detection. This paper introduces wireless networks, as all communication is routed over the further strategies derived from the Linux ecosystem and outlines device offering the hotspot, and can thus be manipulated by their usage on the Android platform. In addition, we present said device. One example for extensive tethering hotspot usage a novel remote rooting detection approach aimed at trust and and a matching use case for this remote rooting detection is integrity checks between devices in wireless networks.
    [Show full text]
  • Agchain: a Blockchain-Based Gateway for Permanent, Distributed, and Secure App Delegation from Existing Mobile App Markets
    AGChain: A Blockchain-based Gateway for Permanent, Distributed, and Secure App Delegation from Existing Mobile App Markets Mengjie Chen Daoyuan Wu∗ The Chinese University of Hong Kong The Chinese University of Hong Kong [email protected] [email protected] Xiao Yi Jianliang Xu The Chinese University of Hong Kong Hong Kong Baptist University [email protected] [email protected] ABSTRACT policies and delist the apps as they wish. For example, Mobile app markets are emerging with the popularity of 13.7% (1,146) of the 8,359 popular apps we measured smartphones. However, they fall short in several aspects, in late 2018 have been delisted (by either the market including no transparent app listing, no world-wide app ac- or developers themselves) after one year in late 2019. cess, and even insecure app downloading. To address these P2: No world-wide and even censored access. Secondly, problems, we propose a novel blockchain-based gateway, many apps on Google Play and Apple Store are avail- AGChain, to bridge end users and app markets so that ex- able only in certain countries. Moreover, Google Play isting app markets could still provide services while users itself is being censored in some regions, causing no enjoy permanent, distributed, and secure app delegation from easy app access for the users in those affected areas. AGChain. To this end, we identify two previously underesti- P3: No enough security guarantee. Thirdly, we find that a mated challenges and propose mechanisms to significantly significant portion of third-party Android app markets reduce gas costs in our smart contract and make IPFS (Inter- do not provide secure app downloading.
    [Show full text]
  • Android Malware Detection Via (Somewhat) Robust Irreversible Feature Transformations
    This article has been accepted for publication in a future issue of this journal, but has not been fully edited. Content may change prior to final publication. Citation information: DOI 10.1109/TIFS.2020.2975932, IEEE Transactions on Information Forensics and Security IEEE TRANSACTIONS ON INFORMATION FORENSICS AND SECURITY 1 Android Malware Detection via (Somewhat) Robust Irreversible Feature Transformations Qian Han1, V.S. Subrahmanian1 and Yanhai Xiong1 1Department of Computer Science and the Institute for Security Technology and Society Dartmouth College, Hanover, NH 03755, USA As the most widely used OS on earth, Android is heavily targeted by malicious hackers. Though much work has been done on detecting Android malware, hackers are becoming increasingly adept at evading ML classifiers. We develop FARM, a Feature transformation based AndRoid Malware detector. FARM takes well-known features for Android malware detection and introduces three new types of feature transformations that transform these features irreversibly into a new feature domain. We first test FARM on 6 Android classification problems separating goodware and “other malware” from 3 classes of malware: rooting malware, spyware, and banking trojans. We show that FARM beats standard baselines when no attacks occur. Though we cannot guess all possible attacks that an adversary might use, we propose three realistic attacks on FARM and show that FARM is very robust to these attacks in all classification problems. Additionally, FARM has automatically identified two malware samples which were not previously classified as rooting malware by any of the 61 anti-viruses on VirusTotal. These samples were reported to Google’s Android Security Team who subsequently confirmed our findings.
    [Show full text]
  • Market and Development Trends, Critical Evaluation of Proprietary Markets (Apple, Google, Microsoft, Nokia)
    Market and Development Trends, Critical Evaluation of Proprietary Markets (Apple, Google, Microsoft, Nokia) Institution Vienna University of Economics and Business Institute for Management Information Systems Course IS Projektseminar, 4289 ao.Univ.Prof. Mag. Dr. Rony G. Flatscher Author Michael Fellner, 1990-12-24 h1051887 2014-06-20 Contents 1 Introduction ............................................................................................................... 1 2 Smartphone Market ................................................................................................ 2 2.1 Hardware Environment ...................................................................................................... 2 2.1.1 Smartphone Producers ..................................................................................................... 2 2.1.2 Mobile Network Operators ............................................................................................... 5 2.2 Mobile Operating Systems ............................................................................................... 8 2.2.1 OS Development Companies ........................................................................................... 8 2.2.2 Android, iOS, Windows Phone ...................................................................................... 10 2.2.3 Alternatives ....................................................................................................................... 11 3 Proprietary Licensing .........................................................................................
    [Show full text]
  • MIDDLETOWN Treats
    Compulsory Busing Rejected by Goy* Hughei SEE STORY BELOW Weather Clouding up this afternoon, high HOME in mid S6s. Chanc* of few show- THEDAW tri tonight, low in mid 4fc. Be- Red Bank, Freehold 7 coming fair tomorrow, Ugh In FINAL •' f Hi. Sunday's oatlock, mostly sun- ( Long Bwmdr J ny and MONMOUTH COUNTY'S HOME NEWSPAPER FOR 89 YEARS DIAL 741-0010 .-..':. i VOL 90, NO. 87 RED BANK, N. J., FRIDAY, OCTOBER 27, 1967 10c PER COPY PAGE \ Garrison Regrets On Mideast Peace Proposal Yule Gifts Letter U.N. Accord Nearing FREEHOLD — Monmouth County Super- "As a member of the Board of Free- intendent of Schools Earl B. Garrison yes- holders," he concluded, "I humbly apologize UNITED NATIONS, N. Y. or withdrawal of Israeli troops council. He based this on the be- to 90 along the 107-mile Suez Ca- in Increasing the U.N. observer terday mailed out apologies to county busi- to our businessmen and the public." (AP) — A drafting team of the rom land they seized from lief that the Soviet Union, France nal and equip them with boats force if the Egyptian government also agrees. nessmen concerning a misinterpretation in Freeholder Director Joseph C. Irwin also U.N. Security Council was re- Egypt, Jordan and Syria in the and Bulgaria would go along with and helicopters. an earlier letter1, which solicited gifts for a said he did not favor this, adding that he ported near agreement today on jne war. the group thus making- a major- Although Tuesday's artillery One. Israeli source at the United 'county employes' annual Christmas party.
    [Show full text]
  • Kindle Fire Manual Root 6.3.2
    Kindle Fire Manual Root 6.3.2 How to root any Kindle Fire HDX on any version or any Android device tablet or easy to go. Keep your Amazon Kindle Fire working in the best of its abilities with the latest Manually download a Kindle Fire software update and transfer it to your Kindle. 2 Rooting Kindle Fire is very strict on the system version. This rooting tutorial is for the latest 6.3.x (6.3.1 and 6.3.2). It may be not suitable for the older version. Cyanogen Team * AOKP Team * Paranoid Android * SlimRoms * RootBox 5887 · 5900mAh · 6*ART · 6.0.3.3 · 6.0.x · 6.09.401.11 · 6.11.841.9 · 6.3.2 · 6.3.3 · 6.4. Kindle · Kindlekindlefire · Kindly · King · Kingzone · KitKat · kitkate · KK4.4.4 Mania · Mansion · manta · mantra · Manual · Manually · manufacturer · many. Sup this is how to root amazon kindle fire 1st gen its easy requires no computer just your. There is a table in the back of the manual (which is not provided in the box although it is available on line, but since it is apparently compiled by The available firmware file was version 6.3.2. Make sure the stick is formatted FAT32 and the update file is in the root directory. Amazon Kindle Fire HDX 8.9 Tablet Review. Kindle Fire Manual Root 6.3.2 Read/Download The primary reason that I bought Amazon Kindle Fire ~ the ability to install custom Do I just follow these instructions in the video? And all Is it possible to root my 6.3.2 version…… because I can only find insrtuctions for 6.3 or 6.3.1 versions.
    [Show full text]
  • Security Issues in Android Custom Roms
    Security Issues in Android Custom ROMs HTML Version Anant Shrivastava http://anantshri.info Contents Abstract................................................................................................................................................... 3 Introduction to Android ........................................................................................................................... 3 What is Android ROM .............................................................................................................................. 3 Types of ROM .......................................................................................................................................... 4 Advantages of custom ROM’s .................................................................................................................. 5 How to obtain custom ROM’s .................................................................................................................. 5 How are they created .............................................................................................................................. 5 Why do we need a security review .......................................................................................................... 6 Practices under Scrutiny .......................................................................................................................... 6 USB Debugging enabled......................................................................................................................
    [Show full text]
  • CUSTOM ROM – a PROMINENT ASPECTS of ANDROID
    ISSN: 2278 – 1323 International Journal of Advanced Research in Computer Engineering & Technology (IJARCET) Volume 5, Issue 5, May 2016 CUSTOM ROM – A PROMINENT ASPECTS Of ANDROID Saurabh Manjrekar, Ramesh Bhati ABSTRACT --This paper tries to look behind the wheels of II. TYPES OF ROM’S android and keeping uncommon spotlight on custom rom's and essentially check for security misconfiguration's which There are two types of ROM’s available for the android could respect gadget trade off, which might bring about device, they are described below : malware disease or information robbery. Android comprises of a portable working framework in view of the Linux bit, A. Stock ROM: with middleware, libraries and APIs written in C and The ROM or the operating system provided application programming running on an application system bydefault by the device manufacturer. It is the which incorporates Java-perfect libraries taking into account official ROM for the device. Apache Harmony. Android utilizes the Dalvik virtual machine with without a moment to spare gathering to run B. Custom ROM: ordered Java code. Android OS utilized as a part of cell phone It is not the default ROM, it is developed mostly itself however now it comes in PC, Tablets, TVs. This by the third party developers. It can either be a modified version of the stock ROM or it can be different ways makes them allowed to get to web by various completely different from the stock ROM.Stock contingent applications. Which builds security dangers in ROMs generally contains vendor specific additions private and business applications, for example, web managing in them, where as Custom ROM’s have different an account or to get to corporate systems.
    [Show full text]