Android - nimrody/knowledgebase GitHub Wiki

Useful ADB commmands

also see here

adb shell screencap -p > screen.png
  • Clear package data
adb shell pm clear <package name>
  • Get the Android Device ID:
shell@cancro:/ $ settings get secure android_id                                
50543e327b1d31f7
smali -o classes.dex frameworkSmaliDirectory
zip framework.jar classes.dex
adb shell mount -o rw,remount /system
adb push framework.jar /system/framework/

ART

Android OS

mount -o remount,rw /system
  • Extract APK from device:
    • Get the package name pm list packages yala
    • Get the package path pm path <package-name>
    • Pull the APK: adb pull <package-path>

App development

Reverse engineering

smali

Internals

Android TrafficStats

acct_tag_hex is a socket tag
Lines with cnt_set==0 are for background data
Lines with cnt_set==1 are for foreground data

reference documentation

native code source

keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore my_application.apk alias_name

If the APK is already signed you need to unzip it, remove the META_INF/ directory and its contents and zip the result to a new APK before signing it. (If the APK has not been zip-aligned, it may be necessary to use zipalign. Something like zipalign -v 4 yourapk.apk signedapk.apk)

  • Windows ADB (USB drivers not needed) On windows go to c://Users/{your-username}/.android On Linux ~/.android

open the file adb-usb.ini on a text editor and add the lines from https://raw.githubusercontent.com/apkudo/adbusbini/master/adb_usb.ini

Save the file, open a CMD (or terminal) and type:

adb kill-server (enter)
adb start-server (enter)

reconnect the device, now it should be recognized.

  • copy files from android device
run-as com.your.packagename cat databases/database.db > /sdcard/database.db

Resources for learning

Example apps

⚠️ **GitHub.com Fallback** ⚠️