apktool

APK Reverse Engineering Tool

🛠️ apktool क्या है?

apktool एक powerful open-source tool है जो Android APK files को reverse engineer करने के लिए use होता है। इसका काम APK को decode करना, resources निकालना, Smali code को edit करना, और फिर से build करना है।

👉 Android app security testing के लिए यह सबसे popular tool है। इससे app के resources (images, strings, layouts) और code को देख सकते हो।

🔍 apktool क्या-क्या कर सकता है

Decode APK

APK को directory में convert करना

Smali Code Edit

Android bytecode में modifications करना

Resources Extract

Images, strings, XML layouts निकालना

Bypass Obfuscation

Obfuscated code को समझना

Manifest Analysis

AndroidManifest.xml देखकर permissions समझना

Rebuild APK

Modifications के बाद फिर से APK build करना और sign करना

⚙️ apktool Install करना

aptInstallation Commands

Update System

apt update

Install Java (required)

apt install openjdk-17-jre

Install apktool

apt install apktool

Check Installation

apktool -v

👉 Termux पर apktool perfectly काम करता है - यह lightweight है और mobile पर easily use हो जाता है।

💻 Basic Commands (Use)

👉 ये basic commands हैं जो तुम daily use करोगे:

Decode APK (extract resources and smali)

apktool d app.apk

Decode APK with output directory

apktool d app.apk -o output_folder

Rebuild APK from decoded folder

apktool b app_folder

Rebuild with specific output path

apktool b app_folder -o new_app.apk

Check apktool version

apktool -v

🌐 Real Example (Practical समझ)

Example🎯 Android App को Decode करना

मान लो तुम्हें एक app.apk दिया है और तुम्हें इसके resources और code को देखना है:

Step 1: APK को decode करो

apktool d app.apk
I: Using Apktool 2.9.3
I: Loading resource table...
I: Decoding AndroidManifest.xml
I: Baksmaling classes...
I: Copying assets and libs...
I: Copying unknown files...
I: Copying original files...

Step 2: Output directory को explore करो

ls -la app/
total 24
drwxr-xr-x  8 user user 4096 Dec 15 10:00 .
drwxr-xr-x  3 user user 4096 Dec 15 10:00 ..
-rw-r--r--  1 user user  230 Dec 15 10:00 AndroidManifest.xml
drwxr-xr-x  3 user user 4096 Dec 15 10:00 smali
drwxr-xr-x  3 user user 4096 Dec 15 10:00 res
drwxr-xr-x  2 user user 4096 Dec 15 10:00 assets
drwxr-xr-x  2 user user 4096 Dec 15 10:00 lib

Step 3: AndroidManifest.xml देखो

cat app/AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.app">
    
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.CAMERA"/>
    
    <application
        android:label="@string/app_name"
        android:icon="@mipmap/ic_launcher">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
    </application>
</manifest>

Step 4: Smali code directory देखो

ls -la app/smali/com/example/app/
MainActivity.smali
NetworkUtils.smali
CameraUtils.smali

Step 5: Smali code देखो

cat app/smali/com/example/app/MainActivity.smali
.class public Lcom/example/app/MainActivity;
.super Landroid/app/Activity;

.method public onCreate(Landroid/os/Bundle;)V
    .registers 2
    
    invoke-super {p0, p1}, Landroid/app/Activity;->onCreate(Landroid/os/Bundle;)V
    
    const-string v0, "Hello from MainActivity!"
    invoke-static {v0}, Landroid/util/Log;->d(Ljava/lang/String;)I
    
    return-void
.end method
🧠 Output समझो

इसका मतलब:

AndroidManifest.xml

App Configuration

Package name, permissions, activities, intents दिख रहे हैं

smali/ directory

Compiled Java Code

Android bytecode (Smali format) में code है

res/ directory

App Resources

Images, layouts, strings, values यहां हैं

Smali Syntax

Android Assembly Language

invoke-super, const-string, return-void जैसे instructions

👉 इससे हमें पता चल गया:

  • • App का package name और permissions
  • • All activities और intents
  • • Smali code में exact logic देख सकते हैं
  • • Resources (images, strings) निकाल सकते हैं

🔥 Advanced Usage

Edit Smali & Rebuild

Smali files में changes करके फिर से apktool b से rebuild करो

Modify Resources

res/values/strings.xml में text, images, layouts change करो

Bypass Security

Root detection, SSL pinning bypass करना

Extract Secrets

API keys, hardcoded strings, passwords find करना

⚠️ Important Warning

किसी भी app को reverse engineer करना illegal हो सकता है

Practice के लिए use करो:

  • अपने बनाए हुए apps
  • Open-source apps
  • CTF challenges और practice apps
  • Bug bounty programs (with permission)

⚠️ Commercial apps, paid apps, और app modification without authorization illegal है और copyright violation हो सकता है

🧩 Related Tools

jadx

Decompile APK to readable Java code

adb

Android Debug Bridge for device interaction

drozer

Android security assessment framework

MobSF

Mobile Security Framework (automated)

💡 Simple समझ

apktool = "Android App का X-ray"

यह APK file को खोलकर अंदर की सब कुछ दिखा देता है — code, images, strings, layout, और सब कुछ।