惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

小众软件
小众软件
量子位
博客园 - 叶小钗
Apple Machine Learning Research
Apple Machine Learning Research
U
Unit 42
IT之家
IT之家
F
Fortinet All Blogs
GbyAI
GbyAI
MongoDB | Blog
MongoDB | Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
大猫的无限游戏
大猫的无限游戏
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
The Register - Security
The Register - Security
NISL@THU
NISL@THU
Webroot Blog
Webroot Blog
A
Arctic Wolf
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
V
Visual Studio Blog
Recent Announcements
Recent Announcements
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Blog — PlanetScale
Blog — PlanetScale
L
LangChain Blog
P
Palo Alto Networks Blog
Y
Y Combinator Blog
WordPress大学
WordPress大学
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
AWS News Blog
AWS News Blog
有赞技术团队
有赞技术团队
Engineering at Meta
Engineering at Meta
C
Cybersecurity and Infrastructure Security Agency CISA
aimingoo的专栏
aimingoo的专栏
Know Your Adversary
Know Your Adversary
Cyberwarzone
Cyberwarzone
Martin Fowler
Martin Fowler
The Hacker News
The Hacker News
P
Privacy International News Feed
T
Threat Research - Cisco Blogs
G
GRAHAM CLULEY
宝玉的分享
宝玉的分享
博客园 - 聂微东
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The GitHub Blog
The GitHub Blog
S
Securelist
T
The Exploit Database - CXSecurity.com
T
Threatpost
Microsoft Azure Blog
Microsoft Azure Blog
The Cloudflare Blog
F
Full Disclosure

Black Hills Information Security, Inc.

Bad Habits: An ANTISOC Operation Same Problem, Different Angles: When Red Team and Blue Team Actually Talk to Each Other How to Identify and Exploit New Vulnerabilities Swapper – A Pure Regex Match/Replace Burp Extension A Practical Guide to BloodHound Data Collection Network Engineering Basics Signed, Trusted, and Abused: Proxy Execution via WebView2 Getting Started In Pentesting – Advice From The BHIS Pentest Lead Cloud Security: Tips and Resources for Securing the Cloud Lessons From A Chatbot Incident How to Lead Effective Tabletops Understanding GRC: How to Navigate Risks and Compliance Standards The “P” in PAM is for Persistence: Linux Persistence Technique Malware Analysis: How to Analyze and Understand Malware OSINT: How to Find, Use, and Control Open-Source Intelligence What to Do with Your First Home Lab When the SOC Goes to Deadwood: A Night to Remember Social Engineering and Microsoft SSPR: The Road to Pwnage is Paved with Good Intentions Common Cyber Threats Finding the Right Penetration Testing Company Deceptive-Auditing: An Active Directory Honeypots Tool The Curious Case of the Comburglar How to Set Smart Goals (That Actually Work For You) Inside the BHIS SOC: A Conversation with Hayden Covington Abusing Delegation with Impacket (Part 3): Resource-Based Constrained Delegation Why You Got Hacked – 2025 Super Edition Abusing Delegation with Impacket (Part 2): Constrained Delegation Abusing Delegation with Impacket (Part 1): Unconstrained Delegation GoSpoof – Turning Attacks into Intel Model Context Protocol (MCP) Bypassing WAFs Using Oversized Requests Getting Started with AI Hacking Part 2: Prompt Injection Wrangling Windows Event Logs with Hayabusa & SOF-ELK (Part 2) DomCat: A Domain Categorization Tool Wrangling Windows Event Logs with Hayabusa & SOF-ELK (Part 1) Microsoft Store and WinGet: Security Risks for Corporate Environments Default Web Content MailFail Commonly Abused Administrative Utilities: A Hidden Risk to Enterprise Security Stop Spoofing Yourself! Disabling M365 Direct Send Bypassing CSP with JSONP: Introducing JSONPeek and CSP B Gone Offensive Tooling Cheatsheets: An Infosec Survival Guide Resource DNS Triage Cheatsheet GraphRunner Cheatsheet Burp Suite Cheatsheet Impacket Cheatsheet Wireshark Cheatsheet Hashcat Cheatsheet EyeWitness Cheatsheet Nmap Cheatsheet Netcat (nc) Cheatsheet Hunt for Weak Spots in Your Wireless Network with Airodump-ng from the Aircrack-ng Suite Detecting ADCS Privilege Escalation Vulnerability Scanning with Nmap Getting Started with NetExec: Streamlining Network Discovery and Access How to Use Dirsearch Augmenting Penetration Testing Methodology with Artificial Intelligence – Part 3: Arcanum Cyber Security Bot How to Design and Execute Effective Social Engineering Attacks by Phone Abusing S4U2Self for Active Directory Pivoting Why Use a Macro Pad? Espanso: Text Replacement, the Easy Way Caging Copilot: Lessons Learned in LLM Security Augmenting Penetration Testing Methodology with Artificial Intelligence – Part 2: Copilot Augmenting Penetration Testing Methodology with Artificial Intelligence – Part 1: Burpference Intercepting Traffic for Mobile Applications that Bypass the System Proxy Communicating Security to the C-Suite: A Strategic Approach Offline Memory Forensics With Volatility Getting Started with AI Hacking: Part 1 Go-Spoof: A Tool for Cyber Deception How to Test Adversary-in-the-Middle Without Hacking Tools Canary in the Code: Alert()-ing on XSS Exploits How to Hack Wi-Fi with No Wi-Fi Why Your Org Needs a Penetration Test Program Burp Suite Extension: Copy For Light at the End of the Dark Web Wi-Fi Forge: Practice Wi-Fi Security Without Hardware Avoiding Dirty RAGs: Retrieval-Augmented Generation with Ollama and LangChain Gone Phishing: Installing GoPhish and Creating a Campaign 5 Things We Are Going to Continue to Ignore in 2025 John Strand’s 5 Phase Plan For Starting in Computer Security Questions From a Beginner Threat Hunter GRC for Security Managers: From Checklists to Influence AI Large Language Models and Supervised Fine Tuning Attack Tactics 9: Shadow Creds for PrivEsc w/ Kent & Jordan One Active Directory Account Can Be Your Best Early Warning Introduction to Zeek Log Analysis Indecent Exposure: Your Secrets are Showing Creating Burp Extensions: A Beginner’s Guide Pitting AI Against AI: Using PyRIT to Assess Large Language Models (LLMs) The Top Ten List of Why You Got Hacked This Year (2023/2024) ICS Hard Knocks: Mitigations to Scenarios Found in ICS/OT Backdoors & Breaches Intro to Data Analytics Using SQL Finding Access Control Vulnerabilities with Autorize The Detection Engineering Process Cyber Risk Lessons We Can Learn From Hurricane Preparedness Intro to Desktop Application Testing Methodology What Is Penetration Testing? Adversary in the Middle (AitM): Post-Exploitation Pentesting, Threat Hunting, and SOC: An Overview QEMU, MSYS2, and Emacs: Open-Source Solutions to Run Virtual Machines on Windows
How to Root Android Phones
BHIS · 2025-04-23 · via Black Hills Information Security, Inc.

Penetration Tester. Developer. Pure GNU/Linux Phone Enthusiast.

This blog will cover how to root an AVD emulator and a physical Pixel 6. But before we cover those topics, let’s cover what it is we will be doing and some of the pro/cons of rooting an Android phone.

First – What is rooting?

Rooting an Android device is a term used for bypassing device restrictions and becoming superuser — often called the “root user,” or just “root.” As superuser, user will have access to system level resources and have greater access on the device.

Second – Why would I want to root a device?

Testing mobile applications for Android usually requires a rooted device. As mentioned above, rooting will give us superuser access on the phone, which allows us to perform actions that make testing easier (e.g. installing proxy CA certificate in system).

The Android operating system is based on the Android Open Source Project (AOSP) (https://source.android.com/), which is the official open-source initiative maintained by Google for the development of the Android operating system. Its purpose is to provide the source code and tools necessary to allow developers, hardware manufacturers, and anyone else to build their own custom versions of Android.

A quick note about the AOSP. The device manufacturer (e.g. Samsung) and the carrier (e.g. T-Mobile) will add to their own updates and changes to their version of Android, so their version of Android on each is based off the AOSP but not a 1:1 match. Updates to Android go through the carrier and device manufacturer before they reach the device. Testing with Google devices bought directly from Google (and not through a carrier) is my recommendation because it is closest to the AOSP.

There are also custom ROMs that a user can flash on an Android device that are different than the AOSP.

What is a ROM?

A ROM is custom firmware that can be flashed on the device. The name is a legacy namesake that is still used. ROM stands for Read Only Memory, which is where the firmware was on older Android devices. The firmware on modern phones is stored in the internal flash memory. ROM is a name that stuck to mean custom firmware.

Examples of custom ROMS:

Third – Bypass security controls (That sounds bad…)

It is. Be careful when rooting a personal phone. (I am not endorsing that you do that and would strongly advise against rooting a personal phone.) If you do decide to root your personal phone, be sure to lock the bootloader after you do what you intended (e.g. installing a custom ROM).

Running sensitive applications (e.g. banking, email client for work) is not recommended on a rooted phone for several reasons. The application is running on a phone where other applications may have access to everything, including the app’s data directory. A couple rules of thumb — always assume the app is not secure, keep protections in place to prevent data loss (e.g. session tokens stored in application’s data directory that another application can access). I could write an entirely new blog/book on this topic but always assume that an application running on your phone wants access to all the data from other apps on your phone (https://techcrunch.com/2024/03/26/facebook-secret-project-snooped-snapchat-user-traffic/). Rooting the phone makes it easier for apps (and attackers) to access information that should not be made available to that app or perform unwarranted actions against another app.

Rooting a phone requires unlocking the bootloader. In short, the bootloader loads the kernel. There are security features that the bootloader provides, including ensuring the code comes from a trusted source. Unlocking the bootloader removes a security control. More info on what the bootloader does can be found here: https://source.android.com/docs/core/architecture/bootloader

Last – There are a lot of tools out there… How do I know a tool is safe?

You need to exercise due diligence when using third-party tools. A good rule for beginners is to stick to the tools listed in the OWASP Mobile Application Security framework (https://owasp.org/www-project-mobile-app-security/). These tools have been vetted.

A word of caution before we begin:  Mobile testing has some sketchy tooling and repos available. ALWAYS be sure to use official repos and tooling. Vet the tooling before using. You do not want to introduce bad/malicious code into your environment. Be mindful of the source as forks and copies of tools like rootAVD exist.

Rooting an Emulator

I personally like testing on a physical device for mobile tests, but in Android, the emulator is still a solid choice. Android Virtual Device (AVD) offers a viable platform. We will use an emulator because it is free! Details on installing and using AVD can be found here: https://developer.android.com/studio/run/managing-avds

Free Stuff is Cool

A really easy way to root an emulator is with rootAVD (https://gitlab.com/newbit/rootAVD).

The TL;DR: rootAVD roots your AVD with Magisk (https://github.com/topjohnwu/Magisk).

Run the rootAVD.sh shell script that is included with rootAVD (or the rootAVD.bat batch script that is included for Windows). You will need Android Debug Bridge (ADB) (https://developer.android.com/tools/adb) installed for rootAVD to work.

rootAVD.sh Showing Commands to Root AVD

The first command that is returned is most often the best command to use. Note that the output has found the AVD emulator and supplied commands to run. The command we are going to use targets the ramdisk image file. The ramdisk image will be modified to give us root access on the AVD. Use the first command in the terminal.

./rootAVD.sh system-images/android-34/google_apis_playstore/arm64-v8a/ramdisk.img
Partial Command Output

Next, open the Magisk app and it will prompt a reboot to complete setup.

Open the App with the Cool Logo

The easiest way to check if you have successfully rooted your device, IMO, is to use ADB to get shell access on the device. Enter the command adb shell in your terminal to get a shell on the AVD. Enter su to access the su binary and grant your shell elevated permissions. whoami will return root if the device has been rooted.

ADB Shell Output Showing Root Access

When you first enter the command su, a prompt on the phone will ask if you want to grant com.android.shell root access. Be sure to grant access.

If you missed the ten second window to grant your shell superuser access, not a big deal. Just open the Magisk app on AVD and click the “Superuser” icon.

Superuser in Magisk App

Grant the process the permission by toggling the field shown in the screenshot below. Because this process requested root access, it will show up in here.

Grant Permission by Toggling Button
Woot! Root Access Granted

And now your shell will allow you to access the su binary! We can move on to capturing traffic.

Root Achieved

Rooting Physical Device

This walkthrough is using a Pixel 6.

First, we need to set the conditions to allow rooting. On the phone, we need to:

  • Enable Developer options
  • Enable USB Debugging
  • Unlock the Bootloader

Developer Options

To enable developer options on a Pixel device, go to Settings –> About phone –> keep rapidly hitting Build number (seven times) until you have enabled Developer options.

Tap the Build Number Until Developer Tools Enabled

Developer options can be found in Settings –> System –> Developer options.

USB Debugging

In Developer options, you will need to enable USB debugging. This option lets us interact with the phone using the USB protocol.

OEM Unlocking

In Developer options, you will need to ensure that OEM unlocking is enabled. Toggle the OEM unlocking option to enable.

Sidebar on OEM Unlocking:

  • What if you are not able to enable OEM unlocking? If your phone was purchased through a carrier (T-Mobile, Verizon), there is a good chance that this option is not available to you. First, I recommend always getting phones straight from Google or if using a reseller, ensure that device is “Carrier Unlocked.” That said, I have had success by calling the carrier, explaining I am a security researcher, and I need this for testing. I also have explained that I need to run a custom ROM that had Google stripped from it and having Google enabled (and tracking and storing everything about me) on the phone puts me at more risk than having the bootloader unlocked. All I am saying is that it is worth a conversation — the employees are helpful and are willing to hear your case!

Unlock the Bootloader

Once that is done, you need to unlock the bootloader. You will need ADB (https://developer.android.com/tools/adb) to do this. Run these commands.

Word of caution: All information on the device is gone after you do this.

adb reboot bootloader
fastboot flashing unlock
fastboot reboot

Great, we have the phone where we need it. Now let’s start rooting.

Root

Download the image from here (https://developers.google.com/android/images) that your Android device is on. I am using a Pixel 6 device running Andoid version 14, so I will choose the version in the screenshot. You need to ensure you download the version that is on your phone.

Download Image from this Site

A .zip file is downloaded. Extract the contents of that file.

unzip oriole-ap2a.240905.003.f1-factory-655c44e7.zip -d root

When you extract the contents, there is a zipped file inside the contents that you will need to extract to get the boot.img file needed.

Extract the Contents of the Zip File
unzip image-oriole-ap2a.240905.003.f1.zip -d boot_image
Locate the boot.img

Great! Now we have the boot.img we need. Use ADB to push that file to the Download folder on the phone.

adb push boot_image/boot.img /sdcard/Download/
Use ADB to Push the Image to the Phone

Now, install Magisk on the phone using ADB. Download the APK file from here: https://github.com/topjohnwu/Magisk/releases

Installing Magisk on Phone using ADB

Open the Magisk app –> Select Install –> Choose Select and Patch a File –> Choose the boot.img file you uploaded to downloads.

Select this Option to Patch the Image

The process creates a patched boot.img file that we can use to root Android. Your file name will be different; make note of the path and file name of the patched boot.img file.

Partial Location of Patched Image

Use ADB to get the file off the phone.

adb  pull /storage/emulated/0/Download/magisk_patched-28100_JydcU.img ./patched_boot.img
Use ADB to Move Patched Image off Phone

Once you have pulled the file off the phone, boot into the bootloader.

adb reboot bootloader

Use the following command to get the current slot. The Pixel 6 I am using uses A/B partitioning, so we need to ensure we flash the correct partition.

fastboot getvar current-slot
Slot B Returned as Current Slot

Slot b is returned in my example. That is what I will use. Use the following command to flash the partition with the Magisk patched boot.img.

fastboot flash boot_b patched_boot.img
Flash the Partition with Patched Image

Reboot.

fastboot reboot

Ensure the device is rooted.

Whoami Returns Root

And there it is — the phone is rooted!

In a Nutshell

In this blog, we learned what rooting is, some pros and cons of rooting a device, and methods to root both an AVD and physical phone. Rooting an Android phone is useful for testers as the superuser access is needed to fully test an application or the phone’s software and firmware for vulnerabilities. Rooting also allows for adding custom modifications to a personal phone, like installing a custom ROM. Once a phone is rooted, a tester has full system access and can observe how apps behave and can monitor network traffic in and out of the device. The downside, however, is that rooting a phone weakens security features normally present on the device.

Rooting a phone gives you superuser power over the device and its settings. Useful, to be sure, and dangerous, so use with caution. Happy Hacking!



Ready to learn more?

Level up your skills with affordable classes from Antisyphon!

Pay-What-You-Can Training

Available live/virtual and on-demand