SlideShare a Scribd company logo
Android
ADB
Hello!I am Yossi Gruner
Agenda
▣ what is adb
▣ adb commands
▣ adb scripts
▣ adb files
▣ adb over WiFi
▣ screen capture/record
▣ logcat
▣ shell command
□ am
□ pm
□ dumpsys
□ more…
What is ADB
What is ADB
▣ Android Debug Bridge (adb) is a versatile command
line tool that lets you communicate with an emulator
instance or connected Android-powered device.
3 elements of ADB
▣ adb clients
□ executable with subcommand
□ ”adb shell”, ”adb logcat” : the end point of host side
▣ adb server
□ running on host on back-ground
□ act as proxy between adb clients and adbd
▣ adb daemon (adbd)
□ running on target device
□ started by init, if die, restarted by init again
How it connect
How it connect
ADB Commands
▣ adb devices
□ Print All the connected devices
▣ adb shell
□ run remote shell interactively
▣ adb jdwp
□ list PIDs of processes hosting a JDWP transport
▣ adb install/uninstall
□ un/install the application
▣ adb start-server
□ ensure that there is a server running
▣ adb kill-server
□ kill the server if it is running
Adb scripts
▣ adb wait-for-device
□ block until device is online
▣ adb start-server
□ ensure that there is a server running
▣ adb kill-server
□ kill the server if it is running
▣ adb get-state
□ prints: offline | bootloader | device
▣ adb get-serialno
□ prints: <serial-number>
▣ adb get-devpath
□ prints: <device-path>
Adb scripts
▣ adb status-window
□ continuously print device status for a specified device
▣ adb remount
□ remounts the /system and /vendor (if present) partitions on
the device read-write
▣ adb reboot [bootloader|recovery]
□ reboots the device, optionally into the bootloader or
recovery program
▣ adb reboot-bootloader -
□ reboots the device into the bootloader
▣ adb root
□ restarts the adbd daemon with root permissions
▣ adb usb
□ restarts the adbd daemon listening on USB
Adb - Files
▣ Copy file to device
□ adb push <local> <remote>
▣ Copy file from device
□ adb pull <remote> <local>
adb over WiFi
▣ Android Device
□ adb shell netcfg
 get the android IP address (x.x.x.x)
□ adb shell setprop service.adb.tcp.port 5555
□ adb shell stop adbd && start adbd
▣ PC device
□ adb connect x.x.x.x
□ adb -s x.x.x.x:5555 logcat
□ adb -s x.x.x.x:5555 logcat |grep -vE "/dalvik"
□ adb -s x.x.x.x:5555 shell
BugReport
▣ Command
□ adb shell bugreport > bugreport.txt
□ java -jar chkbugreport.jar bugreport.txt
▣ JAR download
□ https://github.com/sonyxperiadev/ChkBugReport/download
s
ScreenCapture
▣ Command:
□ adb shell screencap -p /sdcard/screen.png
□ adb pull /sdcard/screen.png
□ adb shell rm /sdcard/screen.png
▣ Other way
□ adb shell screencap -p | sed 's/r$//' > screen.png
□ adb shell screencap -p | perl -pe 's/x0Dx0A/x0A/g' >
screen.png
ScreenRecord
▣ Command:
□ adb shell screenrecord /sdcard/recording.mp4
□ adb pull /sdcard/recording.mp4
□ adb shell rm /sdcard/recording.mp4
Adb Key Event
▣ Power Button
□ adb shell input keyevent 26
▣ Unlock screen
□ adb shell input keyevent 82
▣ Volume down
□ adb shell input keyevent 25
▣ List of Keyevent
□ http://developer.android.com/reference/android/view/KeyEv
ent.html
Logcat - Logging
▣ Filter by tagname
□ adb logcat -s TAG_NAME
□ adb logcat -s TAG_NAME_1 TAG_NAME_2
▣ Filter by priority
□ adb logcat "*:PRIORITY"
 V - Verbose (lowest priority)
 D - Debug
 I - Info
 W - Warning
 E - Error
 F - Fatal
 S - Silent (highest priority, on which nothing is ever
printed)
Logcat - Logging
▣ Filter using grep
□ adb logcat | grep "SEARCH_TERM"
□ Example
 adb logcat | grep "Exception"
▣ Clearing the logcat buffer
□ adb logcat -c
Logcat - Buffers
▣ radio - adb command “”
□ View the buffer that contains radio/telephony related
messages.
▣ events
□ View the buffer containing events-related messages.
▣ main
□ View the main log buffer (default)
Run Command “logcat -b <buffer>”
Shell Commands
▣ dumpstate
□ Dumps state to a file.
▣ dmesg
□ Prints kernel debugging messages to the screen
▣ start
□ Starts an emulator/device instance.
▣ stop
□ Stops execution of an emulator/device instance.
▣ restart
□ restart an emulator/device instance.
Shell Commands
▣ top
□ Prints all the running tasks on your device
▣ Service
□ Help to communicate with phone services
 service list
 service check <SERVICE_NAME>
 service call <SERVICE_NAME> CODE
Shell Commands - More
▣ More Commands
□ adb shell ls /system/bin
AM - Activity Manager
▣ Start Activity
□ am start <packageName/.ActivityClass>
▣ Start/Stop Service
□ am startservice -n <packageName/.ServiceClass>
□ am stopservice -n <packageName/.ServiceClass>
▣ Send broadcast
□ am broadcast -a <action_name>
▣ Users
□ am switch-user <USER_ID>
□ am start-user <USER_ID>
□ am stop-user <USER_ID>
▣ More Commands
▣ adb shell am
PM - Package Manager
▣ pm list packages
▣ pm list permission-groups
▣ pm list users
▣ pm install
▣ pm create-user
▣ pm remove-user USER_ID
▣ pm get-max-users
▣ More Commands
▣ adb shell pm
Dumpsys
▣ dumpsys
□ will show all system data from the device
▣ you can filter it by adding
□ dumpsys activity
□ dumpsys batterystats
□ dumpsys cpuinfo
□ dumpsys wifi
□ dumpsys meminfo
□ dumpsys package ‘package’
▣ More:
□ adb shell dumpsys -l
Joke commands
▣ adb hell
□ same as ”adb shell” except ”hell” color :)
▣ adb lolcat
□ same as ”adb logcat”
Task #1
1. Open Settings Application
a. main application
2. Open Settings In Inner Activity
a. WifiSettings
Task #2
1. Get System Application to pc
a. Dialer.apk
Task #3
1. Open my Application with intent and extra
a. extra keys
i. string
ii. bool
iii. float
iv. string_array
▣ Download Apk
□ https://goo.gl/IWTGle
▣ Code reference
□ https://github.com/yossigruner/AdbSession
Task #4
1. enable the NFC
2. disable the NFC
Answers
▣ Task #1
□ adb shell am start -S com.android.settings/com.android.settings.Settings
□ adb shell am start -a android.intent.action.MAIN -n
com.android.settings/.wifi.WifiSettings
▣ Task #2
□ adb root
□ adb remount
□ adb pull /system/priv-app/Dialer/Dialer.apk
▣ Task #3
□ adb shell am start -n com.mike.adbsession/com.mike.adbsession.MainActivity --ez
bool false --ef float 1.999 --es string hello --esa string_array hello,world
▣ Task #4
□ enable - service call nfc 6
□ disable - service call nfc 5
References
▣ https://community.woodwing.net/sites/default/files/A
ndroid%20Debug%20Bridge%20%7C%20Android%
20Developers.pdf
▣ https://source.android.com/devices/tech/debug/dum
psys.html
Thanks!Any questions?
yossigruner@gmail.com

More Related Content

PDF
Android Automotive
PDF
ADB(Android Debug Bridge): How it works?
PDF
Android OTA updates
PDF
Understanding the Android System Server
PDF
Embedded Android Workshop with Pie
PDF
Low Level View of Android System Architecture
PDF
Design and Concepts of Android Graphics
PDF
Android's Multimedia Framework
Android Automotive
ADB(Android Debug Bridge): How it works?
Android OTA updates
Understanding the Android System Server
Embedded Android Workshop with Pie
Low Level View of Android System Architecture
Design and Concepts of Android Graphics
Android's Multimedia Framework

What's hot (20)

PPT
JDBC Architecture and Drivers
PPTX
Android User Interface
PPTX
PDF
Layouts in android
PDF
Android: Intent, Intent Filter, Broadcast Receivers
PPT
SQLITE Android
PPT
android activity
PDF
AndroidManifest
ODP
Linux commands
PDF
Android Storage - Vold
PPSX
JDBC: java DataBase connectivity
PDF
Android animation
PDF
UI controls in Android
PDF
Explore Android Internals
PPT
Requirement specification (SRS)
PDF
Android IPC Mechanism
PDF
Accessing Hardware on Android
PPTX
Tk2323 lecture 1 introduction to mobile application
PDF
Android Basic Components
PPTX
Android Navigation Component
JDBC Architecture and Drivers
Android User Interface
Layouts in android
Android: Intent, Intent Filter, Broadcast Receivers
SQLITE Android
android activity
AndroidManifest
Linux commands
Android Storage - Vold
JDBC: java DataBase connectivity
Android animation
UI controls in Android
Explore Android Internals
Requirement specification (SRS)
Android IPC Mechanism
Accessing Hardware on Android
Tk2323 lecture 1 introduction to mobile application
Android Basic Components
Android Navigation Component
Ad

Viewers also liked (20)

PPT
Android Debug
PDF
Using and Customizing the Android Framework / part 4 of Embedded Android Work...
PDF
Android Logging System
ODP
Android crash debugging
PPT
android content providers
PPTX
Android content providers
PDF
Android contentprovider
PPT
Content providers in Android
PPSX
Controlling and monitoring external embedded device using android frameworks ...
PDF
Android Overview
PDF
Android Development Tools
PDF
Android Open Accessory Protocol - Turn Your Linux machine as ADK
PPTX
Day 15: Content Provider: Using Contacts API
PPT
Mobile Device Management
PPTX
Android ppt
PPTX
Content provider in_android
PDF
Leveraging the Android Open Accessory Protocol
PPT
Android Architecture
PPTX
Introduction to android
PDF
Android Platform Architecture
Android Debug
Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Android Logging System
Android crash debugging
android content providers
Android content providers
Android contentprovider
Content providers in Android
Controlling and monitoring external embedded device using android frameworks ...
Android Overview
Android Development Tools
Android Open Accessory Protocol - Turn Your Linux machine as ADK
Day 15: Content Provider: Using Contacts API
Mobile Device Management
Android ppt
Content provider in_android
Leveraging the Android Open Accessory Protocol
Android Architecture
Introduction to android
Android Platform Architecture
Ad

Similar to Android - ADB (20)

PPTX
Important adb commands
TXT
Adb instructions
PDF
Android debug bridge android developers
PDF
Android debug bridge android developers
PDF
Android debug bridge
PDF
PPTX
Making it Rain Android Shells - How 30,000+ Android devices are exposed to th...
PDF
Embedded Android
PDF
Unit Kali NetHunter is the official Kali Linux penetration testing platform f...
PDF
Unit 1 Kali Nethunter Android: OS, Debub Bridge
PPTX
Mastering the Android Shell: A Comprehensive Project Report
PDF
3 getting to know the android tools - en-us
PDF
Discover System Facilities inside Your Android Phone
PPT
Android basics – Key Codes – ADB – Rooting Android – Boot Process – File Syst...
PDF
OWF12/PAUG Conf Days Android tools for developpeurs, paul marois, design and ...
PDF
Talks on adb - Day 2 (pdf version)
PDF
Android application penetration testing
PPTX
PPTX
Android Development Tools Overview
Important adb commands
Adb instructions
Android debug bridge android developers
Android debug bridge android developers
Android debug bridge
Making it Rain Android Shells - How 30,000+ Android devices are exposed to th...
Embedded Android
Unit Kali NetHunter is the official Kali Linux penetration testing platform f...
Unit 1 Kali Nethunter Android: OS, Debub Bridge
Mastering the Android Shell: A Comprehensive Project Report
3 getting to know the android tools - en-us
Discover System Facilities inside Your Android Phone
Android basics – Key Codes – ADB – Rooting Android – Boot Process – File Syst...
OWF12/PAUG Conf Days Android tools for developpeurs, paul marois, design and ...
Talks on adb - Day 2 (pdf version)
Android application penetration testing
Android Development Tools Overview

Android - ADB

  • 3. Agenda ▣ what is adb ▣ adb commands ▣ adb scripts ▣ adb files ▣ adb over WiFi ▣ screen capture/record ▣ logcat ▣ shell command □ am □ pm □ dumpsys □ more…
  • 5. What is ADB ▣ Android Debug Bridge (adb) is a versatile command line tool that lets you communicate with an emulator instance or connected Android-powered device.
  • 6. 3 elements of ADB ▣ adb clients □ executable with subcommand □ ”adb shell”, ”adb logcat” : the end point of host side ▣ adb server □ running on host on back-ground □ act as proxy between adb clients and adbd ▣ adb daemon (adbd) □ running on target device □ started by init, if die, restarted by init again
  • 9. ADB Commands ▣ adb devices □ Print All the connected devices ▣ adb shell □ run remote shell interactively ▣ adb jdwp □ list PIDs of processes hosting a JDWP transport ▣ adb install/uninstall □ un/install the application ▣ adb start-server □ ensure that there is a server running ▣ adb kill-server □ kill the server if it is running
  • 10. Adb scripts ▣ adb wait-for-device □ block until device is online ▣ adb start-server □ ensure that there is a server running ▣ adb kill-server □ kill the server if it is running ▣ adb get-state □ prints: offline | bootloader | device ▣ adb get-serialno □ prints: <serial-number> ▣ adb get-devpath □ prints: <device-path>
  • 11. Adb scripts ▣ adb status-window □ continuously print device status for a specified device ▣ adb remount □ remounts the /system and /vendor (if present) partitions on the device read-write ▣ adb reboot [bootloader|recovery] □ reboots the device, optionally into the bootloader or recovery program ▣ adb reboot-bootloader - □ reboots the device into the bootloader ▣ adb root □ restarts the adbd daemon with root permissions ▣ adb usb □ restarts the adbd daemon listening on USB
  • 12. Adb - Files ▣ Copy file to device □ adb push <local> <remote> ▣ Copy file from device □ adb pull <remote> <local>
  • 13. adb over WiFi ▣ Android Device □ adb shell netcfg  get the android IP address (x.x.x.x) □ adb shell setprop service.adb.tcp.port 5555 □ adb shell stop adbd && start adbd ▣ PC device □ adb connect x.x.x.x □ adb -s x.x.x.x:5555 logcat □ adb -s x.x.x.x:5555 logcat |grep -vE "/dalvik" □ adb -s x.x.x.x:5555 shell
  • 14. BugReport ▣ Command □ adb shell bugreport > bugreport.txt □ java -jar chkbugreport.jar bugreport.txt ▣ JAR download □ https://github.com/sonyxperiadev/ChkBugReport/download s
  • 15. ScreenCapture ▣ Command: □ adb shell screencap -p /sdcard/screen.png □ adb pull /sdcard/screen.png □ adb shell rm /sdcard/screen.png ▣ Other way □ adb shell screencap -p | sed 's/r$//' > screen.png □ adb shell screencap -p | perl -pe 's/x0Dx0A/x0A/g' > screen.png
  • 16. ScreenRecord ▣ Command: □ adb shell screenrecord /sdcard/recording.mp4 □ adb pull /sdcard/recording.mp4 □ adb shell rm /sdcard/recording.mp4
  • 17. Adb Key Event ▣ Power Button □ adb shell input keyevent 26 ▣ Unlock screen □ adb shell input keyevent 82 ▣ Volume down □ adb shell input keyevent 25 ▣ List of Keyevent □ http://developer.android.com/reference/android/view/KeyEv ent.html
  • 18. Logcat - Logging ▣ Filter by tagname □ adb logcat -s TAG_NAME □ adb logcat -s TAG_NAME_1 TAG_NAME_2 ▣ Filter by priority □ adb logcat "*:PRIORITY"  V - Verbose (lowest priority)  D - Debug  I - Info  W - Warning  E - Error  F - Fatal  S - Silent (highest priority, on which nothing is ever printed)
  • 19. Logcat - Logging ▣ Filter using grep □ adb logcat | grep "SEARCH_TERM" □ Example  adb logcat | grep "Exception" ▣ Clearing the logcat buffer □ adb logcat -c
  • 20. Logcat - Buffers ▣ radio - adb command “” □ View the buffer that contains radio/telephony related messages. ▣ events □ View the buffer containing events-related messages. ▣ main □ View the main log buffer (default) Run Command “logcat -b <buffer>”
  • 21. Shell Commands ▣ dumpstate □ Dumps state to a file. ▣ dmesg □ Prints kernel debugging messages to the screen ▣ start □ Starts an emulator/device instance. ▣ stop □ Stops execution of an emulator/device instance. ▣ restart □ restart an emulator/device instance.
  • 22. Shell Commands ▣ top □ Prints all the running tasks on your device ▣ Service □ Help to communicate with phone services  service list  service check <SERVICE_NAME>  service call <SERVICE_NAME> CODE
  • 23. Shell Commands - More ▣ More Commands □ adb shell ls /system/bin
  • 24. AM - Activity Manager ▣ Start Activity □ am start <packageName/.ActivityClass> ▣ Start/Stop Service □ am startservice -n <packageName/.ServiceClass> □ am stopservice -n <packageName/.ServiceClass> ▣ Send broadcast □ am broadcast -a <action_name> ▣ Users □ am switch-user <USER_ID> □ am start-user <USER_ID> □ am stop-user <USER_ID> ▣ More Commands ▣ adb shell am
  • 25. PM - Package Manager ▣ pm list packages ▣ pm list permission-groups ▣ pm list users ▣ pm install ▣ pm create-user ▣ pm remove-user USER_ID ▣ pm get-max-users ▣ More Commands ▣ adb shell pm
  • 26. Dumpsys ▣ dumpsys □ will show all system data from the device ▣ you can filter it by adding □ dumpsys activity □ dumpsys batterystats □ dumpsys cpuinfo □ dumpsys wifi □ dumpsys meminfo □ dumpsys package ‘package’ ▣ More: □ adb shell dumpsys -l
  • 27. Joke commands ▣ adb hell □ same as ”adb shell” except ”hell” color :) ▣ adb lolcat □ same as ”adb logcat”
  • 28. Task #1 1. Open Settings Application a. main application 2. Open Settings In Inner Activity a. WifiSettings
  • 29. Task #2 1. Get System Application to pc a. Dialer.apk
  • 30. Task #3 1. Open my Application with intent and extra a. extra keys i. string ii. bool iii. float iv. string_array ▣ Download Apk □ https://goo.gl/IWTGle ▣ Code reference □ https://github.com/yossigruner/AdbSession
  • 31. Task #4 1. enable the NFC 2. disable the NFC
  • 32. Answers ▣ Task #1 □ adb shell am start -S com.android.settings/com.android.settings.Settings □ adb shell am start -a android.intent.action.MAIN -n com.android.settings/.wifi.WifiSettings ▣ Task #2 □ adb root □ adb remount □ adb pull /system/priv-app/Dialer/Dialer.apk ▣ Task #3 □ adb shell am start -n com.mike.adbsession/com.mike.adbsession.MainActivity --ez bool false --ef float 1.999 --es string hello --esa string_array hello,world ▣ Task #4 □ enable - service call nfc 6 □ disable - service call nfc 5

Editor's Notes

  • #29: adb shell am start -S com.android.settings/com.android.settings.Settings adb shell am start -a android.intent.action.MAIN -n com.android.settings/.wifi.WifiSettings
  • #30: adb root adb remount adb pull /system/priv-app/Dialer/Dialer.apk
  • #31: open application adb shell am start -n com.mike.adbsession/com.mike.adbsession.MainActivity extra: adb shell am start -n com.mike.adbsession/com.mike.adbsession.MainActivity --ez bool false --ef float 1.999 --es string hello --esa string_array hello,world
  • #32: # Enable NFC service call nfc 6 # Disable NFC service call nfc 5