顯示具有 Android 標籤的文章。 顯示所有文章
顯示具有 Android 標籤的文章。 顯示所有文章

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:

2013-09-17

Dedexer tool

1. Install oracle java 7
export http_proxy=
export https_proxy=
add-apt-repository ppa:webupd8team/java
apt-get update
apt-get install oracle-java7-installer
2. Download Dedexer tool
3. Decompile the class.dex file
unzip file.apk
java -jar dex.jar -d destination-directory source-class.dex

2013-09-10

Android Sandbox_static analysis_aapt tool

1. set Android path to PATH
export PATH=$PATH:/android-sdk-path/sdk/platform-tools
export PATH=$PATH:/android-sdk-path/sdk/build-tools/android-4.3
2. use AAPT tool to know the permissions and sdk version of an APK file
###AAPT is in /android-sdk-path/sdk/build-tools/android-4.3/aapt###
aapt d permissions file.apk
aapt d badging file.apk | grep 'sdkversion'
3. 目前是用shell script完成,接下來需porting成python
4. reference of AAPT tool

2013-09-03

Android emulator on Linux

OS : Ubuntu 12.04 32-bit

Install android-sdk
  1. apt-get install libgl1-mesa-dev
  2. apt-get install openjdk-6-jdk
  3. download Android SDK or ADT Bundle form here
  4. unzip android-sdk.zip
  5. export PATH=$PATH:/path/to/tools:/path/to/platform-tools
Update android-sdk
  1. cd android-sdk/tools
  2. ./android update sdk
  3. in the AVD manager, set the update proxy (Tools -> Options)
  4. ./android ( in the AVD manager, new an emulator)
  5. cd adnroid-sdk/tools
  6. ./emulator @emulator-name
Set PATH
  1. echo 'export PATH=$PATH:/new path' >> ~/.bashrc
  2. logout