In this part we will extract the legitimate apk from emulator or the device and get the source code.
First Steps
# install toolsaptinstalladbapktoolopenjdk-11-jdk-headlesszipalignapksigner# list android attached devicesadbdevices# find app nameadbshellpmlistpackages-f|grep $app_name# list installed packagesadbshellpmlistpackages-f# get path of the app we want to reverseadbshellpmpath $package_name# get the app on our local machine on current folderadbpull $PATH_app .
Get the source code
Tools :
jadx / jadx-gui
dex2jar
apktool
apkx
jadx-d $path_output_folder app.apk# or d2jd2j-dex2jar.shapp.apk# or apktool decompileapktooldapp.apk-o $output_folder# or apkxapkxapp.apkcdapp# open in visual studiocode.# or use jadx-guijadx-guiapp.apk# Open the JAR file with JD-GUI and youβll see its Java code.
Decompile/Compile Source Code
## Install app on android deviceadbinstallapp.apk# decompileapktooldapp.apk-oapp-decompile# remove app from phone adbuninstallapp.apk# recompileapktoolbapp-decompile/-oapp.apk# sign# create keystorekeytool-genkey-v-keystoredemo.keystore-aliasdemokeys-keyalgRSA-keysize2048-validity10000# sign the apkjarsigner-sigalgSHA1withRSA-digestalgSHA1-keystoredemo.keystore-storepassdemopassapp.apkdemokeys## apksigner supports signature v1 to v4apksignersign--ksdemo.keystore--ks-passpass:$password app.apk# verify the signaturejarsigner-verifyapp.apk# zipalign the APKzipalign4app.apkapp_signed.apk# also for signing :## d2j-apk-signd2j-apk-signapp.apk-oapp-signed.apk## uber-apk-signerjava-jaruber-apk-signer.jar--apksapp.apk