Home

Awesome

ApkAnalyzer

Java app / library used to obtain detailed informations about Andoid APK files.

<a name="How_to_use_it"/>

How to use

<a name="Prepare_for_first_use"/>

Prepare for first use

If you want to build and make changes in code of ApkAnalyzer, you need to perform following steps. ApkAnalyzer uses Apktool for decompilation of Apk. You need to add Apktool to your maven repository.<br/>

  1. Download apktool_2.0.0rc4 from https://bitbucket.org/iBotPeaches/apktool/downloads<br/>
  2. Run following maven command : mvn install:install-file -Dfile=<path-to-apktool_2.0.0rc4-file> -DgroupId=ApkTool -DartifactId=ApkTool -Dversion=2.0.0.rc4 -Dpackaging=jar<br/>

ApkAnalyzer uses maven to build. It`s designed to allow you to customize way it works and various values as thresholds. This can only be done using public API, not using command line parameters (not implemented yet).

You can also use latest build jar with all dependecies and run it as a java program.

Command line parameters
ParameterInfo
-analyzeTriggers analyze task. See [Analyze APKs] (#Analyze_APKs) chapter
-compareTriggers compare task. See [Compare APKs] (#Compare_APKs) chapter
-statisticsTriggers statistics task. See [Statistics] (#Statistics) chapter
-in, --input-dirSpecify directory where input for task will be searched
-out, --output-dirSpecify directory where output of task will be saved
<a name="Analyze_APKs"/>

Analyze APKs

In case you use jar file, this use case can be triggered with following command java -jar -analyze -in="your_input_dir" -out="your_output_dir"

This task unzip and decompile APK file using ApkTool. To find details about implementation, please explore [AnalyzeTask.java] (https://github.com/MartinStyk/ApkAnalyzer/blob/master/src/main/java/sk/styk/martin/bakalarka/execute/tasks/AnalyzeTask.java).

This task creates json file for every analyzed APK. See example of output file.

<a name="Compare_APKs"/>

Compare APKs

In case you use jar file, this use case can be triggered with following command java -jar -compare -in="your_input_dir" -out="your_output_dir"

Directory your_input_dir must contain json files created by analyze task

Directory your_output_dir will contain data about similar APKs

This task only compares metadata. It uses informations about number of activities, services, broadcast recevers, content prividers, apk file size, dex and arsc file size to determine whether two APKs are at least similar. If so, it compares all files in APKs. Default threshold is set to 50% for each attribute. It can not be adjusted using CLI so far. In case you need to adjust it for your use, please feel free to see [CompareTask.java] (https://github.com/MartinStyk/ApkAnalyzer/blob/master/src/main/java/sk/styk/martin/bakalarka/execute/tasks/CompareTask.java) and related parts of code.

Output of this task is json file for every pair of similar APKs. Output is divided into specific folders according to certificate match and version of application match. Every json contains simple diff of two APKs with data including modified, added or deleted files. For example see this file or another one.

<a name="Statistics"/>

Statistics

In case you use jar file, this use case can be triggered with following command java -jar -statistics -in="your_input_dir" -out="your_output_dir"

Directory your_input_dir must contain json files created by analyze task

Directory your_output_dir will contain statistics data

To find details about implementation, please explore [StatisticsTask.java] (https://github.com/MartinStyk/ApkAnalyzer/blob/master/src/main/java/sk/styk/martin/bakalarka/execute/tasks/StatisticsTask.java).

See example of output file.

<a name="Collected_data"/>

Collected data

<a name="ad"/>

Attributes & description

<a name="basic"/>

Basic apk metadata

NameTypeDescription
fileNameStringName of analyzed apk file
sourceOfFileStringLocation from where the file was downloaded
fileSizeLongSize of whole apk file (in bytes)
dexSizeLongSize of compiled sources in classes.dex file (in bytes)
arscSizeLongSize of compiled resources in classes.dex file (in bytes)
<a name="manifest"/>

Android manifest metadata

NameTypeDescription
packageNameStringSee Android documentation
versionCodeStringSee Android documentation
installLocationStringSee Android documentation
numberOfActivitiesIntegerTotal number of activities in application
numberOfServicesIntegerTotal number of services in application
numberOfContentProvidersIntegerTotal number of content providers in application
numberOfBroadcastReceiversIntegerTotal number of broadcast receivers in application
usesPermissionsList<String>List of permissions used by application See Android documentation
usesLibraryList<String>List of libraries used by application See Android documentation
permissionsList<String>List of permissions defined by application See Android documentation
permissionsProtectionLevelList<String>Protection level of permissions defined by application See Android documentation
usesFeatureList<String>List of features used by application See Android documentation
usesMinSdkVersionStringMinimum Sdk version required by app List of features used by application See Android documentation
usesTargetSdkVersionStringTarget Sdk version required by app See Android documentation
usesMaxSdkVersionStringMaximal Sdk version requered by app See Android documentation
supportsScreensResizeableBooleanSee Android documentation
supportsScreensSmallBooleanSee Android documentation
supportsScreensNormalBooleanSee Android documentation
supportsScreensLargeBooleanSee Android documentation
supportsScreensXlargeBooleanSee Android documentation
supportsScreensAnyDensityBooleanSee Android documentation
<a name="certificate"/>

Certificate metadata

NameTypeDescription
fileNameStringName of certificate file (i.e CERT.RSA in MEATA-INF directory)
signAlgorithmStringSignature algorithm name from the certificate
signAlgorithmOIDStringSignature algorithm OID string from the certificate
startDateDatenotBefore date from the validity period of the certificate
endDateDatenotAfter date from the validity period of the certificate
publicKeyMd5StringMD5 hash of public key
certBase64Md5StringBase64 MD5 hash of certificate
certMd5StringMD5 hash of certificate
versionIntegerVersion value from the certificate
issuerNameStringRepresentation of the X.500 distinguished name using the format defined in RFC 2253
subjectNameStringRepresentation of the X.500 distinguished name using the format defined in RFC 2253
<a name="resource"/>

Resources metadata

NameTypeDescription
localeList<String>Localizations of string.xml file
numberOfStringResourceIntegerNumber of entries in default string.xml file (currently not collected)
pngDrawablesIntegerNumber of drawables in png format
ninePatchDrawablesIntegerNumber of drawables in .9.png format
jpgDrawablesIntegerNumber of drawables in jpg/jpeg format
gifDrawablesIntegerNumber of drawables in gif format
xmlDrawablesIntegerNumber of drawables in xml format
ldpiDrawablesIntegerNumber of drawables located in ldpi folder
mdpiDrawablesIntegerNumber of drawables located in mdpi folder
hdpiDrawablesIntegerNumber of drawables located in hdpi folder
xhdpiDrawablesIntegerNumber of drawables located in xhdpi folder
xxhdpiDrawablesIntegerNumber of drawables located in xxhdpi folder
xxxhdpiDrawablesIntegerNumber of drawables located in xxxhdpi folder
tvdpiDrawablesIntegerNumber of drawables located in tvdpi folder
nodpiDrawablesIntegerNumber of drawables located in nodpi folder
unspecifiedDpiDrawablesIntegerNumber of drawables located in default drawable folder
rawResourcesIntegerNumber of resources in raw/ folder
layoutsIntegerTotal number of layout resources in res/layout* folder
differentLayoutsIntegerNumber of different layout resources in res/layout* folder
menuIntegerTotal number of menu resources in res/menu folder
<a name="hash"/>

File hashes

NameTypeDescription
dexHashStringHash of classes.dex from META-INF/MANIFEST.MF
arscHashStringHash of resources.arsc from META-INF/MANIFEST.MF
drawableHashMap<String,String>Hashes of files in res/drawable* folder from META-INF/MANIFEST.MF. Map<HashValue, fileName>
layoutHashMap<String,String>Hashes of files in res/layout* folder from META-INF/MANIFEST.MF. Map<HashValue, fileName>
otherHashMap<String,String>Hashes of all files in apk from META-INF/MANIFEST.MF. Map<HashValue, fileName>
<a name="Used_libs"/>

Used libraries