Loading...
Loading...
Android APK unpacking and resource extraction tool for reverse engineering. Use when you need to decode APK files, extract resources, examine AndroidManifest.xml, analyze smali code, or repackage modified APKs.
npx skill4agent add brownfinesecurity/iothackbot apktoolapktool d <apk-file> -o <output-directory>apktool d app.apk -o app-unpackedapktool d app.apk -o app-unpacked -fapp-unpacked/
├── AndroidManifest.xml # Readable manifest (permissions, components)
├── apktool.yml # Apktool metadata (version info, SDK levels)
├── original/ # Original META-INF certificates
│ └── META-INF/
├── res/ # Decoded resources
│ ├── layout/ # XML layouts
│ ├── values/ # Strings, colors, dimensions
│ ├── drawable/ # Images and drawables
│ └── ...
├── smali/ # Disassembled DEX code (smali format)
│ └── com/company/app/ # Package structure
├── assets/ # App assets (if present)
├── lib/ # Native libraries (if present)
│ ├── arm64-v8a/
│ ├── armeabi-v7a/
│ └── ...
└── unknown/ # Files apktool couldn't classifyapktool d app.apk -o app-code-only -r
# or
apktool d app.apk -o app-code-only --no-resapktool d app.apk -o app-resources-only -s
# or
apktool d app.apk -o app-resources-only --no-src# After unpacking
cat app-unpacked/AndroidManifest.xmlandroid:allowBackup="true"android:debuggable="true"# Find all permissions
grep "uses-permission" app-unpacked/AndroidManifest.xml
# Find exported components
grep "exported=\"true\"" app-unpacked/AndroidManifest.xml
# Check if debuggable
grep "debuggable" app-unpacked/AndroidManifest.xml
# Find all activities
grep "android:name.*Activity" app-unpacked/AndroidManifest.xml# View all string resources
cat app-unpacked/res/values/strings.xml
# Search for API keys, URLs, credentials
grep -r "api" app-unpacked/res/values/
grep -r "http" app-unpacked/res/values/
grep -r "password\|secret\|key\|token" app-unpacked/res/values/
# Find hardcoded URLs in resources
grep -rE "https?://" app-unpacked/res/# Find specific class
find app-unpacked/smali -name "*Login*.smali"
find app-unpacked/smali -name "*Auth*.smali"
# Search for security-relevant code
grep -r "crypto\|encrypt\|decrypt" app-unpacked/smali/
grep -r "http\|https\|url" app-unpacked/smali/
grep -r "password\|credential\|token" app-unpacked/smali/
# Find native library usage
grep -r "System.loadLibrary" app-unpacked/smali/
# Find file operations
grep -r "openFileOutput\|openFileInput" app-unpacked/smali/# List native libraries
ls -lah app-unpacked/lib/
# Check architectures supported
ls app-unpacked/lib/
# Identify library types
file app-unpacked/lib/arm64-v8a/*.so
# Search for interesting strings in libraries
strings app-unpacked/lib/arm64-v8a/libnative.so | grep -i "http\|key\|password"apktool b app-unpacked -o app-modified.apk# Generate keystore (one-time setup)
keytool -genkey -v -keystore my-release-key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias my-key-alias
# Sign APK
jarsigner -verbose -keystore my-release-key.jks app-modified.apk my-key-alias
# Verify signature
jarsigner -verify app-modified.apk
# Zipalign (optimization)
zipalign -v 4 app-modified.apk app-modified-aligned.apk# Install framework
apktool if framework-res.apk
# List installed frameworks
apktool list-frameworks
# Decode with specific framework
apktool d -t <tag> app.apk# 1. Unpack APK
apktool d target.apk -o target-unpacked
# 2. Examine manifest for security issues
cat target-unpacked/AndroidManifest.xml
# 3. Search for hardcoded credentials
grep -r "password\|api_key\|secret\|token" target-unpacked/res/
# 4. Check for debuggable flag
grep "debuggable" target-unpacked/AndroidManifest.xml
# 5. Find exported components
grep "exported=\"true\"" target-unpacked/AndroidManifest.xml
# 6. Examine network security config
cat target-unpacked/res/xml/network_security_config.xml 2>/dev/null# 1. Unpack APK
apktool d iot-app.apk -o iot-app-unpacked
# 2. Search for device endpoints
grep -rE "https?://[^\"']+" iot-app-unpacked/res/ | grep -v "google\|android"
# 3. Find API keys
grep -r "api\|key" iot-app-unpacked/res/values/strings.xml
# 4. Locate device communication code
find iot-app-unpacked/smali -name "*Device*.smali"
find iot-app-unpacked/smali -name "*Network*.smali"
find iot-app-unpacked/smali -name "*Api*.smali"
# 5. Check for certificate pinning
grep -r "certificatePinner\|TrustManager" iot-app-unpacked/smali/# Fast resource-only extraction
apktool d app.apk -o app-resources -s
# Extract app icon
cp app-resources/res/mipmap-xxxhdpi/ic_launcher.png ./
# Extract strings for localization
cat app-resources/res/values*/strings.xml
# Extract layouts for UI analysis
ls app-resources/res/layout/# Fast code-only extraction
apktool d app.apk -o app-code -r
# Analyze smali quickly
grep -r "http" app-code/smali/ | head -20
grep -r "password" app-code/smali/# Generate analysis report
{
echo "=== APK Analysis Report ==="
echo "APK: app.apk"
echo "Date: $(date)"
echo ""
echo "=== Permissions ==="
grep "uses-permission" app-unpacked/AndroidManifest.xml
echo ""
echo "=== Exported Components ==="
grep "exported=\"true\"" app-unpacked/AndroidManifest.xml
echo ""
echo "=== Package Info ==="
grep "package=" app-unpacked/AndroidManifest.xml
} > apk-analysis-report.txtapktool d app.apk -o app-unpacked
cat app-unpacked/AndroidManifest.xml | less-r-s# Create analysis script
cat > analyze.sh << 'EOF'
#!/bin/bash
APK_DIR="$1"
echo "[+] Searching for URLs..."
grep -rE "https?://" "$APK_DIR/res/" | grep -v "schema\|google\|android"
echo "[+] Searching for API keys..."
grep -ri "api.*key\|apikey" "$APK_DIR/res/"
echo "[+] Searching for secrets..."
grep -ri "secret\|password\|credential" "$APK_DIR/res/"
EOF
chmod +x analyze.sh
./analyze.sh app-unpackedapktool if <framework-res.apk>--keep-broken-resapktool d app.apk -o output --keep-broken-resls -l app.apk
file app.apk # Should show "Zip archive data"export _JAVA_OPTIONS="-Xmx2048m"
apktool d large-app.apk# Check for syntax errors
apktool b app-unpacked -o test.apk --use-aapt2jarsigner -verbose -keystore debug.keystore rebuilt.apk androiddebugkey# Complete analysis workflow
TARGET="myapp.apk"
OUTPUT="myapp-analysis"
# 1. Unpack
echo "[+] Unpacking APK..."
apktool d "$TARGET" -o "$OUTPUT"
# 2. Basic info
echo "[+] Package info:"
grep "package=" "$OUTPUT/AndroidManifest.xml"
# 3. Permissions
echo "[+] Permissions:"
grep "uses-permission" "$OUTPUT/AndroidManifest.xml"
# 4. Exported components
echo "[+] Exported components:"
grep "exported=\"true\"" "$OUTPUT/AndroidManifest.xml"
# 5. Search for secrets
echo "[+] Searching for hardcoded secrets..."
grep -r "api.*key\|password\|secret" "$OUTPUT/res/" | grep -v "^Binary"
# 6. Find URLs
echo "[+] Finding URLs..."
grep -rE "https?://[^\"']+" "$OUTPUT/res/" | grep -v "schema\|xmlns"
# 7. Check debuggable
echo "[+] Debug status:"
grep "debuggable" "$OUTPUT/AndroidManifest.xml" || echo "Not debuggable (good)"
# 8. Summary
echo "[+] Analysis complete. Output in: $OUTPUT/"# Decode (unpack)
apktool d <apk> -o <output-dir>
# Decode with force overwrite
apktool d <apk> -o <output-dir> -f
# Decode without resources (faster)
apktool d <apk> -o <output-dir> -r
# Decode without source (faster)
apktool d <apk> -o <output-dir> -s
# Build (repack)
apktool b <unpacked-dir> -o <output-apk>
# Install framework
apktool if <framework.apk>
# Empty framework cache
apktool empty-framework-dir