2013-12-06

Disassemble & assemble android apk

1.    download smali,smali.jar,baksmali,baksmali.jar
2.    move those file to the folder where the android sdk is
cp smali* android-sdk/tools
cp baksmali* andorid-sdk/tools
3.    unzip the apk file
unzip xxx.apk
     there will be files and directories:
AndroidManifest.xml
classes.dex
META-INF resources.arsc
assets
com
res
4.    disassemble the .dex file
baksmali xxx.dex
     This will generate an out folder
     from the out folder, there are some .smali files that should be traced and modified
5.    assemble the smali code to dex file
smali out  
6.    generate the key to sign the repacked apk file
     use keytool.exe under java jdk
     in the CMD, switch to the java sdk folder
keytool -genkey -v -keystore keystore-name.keystore -alias alias-name -keyalg RSA -keysize 2048 -validity 10000
     enter the password of your keystore
Enter key password for keystore-name.keystore
RETURE if the same as keystore password:
     the password is to encrypt your private key
7.    sign the repacked apk fild
jarsigner -verbose -sigalg MD5withRSA -digestalg SHA1 -keystore keysotre-name.keystore -signedjar apk_signed.apk your_repacked_apk.apk alias_name
8.    check if the sign is valid
jarsigner -verify apk-signed.apk

reference:

沒有留言: