How to install apktool in Kali Linux and Termux Android without root

May 21, 2022
Apktool is available for Windows, Kali Linux, and macOS. In this blog, we will install apktool in Kali Linux and Termux. Before installing apktool in Kali Linux, let us answer some questions to make a clear view of on objective of the blog.


What is apktool in Kali Linux?
According to google: Apktool is a preeminent utility to compile, decompile, and edit the Android smali codes to generate working APK using CLI in Linux GUI in Windows.
In short, apktool is a Linux, Windows, and macOS utility to engineer Android applications. Apktool in termux also works same as Kali Linux.


What is zipalign?
According to google: Zipalign is an archive alignment tool introduced first time with 1.6 Android SDK (software development kit). It optimizes the way an Android application package (APK) is packaged.


What is keytool?
According to google: keytool is a key and certificate management utility. It allows users to administer their public/private key pairs and associated certificates for use in self-authentication (where the user authenticates himself/herself to other users/services) or data integrity and authentication services, using digital signatures.


What is Jarsigner?
According to google: The jarsigner command uses key and certificate information from a keystore to generate digital signatures for JAR files. A keystore is a database of private keys and their associated X. 509 certificate chains that authenticate the corresponding public keys.


Today android developers use java JDK (java8 in Kali Linux) to develop Java apps, known as APK apps. Recently python has become more popular among developers. To run Apktool, you require Java JRE installed in Linux or Termux, Windows. We use apktool in termux to inject the msfvenom payload in oreginal apk. This blog is only for educational purposes where we are going to learn how to install apktool in Kali Linux and How to install apktool in Termux.


Do you know about emsf tool by EFX Tv? must click here to know more... Standred command to install apktool in Kali Linux:
 $ sudo apt install apktool 
 $ pkg install apktool 

List the dependencies for apktool? Apktool depends on the packages listed below:
aapt android-framework-res
default-jre-headless | java8-runtime-headless libantlr3-runtime-java
libcommons-cli-java libcommons-io-java
libcommons-lang3-java libcommons-text-java
libguava-java libsmali-java
libstringtemplate-java libxmlunit-java
libxpp3-java libyaml-snake-java

How to install Install apktool in Linux/Termux? (Download updated apktool binary visit apktool official website)
a) How to install apktool in Kali LInux?
Download the apktool binary using the script written below:
 $ curl -L -o $PWD/apktool https://raw.githubusercontent.com/iBotPeaches/Apktool/master/scripts/linux/apktool 
 $ curl -L -o $PWD/apktool.jar https://bitbucket.org/iBotPeaches/apktool/downloads/apktool_2.6.1.jar 
Provide execution permission to the apktool binary
 $ sudo chmod +x apktool* 
Move the apktool binary to the usr/bin directory
 $ sudo mv apktool* /usr/bin/ 
b) How to install apktool in Termux
Download the apktool binary using the script written below:
 $ curl -L -o $PWD/apktool https://raw.githubusercontent.com/iBotPeaches/Apktool/master/scripts/linux/apktool 
 $ curl -L -o $PWD/apktool.jar https://bitbucket.org/iBotPeaches/apktool/downloads/apktool_2.6.1.jar 
Provide execution permission to the apktool binary
 $ chmod +x apktool* 
Move the apktool binary to the usr/bin directory
 $ mv apktool* $PREFIX/bin/ 
c) How to install apktool in Kali Linux using a custom binary or outdated version along with latest one
Till today Apktool 2.6.1 is the latest version. Some older applications may support specific Apktool (outdated version) known as custom apktool installation. To install a custom apktool with a particular version, you need to download and link the script to the /bin/ directory using soft link commands. To create the softlink pointing to the apktool, we will use ln -s command. Step 1
Create a new directory $HOME
 $ mkdir tools/apktool2 
Step 2
Download the files in the apktool2 directory and provide them with execution permissions
 $ curl -L -o $PWD/apktool https://raw.githubusercontent.com/iBotPeaches/Apktool/master/scripts/linux/apktool 
 $ curl -L -o $PWD/apktool.jar https://bitbucket.org/iBotPeaches/apktool/downloads/apktool_2.6.1.jar 
 $ sudo chmod +x apktool* 
Step 3
Create the softlink for both of the files (rename apktool file as apktooll or you desire)
 $ ln -s $HOME/tool/apktool2/apktooll /usr/bin/ 
 $ ln -s $HOME/tool/apktool2/apktool.jar /usr/bin 
Step 4
Open a new terminal and type apktoll to use custom apktool. Now you have 2 apktools installed (apktool and apktooll) consisting of different versions. How to install Apktool in Termux 2.6.2 snapshots in termux? Use the commands to install the Apktool 2.6.2 snapshot version for termux along with zipalign
 $ https://raw.githubusercontent.com/rendiix/rendiix.github.io/master/install-repo.sh | bash  
 $ pkg install zipalign 
Apktool's most used commands in Linux are written below:
 $ sudo apt install apktool 
 $ apktool -version 
 $ apktool -h 
Decompile apk (d=decompile)
 $ apktool d file.apk 
Recompile apk (b=bind)
 $ apktool b file.apk 
Decompile with custom name
 $ apktool d file.apk -o $HOME/Download/outputdir 
Decode AndroidManifest.xml
 $ aapt d xmltree com.file.apk AndroidManifest.xml 
 $ axmldec -o output.xml AndroidManifest.xml 
 $ axmldec -o output.xml AndroidApp.apk 
 $ aapt2 d --file AndroidManifest.xml app.apk 
 $ aapt2 d xmltree --file AndroidManifest.xml file.apk 
 $ androguard axml my.apk -o my.xml 
DEX to Java classes
 $ d2j-dex2jar.sh classes.dex  
DEX to Java pseudo source code
 $ /opt/jadx/build/jadx/bin/jadx -d outputdir classes.dex  
 $ androdd -i classes.dex -o outputdir 
DEX to smali
 $ /opt/android-sdk-linux/build-tools/24.0.2/dexdump -d classes.dex  
 $ java -jar /opt/baksmali.jar -o outputdir classes.dex 
Android resources
 $ /opt/android-sdk-linux/build-tools/24.0.2/aapt dump resources package.apk 
Reading a certificate
 $ keytool -printcert -file cert.rsa 
 $ openssl pkcs7 -inform DER -in CERT.RSA -noout -print_certs -text 
ADB
 $ adb devices 
 $ adb install package.apk 
 $ adb uninstall packagename 
 $ adb forward tcp:port tcp:otherport 
 $ adb pull fileinemulator localpath 
 $ adb push localfile fileinemulator 
 $ adb emu geo fix longitude latitude 
 $ adb shell 
 $ adb logcat 

Click here to watch full screen video

Uk2blogger