Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Android Security Cookbook

You're reading from   Android Security Cookbook Practical recipes to delve into Android's security mechanisms by troubleshooting common vulnerabilities in applications and Android OS versions

Arrow left icon
Product type Paperback
Published in Dec 2013
Publisher Packt
ISBN-13 9781782167167
Length 350 pages
Edition 1st Edition
Languages
Arrow right icon
Toc

Table of Contents (11) Chapters Close

Preface 1. Android Development Tools FREE CHAPTER 2. Engaging with Application Security 3. Android Security Assessment Tools 4. Exploiting Applications 5. Protecting Applications 6. Reverse Engineering Applications 7. Secure Networking 8. Native Exploitation and Analysis 9. Encryption and Developing Device Administration Policies Index

Using the Android Debug Bridge (ADB) to interact with the AVDs

Interacting with the emulated Android device is one of the most important skills for both a developer and an Android security engineer/auditor. The Android Debug Bridge (ADB) provides the functionality needed to interact with the native-level components of an Android device. It allows the developers and security engineers to read the contents of the filesystem and interact with the package manager, application manager, kernel driver interfaces, and initialization scripts to mention a few.

How to do it...

Interacting with a virtual device using the ADB works as follows:

  1. You'll need to start an AVD first or, if you like, simply plug in your own Android device via a USB to whatever machine you'd like to use—given that this machine has the SDK installed. You can start the AVD using the following command:
    emulator –avd [name]
    
  2. We can list all the connected Android Devices by using the following command for a Windows machine:
    C;\\[path-to-sdk-install]\platform-tools\adb devices
    

    Or, if you're using a Linux machine, use the following command:

    [path-to-sdk-install]/platform-tools/adb devices
    

    This command should give you a list of the connected devices, which is basically all the devices that you will be able to connect to using ADB. You need to pay attention to the device names in the list. You will need to identify the devices when you launch a connection to them using ADB.

  3. You can launch a shell connection to your Android device using the following command:
    /sdk/platform-tools/abd shell –s [specific device]
    

    Or, if you happen to know that the Android device you want to connect to is the only emulated device, you can use the following command:

    /sdk/platform-tools/adb shell –e
    

    Or, if the device is the only USB-connected device, you can use the following command:

    /sdk/platform-tools/adb shell –d
    

    The switches –d, -e, and -p apply to the other ADB commands and not just the shell. If this works well, you should see a prompt string—the string displayed to identify the command shell being used—similar to the following command:

    root@android$
    

You should now have a full-fledged shell with some of the traditional Unix/Linux commands and utilities at your finger tips. Try searching around on the filesystem and getting to know where everything is kept.

There's more…

Now that you have a connected device, you'll need to know a little bit about navigating the Android filesystem and making use of the commands. Here's a small list to get you started:

  • ls {path}: This will list the contents of the directory at the path
  • cat {file}: This will print the contents of a text file on the screen
  • cd {path}: This will change the working directory to the one pointed to by the path
  • cd ../: This changes the working directory to the one that's exactly one level higher
  • pwd: This prints the current working directory
  • id: This checks your user ID
You have been reading a chapter from
Android Security Cookbook
Published in: Dec 2013
Publisher: Packt
ISBN-13: 9781782167167
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image